Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: of_parse_dma_window should take a __be32 *dma_window

We pass dma_window to of_parse_dma_window as a void * and then
run through hoops to cast it back to a u32 array. In the process
we lose endian annotation.

Simplify it by just passing a __be32 * down.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Anton Blanchard and committed by
Benjamin Herrenschmidt
2083f681 d213dd53

+17 -17
+3 -2
arch/powerpc/include/asm/prom.h
··· 38 38 /* Parse the ibm,dma-window property of an OF node into the busno, phys and 39 39 * size parameters. 40 40 */ 41 - void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, 42 - unsigned long *busno, unsigned long *phys, unsigned long *size); 41 + void of_parse_dma_window(struct device_node *dn, const __be32 *dma_window, 42 + unsigned long *busno, unsigned long *phys, 43 + unsigned long *size); 43 44 44 45 extern void kdump_move_device_tree(void); 45 46
+8 -9
arch/powerpc/kernel/prom_parse.c
··· 7 7 #include <linux/of_address.h> 8 8 #include <asm/prom.h> 9 9 10 - void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, 11 - unsigned long *busno, unsigned long *phys, unsigned long *size) 10 + void of_parse_dma_window(struct device_node *dn, const __be32 *dma_window, 11 + unsigned long *busno, unsigned long *phys, 12 + unsigned long *size) 12 13 { 13 - const u32 *dma_window; 14 14 u32 cells; 15 - const unsigned char *prop; 16 - 17 - dma_window = dma_window_prop; 15 + const __be32 *prop; 18 16 19 17 /* busno is always one cell */ 20 - *busno = *(dma_window++); 18 + *busno = of_read_number(dma_window, 1); 19 + dma_window++; 21 20 22 21 prop = of_get_property(dn, "ibm,#dma-address-cells", NULL); 23 22 if (!prop) 24 23 prop = of_get_property(dn, "#address-cells", NULL); 25 24 26 - cells = prop ? *(u32 *)prop : of_n_addr_cells(dn); 25 + cells = prop ? of_read_number(prop, 1) : of_n_addr_cells(dn); 27 26 *phys = of_read_number(dma_window, cells); 28 27 29 28 dma_window += cells; 30 29 31 30 prop = of_get_property(dn, "ibm,#dma-size-cells", NULL); 32 - cells = prop ? *(u32 *)prop : of_n_size_cells(dn); 31 + cells = prop ? of_read_number(prop, 1) : of_n_size_cells(dn); 33 32 *size = of_read_number(dma_window, cells); 34 33 }
+1 -1
arch/powerpc/kernel/vio.c
··· 1153 1153 1154 1154 static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev) 1155 1155 { 1156 - const unsigned char *dma_window; 1156 + const __be32 *dma_window; 1157 1157 struct iommu_table *tbl; 1158 1158 unsigned long offset, size; 1159 1159
+1 -1
arch/powerpc/platforms/cell/iommu.c
··· 697 697 unsigned long *base, 698 698 unsigned long *size) 699 699 { 700 - const void *dma_window; 700 + const __be32 *dma_window; 701 701 unsigned long index; 702 702 703 703 /* Use ibm,dma-window if available, else, hard code ! */
+4 -4
arch/powerpc/platforms/pseries/iommu.c
··· 530 530 static void iommu_table_setparms_lpar(struct pci_controller *phb, 531 531 struct device_node *dn, 532 532 struct iommu_table *tbl, 533 - const void *dma_window) 533 + const __be32 *dma_window) 534 534 { 535 535 unsigned long offset, size; 536 536 ··· 630 630 struct iommu_table *tbl; 631 631 struct device_node *dn, *pdn; 632 632 struct pci_dn *ppci; 633 - const void *dma_window = NULL; 633 + const __be32 *dma_window = NULL; 634 634 635 635 dn = pci_bus_to_OF_node(bus); 636 636 ··· 1152 1152 { 1153 1153 struct device_node *pdn, *dn; 1154 1154 struct iommu_table *tbl; 1155 - const void *dma_window = NULL; 1155 + const __be32 *dma_window = NULL; 1156 1156 struct pci_dn *pci; 1157 1157 1158 1158 pr_debug("pci_dma_dev_setup_pSeriesLP: %s\n", pci_name(dev)); ··· 1201 1201 bool ddw_enabled = false; 1202 1202 struct device_node *pdn, *dn; 1203 1203 struct pci_dev *pdev; 1204 - const void *dma_window = NULL; 1204 + const __be32 *dma_window = NULL; 1205 1205 u64 dma_offset; 1206 1206 1207 1207 if (!dev->dma_mask)