]> err.no Git - linux-2.6/blobdiff - drivers/macintosh/macio_asic.c
Merge branch 'genirq' of master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6] / drivers / macintosh / macio_asic.c
index ed6d3174d66050f1ca3358909469770682111243..40ae7b6a939da8c492afd1576d61ea24e89dac99 100644 (file)
@@ -17,7 +17,6 @@
  *    sub-devices.
  */
  
-#include <linux/config.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
@@ -140,10 +139,9 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
 {
        struct macio_dev * macio_dev;
        struct of_device * of;
-       char *scratch, *compat;
+       char *scratch, *compat, *compat2;
        int i = 0;
-       int length = 0;
-       int cplen, seen = 0;
+       int length, cplen, cplen2, seen = 0;
 
        if (!dev)
                return -ENODEV;
@@ -153,23 +151,22 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
                return -ENODEV;
 
        of = &macio_dev->ofdev;
-       scratch = buffer;
 
        /* stuff we want to pass to /sbin/hotplug */
-       envp[i++] = scratch;
-       length += scnprintf (scratch, buffer_size - length, "OF_NAME=%s",
-                            of->node->name);
-       if ((buffer_size - length <= 0) || (i >= num_envp))
-               return -ENOMEM;
+       envp[i++] = scratch = buffer;
+       length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name);
        ++length;
+       buffer_size -= length;
+       if ((buffer_size <= 0) || (i >= num_envp))
+               return -ENOMEM;
        scratch += length;
 
        envp[i++] = scratch;
-       length += scnprintf (scratch, buffer_size - length, "OF_TYPE=%s",
-                            of->node->type);
-       if ((buffer_size - length <= 0) || (i >= num_envp))
-               return -ENOMEM;
+       length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type);
        ++length;
+       buffer_size -= length;
+       if ((buffer_size <= 0) || (i >= num_envp))
+               return -ENOMEM;
        scratch += length;
 
         /* Since the compatible field can contain pretty much anything
@@ -177,29 +174,55 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
          * up using a number of environment variables instead. */
 
        compat = (char *) get_property(of->node, "compatible", &cplen);
+       compat2 = compat;
+       cplen2= cplen;
        while (compat && cplen > 0) {
-               int l;
                 envp[i++] = scratch;
-               length += scnprintf (scratch, buffer_size - length,
+               length = scnprintf (scratch, buffer_size,
                                     "OF_COMPATIBLE_%d=%s", seen, compat);
-               if ((buffer_size - length <= 0) || (i >= num_envp))
+               ++length;
+               buffer_size -= length;
+               if ((buffer_size <= 0) || (i >= num_envp))
                        return -ENOMEM;
-               length++;
                scratch += length;
-               l = strlen (compat) + 1;
-               compat += l;
-               cplen -= l;
+               length = strlen (compat) + 1;
+               compat += length;
+               cplen -= length;
                seen++;
        }
 
        envp[i++] = scratch;
-       length += scnprintf (scratch, buffer_size - length,
-                            "OF_COMPATIBLE_N=%d", seen);
-       if ((buffer_size - length <= 0) || (i >= num_envp))
-               return -ENOMEM;
+       length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen);
        ++length;
+       buffer_size -= length;
+       if ((buffer_size <= 0) || (i >= num_envp))
+               return -ENOMEM;
+       scratch += length;
+
+       envp[i++] = scratch;
+       length = scnprintf (scratch, buffer_size, "MODALIAS=of:N%sT%s",
+                       of->node->name, of->node->type);
+       /* overwrite '\0' */
+       buffer_size -= length;
+       if ((buffer_size <= 0) || (i >= num_envp))
+               return -ENOMEM;
        scratch += length;
 
+       if (!compat2) {
+               compat2 = "";
+               cplen2 = 1;
+       }
+       while (cplen2 > 0) {
+               length = snprintf (scratch, buffer_size, "C%s", compat2);
+               buffer_size -= length;
+               if (buffer_size <= 0)
+                       return -ENOMEM;
+               scratch += length;
+               length = strlen (compat2) + 1;
+               compat2 += length;
+               cplen2 -= length;
+       }
+
        envp[i] = NULL;
 
        return 0;
@@ -404,10 +427,10 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
 
        /* MacIO itself has a different reg, we use it's PCI base */
        if (np == chip->of_node) {
-               sprintf(dev->ofdev.dev.bus_id, "%1d.%08lx:%.*s",
+               sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s",
                        chip->lbus.index,
 #ifdef CONFIG_PCI
-                       pci_resource_start(chip->lbus.pdev, 0),
+                       (unsigned int)pci_resource_start(chip->lbus.pdev, 0),
 #else
                        0, /* NuBus may want to do something better here */
 #endif
@@ -526,15 +549,12 @@ static void macio_pci_add_devices(struct macio_chip *chip)
  */
 int macio_register_driver(struct macio_driver *drv)
 {
-       int count = 0;
-
        /* initialize common driver fields */
        drv->driver.name = drv->name;
        drv->driver.bus = &macio_bus_type;
 
        /* register with core */
-       count = driver_register(&drv->driver);
-       return count ? count : 1;
+       return driver_register(&drv->driver);
 }
 
 /**