efivars: Refactor sanity checking code into separate function
[linux/fpc-iii.git] / arch / powerpc / kernel / prom_parse.c
blob6295e646f78cca6a204d4becdb2ec7d8ccdfde40
1 #undef DEBUG
3 #include <linux/kernel.h>
4 #include <linux/string.h>
5 #include <linux/ioport.h>
6 #include <linux/etherdevice.h>
7 #include <linux/of_address.h>
8 #include <asm/prom.h>
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)
14 u32 cells;
15 const __be32 *prop;
17 /* busno is always one cell */
18 *busno = of_read_number(dma_window, 1);
19 dma_window++;
21 prop = of_get_property(dn, "ibm,#dma-address-cells", NULL);
22 if (!prop)
23 prop = of_get_property(dn, "#address-cells", NULL);
25 cells = prop ? of_read_number(prop, 1) : of_n_addr_cells(dn);
26 *phys = of_read_number(dma_window, cells);
28 dma_window += cells;
30 prop = of_get_property(dn, "ibm,#dma-size-cells", NULL);
31 cells = prop ? of_read_number(prop, 1) : of_n_size_cells(dn);
32 *size = of_read_number(dma_window, cells);