Merge branch 'for_paulus' of master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc
[pandora-kernel.git] / arch / powerpc / kernel / vio.c
index 97082a4..971020c 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 *);
@@ -75,7 +76,7 @@ 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)
+       if (dev->driver && viodrv->shutdown)
                viodrv->shutdown(viodev);
 }
 
@@ -90,9 +91,6 @@ int vio_register_driver(struct vio_driver *viodrv)
 
        /* fill in 'struct driver' fields */
        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);
 }
@@ -204,7 +202,7 @@ static dma_addr_t vio_map_single(struct device *dev, void *vaddr,
                          size_t size, enum dma_data_direction direction)
 {
        return iommu_map_single(to_vio_dev(dev)->iommu_table, vaddr, size,
-                       direction);
+                       ~0ul, direction);
 }
 
 static void vio_unmap_single(struct device *dev, dma_addr_t dma_handle,
@@ -218,7 +216,7 @@ static int vio_map_sg(struct device *dev, struct scatterlist *sglist,
                int nelems, enum dma_data_direction direction)
 {
        return iommu_map_sg(dev, to_vio_dev(dev)->iommu_table, sglist,
-                       nelems, direction);
+                       nelems, ~0ul, direction);
 }
 
 static void vio_unmap_sg(struct device *dev, struct scatterlist *sglist,
@@ -231,7 +229,7 @@ static void *vio_alloc_coherent(struct device *dev, size_t size,
                           dma_addr_t *dma_handle, gfp_t flag)
 {
        return iommu_alloc_coherent(to_vio_dev(dev)->iommu_table, size,
-                       dma_handle, flag);
+                       dma_handle, ~0ul, flag);
 }
 
 static void vio_free_coherent(struct device *dev, size_t size,
@@ -265,7 +263,36 @@ 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",
+       .uevent = vio_hotplug,
        .match = vio_bus_match,
+       .probe = vio_bus_probe,
+       .remove = vio_bus_remove,
+       .shutdown = vio_bus_shutdown,
 };