fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / eisa / eisa-bus.c
index af825fc..d944647 100644 (file)
@@ -128,20 +128,29 @@ 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)
 {
-       int r;
-       
        edrv->driver.bus = &eisa_bus_type;
-       if ((r = driver_register (&edrv->driver)) < 0)
-               return r;
-
-       return 0;
+       return driver_register (&edrv->driver);
 }
 
 void eisa_driver_unregister (struct eisa_driver *edrv)
@@ -149,7 +158,7 @@ void eisa_driver_unregister (struct eisa_driver *edrv)
        driver_unregister (&edrv->driver);
 }
 
-static ssize_t eisa_show_sig (struct device *dev, char *buf)
+static ssize_t eisa_show_sig (struct device *dev, struct device_attribute *attr, char *buf)
 {
         struct eisa_device *edev = to_eisa_device (dev);
         return sprintf (buf,"%s\n", edev->id.sig);
@@ -157,7 +166,7 @@ static ssize_t eisa_show_sig (struct device *dev, char *buf)
 
 static DEVICE_ATTR(signature, S_IRUGO, eisa_show_sig, NULL);
 
-static ssize_t eisa_show_state (struct device *dev, char *buf)
+static ssize_t eisa_show_state (struct device *dev, struct device_attribute *attr, char *buf)
 {
         struct eisa_device *edev = to_eisa_device (dev);
         return sprintf (buf,"%d\n", edev->state & EISA_CONFIG_ENABLED);
@@ -165,6 +174,14 @@ static ssize_t eisa_show_state (struct device *dev, char *buf)
 
 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)
@@ -209,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,
@@ -281,13 +311,11 @@ static int __init eisa_probe (struct eisa_root_device *root)
        /* First try to get hold of slot 0. If there is no device
         * here, simply fail, unless root->force_probe is set. */
        
-       if (!(edev = kmalloc (sizeof (*edev), GFP_KERNEL))) {
+       if (!(edev = kzalloc (sizeof (*edev), GFP_KERNEL))) {
                printk (KERN_ERR "EISA: Couldn't allocate mainboard slot\n");
                return -ENOMEM;
        }
                
-       memset (edev, 0, sizeof (*edev));
-
        if (eisa_request_resources (root, edev, 0)) {
                printk (KERN_WARNING \
                        "EISA: Cannot allocate resource for mainboard\n");
@@ -317,13 +345,11 @@ static int __init eisa_probe (struct eisa_root_device *root)
  force_probe:
        
         for (c = 0, i = 1; i <= root->slots; i++) {
-               if (!(edev = kmalloc (sizeof (*edev), GFP_KERNEL))) {
+               if (!(edev = kzalloc (sizeof (*edev), GFP_KERNEL))) {
                        printk (KERN_ERR "EISA: Out of memory for slot %d\n",
                                i);
                        continue;
                }
-               
-               memset (edev, 0, sizeof (*edev));
 
                if (eisa_request_resources (root, edev, i)) {
                        printk (KERN_WARNING \
@@ -418,8 +444,8 @@ static int __init eisa_init (void)
        return 0;
 }
 
-module_param_array(enable_dev, int, enable_dev_count, 0444);
-module_param_array(disable_dev, int, disable_dev_count, 0444);
+module_param_array(enable_dev, int, &enable_dev_count, 0444);
+module_param_array(disable_dev, int, &disable_dev_count, 0444);
 
 postcore_initcall (eisa_init);