[PATCH v2 3/8] state: make use of of_find_path_by_phandle() and add return -EPROBE_DEFER if device is not available

Marc Kleine-Budde mkl at pengutronix.de
Tue Oct 20 01:39:07 PDT 2015


Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 drivers/misc/state.c | 37 ++++++++-----------------------------
 1 file changed, 8 insertions(+), 29 deletions(-)

diff --git a/drivers/misc/state.c b/drivers/misc/state.c
index f3e366480fa2..4cda55b6efc6 100644
--- a/drivers/misc/state.c
+++ b/drivers/misc/state.c
@@ -24,7 +24,6 @@
 static int state_probe(struct device_d *dev)
 {
 	struct device_node *np = dev->device_node;
-	struct device_node *partition_node;
 	struct state *state;
 	const char *alias;
 	const char *backend_type = NULL;
@@ -50,35 +49,15 @@ static int state_probe(struct device_d *dev)
 	}
 
 	/* guess if of_path is a path, not a phandle */
-	if (of_path[0] == '/' && len > 1) {
+	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);
-		of_path = partition_node->full_name;
-	}
+	else
+		ret = of_find_path_by_phandle(np, "backend", &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) {
-- 
2.6.1




More information about the barebox mailing list