]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - arch/powerpc/kernel/vio.c
Merge branches 'fixes', 'misc', 'mmci', 'unstable/dma-for-next' and 'sa11x0' into...
[karo-tx-linux.git] / arch / powerpc / kernel / vio.c
index 536016d792baf8a8a7208c4cd2f300c1672d49f2..089de12b9ab0946e324c4521e11936ae685b15da 100644 (file)
@@ -1153,7 +1153,7 @@ EXPORT_SYMBOL(vio_h_cop_sync);
 
 static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
 {
-       const unsigned char *dma_window;
+       const __be32 *dma_window;
        struct iommu_table *tbl;
        unsigned long offset, size;
 
@@ -1312,8 +1312,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
 {
        struct vio_dev *viodev;
        struct device_node *parent_node;
-       const unsigned int *unit_address;
-       const unsigned int *pfo_resid = NULL;
+       const __be32 *prop;
        enum vio_dev_family family;
        const char *of_node_name = of_node->name ? of_node->name : "<unknown>";
 
@@ -1360,6 +1359,8 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
        /* we need the 'device_type' property, in order to match with drivers */
        viodev->family = family;
        if (viodev->family == VDEVICE) {
+               unsigned int unit_address;
+
                if (of_node->type != NULL)
                        viodev->type = of_node->type;
                else {
@@ -1368,24 +1369,24 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
                        goto out;
                }
 
-               unit_address = of_get_property(of_node, "reg", NULL);
-               if (unit_address == NULL) {
+               prop = of_get_property(of_node, "reg", NULL);
+               if (prop == NULL) {
                        pr_warn("%s: node %s missing 'reg'\n",
                                        __func__, of_node_name);
                        goto out;
                }
-               dev_set_name(&viodev->dev, "%x", *unit_address);
+               unit_address = of_read_number(prop, 1);
+               dev_set_name(&viodev->dev, "%x", unit_address);
                viodev->irq = irq_of_parse_and_map(of_node, 0);
-               viodev->unit_address = *unit_address;
+               viodev->unit_address = unit_address;
        } else {
                /* PFO devices need their resource_id for submitting COP_OPs
                 * This is an optional field for devices, but is required when
                 * performing synchronous ops */
-               pfo_resid = of_get_property(of_node, "ibm,resource-id", NULL);
-               if (pfo_resid != NULL)
-                       viodev->resource_id = *pfo_resid;
+               prop = of_get_property(of_node, "ibm,resource-id", NULL);
+               if (prop != NULL)
+                       viodev->resource_id = of_read_number(prop, 1);
 
-               unit_address = NULL;
                dev_set_name(&viodev->dev, "%s", of_node_name);
                viodev->type = of_node_name;
                viodev->irq = 0;
@@ -1412,8 +1413,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
 
                /* needed to ensure proper operation of coherent allocations
                 * later, in case driver doesn't set it explicitly */
-               dma_set_mask(&viodev->dev, DMA_BIT_MASK(64));
-               dma_set_coherent_mask(&viodev->dev, DMA_BIT_MASK(64));
+               dma_set_mask_and_coherent(&viodev->dev, DMA_BIT_MASK(64));
        }
 
        /* register with generic device framework */
@@ -1529,11 +1529,15 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
        const char *cp;
 
        dn = dev->of_node;
-       if (!dn)
-               return -ENODEV;
+       if (!dn) {
+               strcat(buf, "\n");
+               return strlen(buf);
+       }
        cp = of_get_property(dn, "compatible", NULL);
-       if (!cp)
-               return -ENODEV;
+       if (!cp) {
+               strcat(buf, "\n");
+               return strlen(buf);
+       }
 
        return sprintf(buf, "vio:T%sS%s\n", vio_dev->type, cp);
 }
@@ -1622,7 +1626,6 @@ 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[20];
        struct device_node *vnode_parent;
        const char *dev_type;
@@ -1638,10 +1641,13 @@ struct vio_dev *vio_find_node(struct device_node *vnode)
 
        /* construct the kobject name from the device node */
        if (!strcmp(dev_type, "vdevice")) {
-               unit_address = of_get_property(vnode, "reg", NULL);
-               if (!unit_address)
+               const __be32 *prop;
+               
+               prop = of_get_property(vnode, "reg", NULL);
+               if (!prop)
                        return NULL;
-               snprintf(kobj_name, sizeof(kobj_name), "%x", *unit_address);
+               snprintf(kobj_name, sizeof(kobj_name), "%x",
+                        (uint32_t)of_read_number(prop, 1));
        } else if (!strcmp(dev_type, "ibm,platform-facilities"))
                snprintf(kobj_name, sizeof(kobj_name), "%s", vnode->name);
        else