diff --git a/drivers/of/partition.c b/drivers/of/partition.c index 3dce844..6017897 100644 --- a/drivers/of/partition.c +++ b/drivers/of/partition.c @@ -64,8 +64,8 @@ if (IS_ERR(new)) new = NULL; - if (new && new->dev) - new->dev->device_node = node; + if (new) + new->device_node = node;; free(filename); diff --git a/fs/devfs-core.c b/fs/devfs-core.c index f45f8ca..62571fb 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -57,6 +57,19 @@ return NULL; } +struct cdev *cdev_by_device_node(struct device_node *node) +{ + struct cdev *cdev; + + list_for_each_entry(cdev, &cdev_list, list) { + if (!cdev->device_node) + continue; + if (cdev->device_node == node) + return cdev; + } + return NULL; +} + /** * device_find_partition - find a partition belonging to a physical device * diff --git a/include/driver.h b/include/driver.h index 728f8ab..046dd90 100644 --- a/include/driver.h +++ b/include/driver.h @@ -436,6 +436,7 @@ struct file_operations *ops; void *priv; struct device_d *dev; + struct device_node *device_node; struct list_head list; struct list_head devices_list; char *name; /* filename under /dev/ */ @@ -456,6 +457,7 @@ int cdev_find_free_index(const char *); struct cdev *device_find_partition(struct device_d *dev, const char *name); struct cdev *cdev_by_name(const char *filename); +struct cdev *cdev_by_device_node(struct device_node *node); struct cdev *cdev_open(const char *name, unsigned long flags); int cdev_do_open(struct cdev *, unsigned long flags); void cdev_close(struct cdev *cdev);