summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-07-10 08:49:46 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-07-15 11:16:14 +0200
commit0ee203186d1adf98a04484ee9e601ca9714f0497 (patch)
treeb1824fd716dfbc4ce8143ed156c772efcf873d4b /fs
parent2672c906a4b83cd2aef1ddc0b9d2ec54b89eba3d (diff)
downloadbarebox-0ee203186d1adf98a04484ee9e601ca9714f0497.tar.gz
barebox-0ee203186d1adf98a04484ee9e601ca9714f0497.tar.xz
cdev: add device_find_partition
device_find_partition allows to find a partition of a device with a particular name. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/devfs-core.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 816f244f1c..a92d4347f8 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -56,6 +56,33 @@ struct cdev *cdev_by_name(const char *filename)
return NULL;
}
+/**
+ * device_find_partition - find a partition belonging to a physical device
+ *
+ * @dev: the device which should be searched for partitions
+ * @name: the partition name
+ */
+struct cdev *device_find_partition(struct device_d *dev, const char *name)
+{
+ struct cdev *cdev;
+ struct device_d *child;
+
+ list_for_each_entry(cdev, &dev->cdevs, devices_list) {
+ if (!cdev->partname)
+ continue;
+ if (!strcmp(cdev->partname, name))
+ return cdev;
+ }
+
+ device_for_each_child(dev, child) {
+ cdev = device_find_partition(child, name);
+ if (cdev)
+ return cdev;
+ }
+
+ return NULL;
+}
+
int cdev_find_free_index(const char *basename)
{
int i;