]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/kernel/vio.c
powerpc/pseries: Correct VIO bus accounting problem in CMO env.
[linux-2.6-omap-h63xx.git] / arch / powerpc / kernel / vio.c
index a11e6bc59b307e9d9ac7e6892e95a4eef34f6ca1..d3694498f3af517264d64a332f85733a5b1fbf73 100644 (file)
@@ -41,9 +41,9 @@
 static struct bus_type vio_bus_type;
 
 static struct vio_dev vio_bus_device  = { /* fake "parent" device */
-       .name = vio_bus_device.dev.bus_id,
+       .name = "vio",
        .type = "",
-       .dev.bus_id = "vio",
+       .dev.init_name = "vio",
        .dev.bus = &vio_bus_type,
 };
 
@@ -492,14 +492,14 @@ static void *vio_dma_iommu_alloc_coherent(struct device *dev, size_t size,
        struct vio_dev *viodev = to_vio_dev(dev);
        void *ret;
 
-       if (vio_cmo_alloc(viodev, roundup(size, IOMMU_PAGE_SIZE))) {
+       if (vio_cmo_alloc(viodev, roundup(size, PAGE_SIZE))) {
                atomic_inc(&viodev->cmo.allocs_failed);
                return NULL;
        }
 
        ret = dma_iommu_ops.alloc_coherent(dev, size, dma_handle, flag);
        if (unlikely(ret == NULL)) {
-               vio_cmo_dealloc(viodev, roundup(size, IOMMU_PAGE_SIZE));
+               vio_cmo_dealloc(viodev, roundup(size, PAGE_SIZE));
                atomic_inc(&viodev->cmo.allocs_failed);
        }
 
@@ -513,7 +513,7 @@ static void vio_dma_iommu_free_coherent(struct device *dev, size_t size,
 
        dma_iommu_ops.free_coherent(dev, size, vaddr, dma_handle);
 
-       vio_cmo_dealloc(viodev, roundup(size, IOMMU_PAGE_SIZE));
+       vio_cmo_dealloc(viodev, roundup(size, PAGE_SIZE));
 }
 
 static dma_addr_t vio_dma_iommu_map_page(struct device *dev, struct page *page,
@@ -572,6 +572,7 @@ static int vio_dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
        if (unlikely(!ret)) {
                vio_cmo_dealloc(viodev, alloc_size);
                atomic_inc(&viodev->cmo.allocs_failed);
+               return ret;
        }
 
        for (sgl = sglist, count = 0; count < ret; count++, sgl++)
@@ -1216,7 +1217,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
 
        viodev->irq = irq_of_parse_and_map(of_node, 0);
 
-       snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%x", *unit_address);
+       dev_set_name(&viodev->dev, "%x", *unit_address);
        viodev->name = of_node->name;
        viodev->type = of_node->type;
        viodev->unit_address = *unit_address;
@@ -1243,7 +1244,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
        /* register with generic device framework */
        if (device_register(&viodev->dev)) {
                printk(KERN_ERR "%s: failed to register device %s\n",
-                               __func__, viodev->dev.bus_id);
+                               __func__, dev_name(&viodev->dev));
                /* XXX free TCE table */
                kfree(viodev);
                return NULL;
@@ -1400,13 +1401,13 @@ static struct vio_dev *vio_find_name(const char *name)
 struct vio_dev *vio_find_node(struct device_node *vnode)
 {
        const uint32_t *unit_address;
-       char kobj_name[BUS_ID_SIZE];
+       char kobj_name[20];
 
        /* construct the kobject name from the device node */
        unit_address = of_get_property(vnode, "reg", NULL);
        if (!unit_address)
                return NULL;
-       snprintf(kobj_name, BUS_ID_SIZE, "%x", *unit_address);
+       snprintf(kobj_name, sizeof(kobj_name), "%x", *unit_address);
 
        return vio_find_name(kobj_name);
 }