From 601dcf7644814a3c9dc2a332bbd065d94d133edd Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 9 Apr 2014 15:12:30 +0200 Subject: [PATCH 1/3] of: partition: set device_node of the newly created partition So that we can find the devicenode for a partition. Signed-off-by: Sascha Hauer --- drivers/of/partition.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/of/partition.c b/drivers/of/partition.c index 5ed44a84d..0560eb3af 100644 --- a/drivers/of/partition.c +++ b/drivers/of/partition.c @@ -60,6 +60,8 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node) filename = asprintf("%s.%s", cdev->name, partname); new = devfs_add_partition(cdev->name, offset, size, flags, filename); + if (new && new->dev) + new->dev->device_node = node; if (cdev->mtd && cdev->mtd->type == MTD_NANDFLASH) dev_add_bb_dev(filename, NULL); From 12c7f5d560799ff57cf4acc23f056ad7962a040e Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 9 Apr 2014 15:19:38 +0200 Subject: [PATCH 2/3] of: move of_find_device_by_node_path to drivers/of/of_path.c As it's generic helper function which should not stay in driver specific code. Signed-off-by: Sascha Hauer --- drivers/of/barebox.c | 14 -------------- drivers/of/of_path.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/of/barebox.c b/drivers/of/barebox.c index 44ec820ec..92471f83e 100644 --- a/drivers/of/barebox.c +++ b/drivers/of/barebox.c @@ -34,20 +34,6 @@ struct of_partition { static LIST_HEAD(of_partition_list); -struct device_d *of_find_device_by_node_path(const char *path) -{ - struct device_d *dev; - - for_each_device(dev) { - if (!dev->device_node) - continue; - if (!strcmp(path, dev->device_node->full_name)) - return dev; - } - - return NULL; -} - static int environment_probe(struct device_d *dev) { char *path; diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c index ab8618e23..20eb771e6 100644 --- a/drivers/of/of_path.c +++ b/drivers/of/of_path.c @@ -31,6 +31,20 @@ struct of_path_type { int (*parse)(struct of_path *op, const char *str); }; +struct device_d *of_find_device_by_node_path(const char *path) +{ + struct device_d *dev; + + for_each_device(dev) { + if (!dev->device_node) + continue; + if (!strcmp(path, dev->device_node->full_name)) + return dev; + } + + return NULL; +} + /** * of_path_type_partname - find a partition based on physical device and * partition name From 66d0f93d5ca372b985dc61d01177fdc5f88392b4 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 9 Apr 2014 15:16:34 +0200 Subject: [PATCH 3/3] of_path: Allow to specify path with phandle only Instead of just allowing to specify an OF path with additional partname: property allow to specify a phandle to the partition directly. Signed-off-by: Sascha Hauer --- drivers/of/of_path.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c index 20eb771e6..6a2d634dc 100644 --- a/drivers/of/of_path.c +++ b/drivers/of/of_path.c @@ -148,6 +148,9 @@ int of_find_path(struct device_node *node, const char *propname, char **outpath) device_detect(op.dev); + if (list_is_singular(&op.dev->cdevs)) + op.cdev = list_first_entry(&op.dev->cdevs, struct cdev, devices_list); + i = 1; while (1) {