driver core: add root_device_register()

Add support for allocating root device objects which group
device objects under /sys/devices directories.

Also add a sysfs 'module' symlink which points to the owner
of the root device object. This symlink will be used in virtio
to allow userspace to determine which virtio bus implementation
a given device is associated with.

[Includes suggestions from Cornelia Huck]

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Mark McLoughlin
2008-12-15 12:58:26 +00:00
committed by Greg Kroah-Hartman
parent 7232800ba8
commit 0aa0dc41bf
2 changed files with 102 additions and 0 deletions

View File

@@ -482,6 +482,17 @@ extern struct device *device_find_child(struct device *dev, void *data,
extern int device_rename(struct device *dev, char *new_name);
extern int device_move(struct device *dev, struct device *new_parent);
/*
* Root device objects for grouping under /sys/devices
*/
extern struct device *__root_device_register(const char *name,
struct module *owner);
static inline struct device *root_device_register(const char *name)
{
return __root_device_register(name, THIS_MODULE);
}
extern void root_device_unregister(struct device *root);
/*
* Manual binding of a device to driver. See drivers/base/bus.c
* for information on use.