Merge ../linux-2.6-watchdog-mm
[linux-drm-fsl-dcu.git] / drivers / eisa / eisa-bus.c
index 6078e2f588172e73aad9ad45ec2a3cfb9eb7e97d..d944647c82c2e0dfc771fb286a3554569e0f487c 100644 (file)
@@ -128,9 +128,23 @@ static int eisa_bus_match (struct device *dev, struct device_driver *drv)
        return 0;
 }
 
+static int eisa_bus_uevent(struct device *dev, char **envp, int num_envp,
+                          char *buffer, int buffer_size)
+{
+       struct eisa_device *edev = to_eisa_device(dev);
+       int i = 0;
+       int length = 0;
+
+       add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
+                      "MODALIAS=" EISA_DEVICE_MODALIAS_FMT, edev->id.sig);
+       envp[i] = NULL;
+       return 0;
+}
+
 struct bus_type eisa_bus_type = {
        .name  = "eisa",
        .match = eisa_bus_match,
+       .uevent = eisa_bus_uevent,
 };
 
 int eisa_driver_register (struct eisa_driver *edrv)
@@ -160,6 +174,14 @@ static ssize_t eisa_show_state (struct device *dev, struct device_attribute *att
 
 static DEVICE_ATTR(enabled, S_IRUGO, eisa_show_state, NULL);
 
+static ssize_t eisa_show_modalias (struct device *dev, struct device_attribute *attr, char *buf)
+{
+        struct eisa_device *edev = to_eisa_device (dev);
+        return sprintf (buf, EISA_DEVICE_MODALIAS_FMT "\n", edev->id.sig);
+}
+
+static DEVICE_ATTR(modalias, S_IRUGO, eisa_show_modalias, NULL);
+
 static int __init eisa_init_device (struct eisa_root_device *root,
                                    struct eisa_device *edev,
                                    int slot)
@@ -204,13 +226,26 @@ static int __init eisa_init_device (struct eisa_root_device *root,
 
 static int __init eisa_register_device (struct eisa_device *edev)
 {
-       if (device_register (&edev->dev))
-               return -1;
+       int rc = device_register (&edev->dev);
+       if (rc)
+               return rc;
 
-       device_create_file (&edev->dev, &dev_attr_signature);
-       device_create_file (&edev->dev, &dev_attr_enabled);
+       rc = device_create_file (&edev->dev, &dev_attr_signature);
+       if (rc) goto err_devreg;
+       rc = device_create_file (&edev->dev, &dev_attr_enabled);
+       if (rc) goto err_sig;
+       rc = device_create_file (&edev->dev, &dev_attr_modalias);
+       if (rc) goto err_enab;
 
        return 0;
+
+err_enab:
+       device_remove_file (&edev->dev, &dev_attr_enabled);
+err_sig:
+       device_remove_file (&edev->dev, &dev_attr_signature);
+err_devreg:
+       device_unregister(&edev->dev);
+       return rc;
 }
 
 static int __init eisa_request_resources (struct eisa_root_device *root,