diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-10-22 11:03:39 +1000 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2007-10-23 15:49:55 +1000 |
commit | b01d9f2863349b0e041b90c3c86a998ee0fed2b0 (patch) | |
tree | 8789a06631a0ee502c58388d12c230eb4a2059b2 /drivers/virtio | |
parent | 31610434bc3523c0b01a10917a1185096a03c4c8 (diff) | |
download | linux-b01d9f2863349b0e041b90c3c86a998ee0fed2b0.tar.bz2 |
Module autoprobing support for virtio drivers.
This adds the logic to convert the virtio ids into module aliases, and
includes a modalias entry in sysfs and the env var to make probing work.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio')
-rw-r--r-- | drivers/virtio/virtio.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index f640e0b732b7..15d7787dea87 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -20,10 +20,19 @@ static ssize_t status_show(struct device *_d, struct virtio_device *dev = container_of(_d,struct virtio_device,dev); return sprintf(buf, "0x%08x", dev->config->get_status(dev)); } +static ssize_t modalias_show(struct device *_d, + struct device_attribute *attr, char *buf) +{ + struct virtio_device *dev = container_of(_d,struct virtio_device,dev); + + return sprintf(buf, "virtio:d%08Xv%08X\n", + dev->id.device, dev->id.vendor); +} static struct device_attribute virtio_dev_attrs[] = { __ATTR_RO(device), __ATTR_RO(vendor), __ATTR_RO(status), + __ATTR_RO(modalias), __ATTR_NULL }; @@ -51,10 +60,19 @@ static int virtio_dev_match(struct device *_dv, struct device_driver *_dr) return 0; } +static int virtio_uevent(struct device *_dv, struct kobj_uevent_env *env) +{ + struct virtio_device *dev = container_of(_dv,struct virtio_device,dev); + + return add_uevent_var(env, "MODALIAS=virtio:d%08Xv%08X", + dev->id.device, dev->id.vendor); +} + static struct bus_type virtio_bus = { .name = "virtio", .match = virtio_dev_match, .dev_attrs = virtio_dev_attrs, + .uevent = virtio_uevent, }; static void add_status(struct virtio_device *dev, unsigned status) |