]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/powerpc/kernel/vio.c
[PATCH] powerpc: Merge signal.h
[karo-tx-linux.git] / arch / powerpc / kernel / vio.c
index 3aec492ec76721d363390ffda237202de8e71738..71a6addf9f7fba85e81d614235cfc72670b569d0 100644 (file)
@@ -21,6 +21,7 @@
 #include <asm/iommu.h>
 #include <asm/dma.h>
 #include <asm/vio.h>
+#include <asm/prom.h>
 
 static const struct vio_device_id *vio_match_device(
                const struct vio_device_id *, const struct vio_dev *);
@@ -69,6 +70,16 @@ static int vio_bus_remove(struct device *dev)
        return 1;
 }
 
+/* convert from struct device to struct vio_dev and pass to driver. */
+static void vio_bus_shutdown(struct device *dev)
+{
+       struct vio_dev *viodev = to_vio_dev(dev);
+       struct vio_driver *viodrv = to_vio_driver(dev->driver);
+
+       if (viodrv->shutdown)
+               viodrv->shutdown(viodev);
+}
+
 /**
  * vio_register_driver: - Register a new vio driver
  * @drv:       The vio_driver structure to be registered.
@@ -82,6 +93,7 @@ int vio_register_driver(struct vio_driver *viodrv)
        viodrv->driver.bus = &vio_bus_type;
        viodrv->driver.probe = vio_bus_probe;
        viodrv->driver.remove = vio_bus_remove;
+       viodrv->driver.shutdown = vio_bus_shutdown;
 
        return driver_register(&viodrv->driver);
 }
@@ -254,7 +266,33 @@ static int vio_bus_match(struct device *dev, struct device_driver *drv)
        return (ids != NULL) && (vio_match_device(ids, vio_dev) != NULL);
 }
 
+static int vio_hotplug(struct device *dev, char **envp, int num_envp,
+                       char *buffer, int buffer_size)
+{
+       const struct vio_dev *vio_dev = to_vio_dev(dev);
+       char *cp;
+       int length;
+
+       if (!num_envp)
+               return -ENOMEM;
+
+       if (!vio_dev->dev.platform_data)
+               return -ENODEV;
+       cp = (char *)get_property(vio_dev->dev.platform_data, "compatible", &length);
+       if (!cp)
+               return -ENODEV;
+
+       envp[0] = buffer;
+       length = scnprintf(buffer, buffer_size, "MODALIAS=vio:T%sS%s",
+                               vio_dev->type, cp);
+       if (buffer_size - length <= 0)
+               return -ENOMEM;
+       envp[1] = NULL;
+       return 0;
+}
+
 struct bus_type vio_bus_type = {
        .name = "vio",
+       .hotplug = vio_hotplug,
        .match = vio_bus_match,
 };