summaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2015-10-25 22:03:30 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-11-27 08:26:40 +0100
commitef39770210090086f019b636bc197fa189433c05 (patch)
tree69e9197fa6b0ee4845208608996d561607119ec1 /drivers/misc
parent21aea1d9ff07bbb9098d419118d9a4de0d5bfc60 (diff)
downloadbarebox-ef39770210090086f019b636bc197fa189433c05.tar.gz
state: make use of of_find_path_by_node() and add return -EPROBE_DEFER if device is not available
Signed-off-by: Uwe Kleine-K├Ânig <u.kleine-koenig@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/state.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/drivers/misc/state.c b/drivers/misc/state.c
index f3e3664..2255147 100644
--- a/drivers/misc/state.c
+++ b/drivers/misc/state.c
@@ -52,34 +52,21 @@ static int state_probe(struct device_d *dev)
/* guess if of_path is a path, not a phandle */
if (of_path[0] == '/' && len > 1) {
ret = of_find_path(np, "backend", &path, 0);
- if (ret)
- goto out_release;
} else {
- struct device_d *dev;
- struct cdev *cdev;
partition_node = of_parse_phandle(np, "backend", 0);
- if (!partition_node) {
- ret = -ENODEV;
- goto out_release;
- }
-
- dev = of_find_device_by_node(partition_node);
- if (!list_is_singular(&dev->cdevs)) {
- ret = -ENODEV;
- goto out_release;
- }
-
- cdev = list_first_entry(&dev->cdevs, struct cdev, devices_list);
- if (!cdev) {
- ret = -ENODEV;
- goto out_release;
- }
-
- path = asprintf("/dev/%s", cdev->name);
+ if (!partition_node)
+ return -EINVAL;
+
of_path = partition_node->full_name;
+ ret = of_find_path_by_node(partition_node, &path, 0);
}
+ if (ret == -ENODEV)
+ ret = -EPROBE_DEFER;
+ if (ret)
+ goto out_release;
+
ret = of_property_read_string(np, "backend-type", &backend_type);
if (ret) {
goto out_free;