]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/xen/xenbus/xenbus_probe.c
Merge branches 'core/signal' and 'x86/spinlocks' into x86/xen
[linux-2.6-omap-h63xx.git] / drivers / xen / xenbus / xenbus_probe.c
index 4750de316ad36fbde50524d81beac8f10cfd424f..7f24a98a446f53e0a7fd2bd0ec518494ca7e72cd 100644 (file)
@@ -88,6 +88,16 @@ int xenbus_match(struct device *_dev, struct device_driver *_drv)
        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> */
 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 = {
        .bus = {
                .name     = "xen",
                .match    = xenbus_match,
+               .uevent   = xenbus_uevent,
                .probe    = xenbus_dev_probe,
                .remove   = xenbus_dev_remove,
                .shutdown = xenbus_dev_shutdown,
@@ -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);
 
+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,
                      const char *type,
@@ -492,10 +509,16 @@ int xenbus_probe_node(struct xen_bus_type *bus,
 
        err = device_create_file(&xendev->dev, &dev_attr_devtype);
        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;
-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);
 fail_unregister:
        device_unregister(&xendev->dev);
@@ -791,7 +814,7 @@ static int __init xenbus_probe_init(void)
        DPRINTK("");
 
        err = -ENODEV;
-       if (!is_running_on_xen())
+       if (!xen_domain())
                goto out_error;
 
        /* Register ourselves with the kernel bus subsystem */
@@ -806,7 +829,7 @@ static int __init xenbus_probe_init(void)
        /*
         * Domain0 doesn't have a store_evtchn or store_mfn yet.
         */
-       if (is_initial_xendomain()) {
+       if (xen_initial_domain()) {
                /* dom0 not yet supported */
        } else {
                xenstored_ready = 1;
@@ -823,7 +846,7 @@ static int __init xenbus_probe_init(void)
                goto out_unreg_back;
        }
 
-       if (!is_initial_xendomain())
+       if (!xen_initial_domain())
                xenbus_probe(NULL);
 
        return 0;
@@ -846,6 +869,7 @@ static int is_disconnected_device(struct device *dev, void *data)
 {
        struct xenbus_device *xendev = to_xenbus_device(dev);
        struct device_driver *drv = data;
+       struct xenbus_driver *xendrv;
 
        /*
         * A device with no driver will never connect. We care only about
@@ -858,7 +882,9 @@ static int is_disconnected_device(struct device *dev, void *data)
        if (drv && (dev->driver != drv))
                return 0;
 
-       return (xendev->state != XenbusStateConnected);
+       xendrv = to_xenbus_driver(dev->driver);
+       return (xendev->state != XenbusStateConnected ||
+               (xendrv->is_ready && !xendrv->is_ready(xendev)));
 }
 
 static int exists_disconnected_device(struct device_driver *drv)
@@ -911,7 +937,7 @@ static void wait_for_devices(struct xenbus_driver *xendrv)
        unsigned long timeout = jiffies + 10*HZ;
        struct device_driver *drv = xendrv ? &xendrv->driver : NULL;
 
-       if (!ready_to_wait_for_devices || !is_running_on_xen())
+       if (!ready_to_wait_for_devices || !xen_domain())
                return;
 
        while (exists_disconnected_device(drv)) {