Commit d2f0c52b authored by Mark McLoughlin's avatar Mark McLoughlin Committed by Ingo Molnar

xen: Module autoprobing support for frontend drivers

Add module aliases to support autoprobing modules
for xen frontend devices.
Signed-off-by: default avatarMark McLoughlin <markmc@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 1d78d705
...@@ -1015,3 +1015,4 @@ module_exit(xlblk_exit); ...@@ -1015,3 +1015,4 @@ module_exit(xlblk_exit);
MODULE_DESCRIPTION("Xen virtual block device frontend"); MODULE_DESCRIPTION("Xen virtual block device frontend");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS_BLOCKDEV_MAJOR(XENVBD_MAJOR); MODULE_ALIAS_BLOCKDEV_MAJOR(XENVBD_MAJOR);
MODULE_ALIAS("xen:vbd");
...@@ -1809,3 +1809,4 @@ module_exit(netif_exit); ...@@ -1809,3 +1809,4 @@ module_exit(netif_exit);
MODULE_DESCRIPTION("Xen virtual network device frontend"); MODULE_DESCRIPTION("Xen virtual network device frontend");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("xen:vif");
...@@ -88,6 +88,16 @@ int xenbus_match(struct device *_dev, struct device_driver *_drv) ...@@ -88,6 +88,16 @@ int xenbus_match(struct device *_dev, struct device_driver *_drv)
return match_device(drv->ids, to_xenbus_device(_dev)) != NULL; return match_device(drv->ids, to_xenbus_device(_dev)) != NULL;
} }
static int xenbus_uevent(struct device *_dev, struct kobj_uevent_env *env)
{
struct xenbus_device *dev = to_xenbus_device(_dev);
if (add_uevent_var(env, "MODALIAS=xen:%s", dev->devicetype))
return -ENOMEM;
return 0;
}
/* device/<type>/<id> => <type>-<id> */ /* device/<type>/<id> => <type>-<id> */
static int frontend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename) static int frontend_bus_id(char bus_id[BUS_ID_SIZE], const char *nodename)
{ {
...@@ -166,6 +176,7 @@ static struct xen_bus_type xenbus_frontend = { ...@@ -166,6 +176,7 @@ static struct xen_bus_type xenbus_frontend = {
.bus = { .bus = {
.name = "xen", .name = "xen",
.match = xenbus_match, .match = xenbus_match,
.uevent = xenbus_uevent,
.probe = xenbus_dev_probe, .probe = xenbus_dev_probe,
.remove = xenbus_dev_remove, .remove = xenbus_dev_remove,
.shutdown = xenbus_dev_shutdown, .shutdown = xenbus_dev_shutdown,
...@@ -438,6 +449,12 @@ static ssize_t xendev_show_devtype(struct device *dev, ...@@ -438,6 +449,12 @@ static ssize_t xendev_show_devtype(struct device *dev,
} }
DEVICE_ATTR(devtype, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_devtype, NULL); DEVICE_ATTR(devtype, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_devtype, NULL);
static ssize_t xendev_show_modalias(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "xen:%s\n", to_xenbus_device(dev)->devicetype);
}
DEVICE_ATTR(modalias, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_modalias, NULL);
int xenbus_probe_node(struct xen_bus_type *bus, int xenbus_probe_node(struct xen_bus_type *bus,
const char *type, const char *type,
...@@ -492,10 +509,16 @@ int xenbus_probe_node(struct xen_bus_type *bus, ...@@ -492,10 +509,16 @@ int xenbus_probe_node(struct xen_bus_type *bus,
err = device_create_file(&xendev->dev, &dev_attr_devtype); err = device_create_file(&xendev->dev, &dev_attr_devtype);
if (err) if (err)
goto fail_remove_file; goto fail_remove_nodename;
err = device_create_file(&xendev->dev, &dev_attr_modalias);
if (err)
goto fail_remove_devtype;
return 0; return 0;
fail_remove_file: fail_remove_devtype:
device_remove_file(&xendev->dev, &dev_attr_devtype);
fail_remove_nodename:
device_remove_file(&xendev->dev, &dev_attr_nodename); device_remove_file(&xendev->dev, &dev_attr_nodename);
fail_unregister: fail_unregister:
device_unregister(&xendev->dev); device_unregister(&xendev->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment