diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-08 00:43:33 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-08 00:43:33 +0300 |
commit | 74fee4e88fd196c712abfdae89acfa272abf10f8 (patch) | |
tree | 942a2668830b36f5cf9bc9f2c77948f8b04c2742 /drivers/of/of_pci.c | |
parent | 7d955656121f547ff9a708ed7ee4c86a08bf628a (diff) | |
parent | 84024468cf1612783e6ab317da5b72fa41487ac6 (diff) | |
download | linux-74fee4e88fd196c712abfdae89acfa272abf10f8.tar.xz |
Merge tag 'devicetree-for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
Pull DeviceTree updates from Rob Herring:
"There's a few orphans in the conversion to %pOF printf specifiers
included here that no one else picked up.
Summary:
- Convert more DT code to use of_property_read_* API.
- Improve DT overlay support when adding multiple overlays
- Convert printk's to %pOF format specifiers. Most went via subsystem
trees, but picked up the remaining orphans
- Correct unittests to use preferred "okay" for "status" property
value
- Add a KASLR seed property
- Vendor prefixes for Mellanox, Theobroma System, Adaptrum, Moxa
- Fix modalias buffer handling
- Clean-up of include paths for building dtbs
- Add bindings for amc6821, isl1208, tsl2x7x, srf02, and srf10
devices
- Add nvmem bindings for MediaTek MT7623 and MT7622 SoC
- Add compatible string for Allwinner H5 Mali-450 GPU
- Fix links to old OpenFirmware docs with new mirror on
devicetree.org
- Remove status property from binding doc examples"
* tag 'devicetree-for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (45 commits)
devicetree: Adjust status "ok" -> "okay" under drivers/of/
dt-bindings: Remove "status" from examples
dt-bindings: pinctrl: sh-pfc: Use generic node name
dt-bindings: Add vendor Mellanox
dt-binding: net/phy: fix interrupts description
virt: Convert to using %pOF instead of full_name
macintosh: Convert to using %pOF instead of full_name
ide: pmac: Convert to using %pOF instead of full_name
microblaze: Convert to using %pOF instead of full_name
dt-bindings: usb: musb: Grammar s/the/to/, s/is/are/
of: Use PLATFORM_DEVID_NONE definition
of/device: Fix of_device_get_modalias() buffer handling
of/device: Prevent buffer overflow in of_device_modalias()
dt-bindings: add amc6821, isl1208 trivial bindings
dt-bindings: add vendor prefix for Theobroma Systems
of: search scripts/dtc/include-prefixes path for both CPP and DTC
of: remove arch/$(SRCARCH)/boot/dts from include search path for CPP
of: remove drivers/of/testcase-data from include search path for CPP
of: return of_get_cpu_node from of_cpu_device_node_get if CPUs are not registered
iio: srf08: add device tree binding for srf02 and srf10
...
Diffstat (limited to 'drivers/of/of_pci.c')
-rw-r--r-- | drivers/of/of_pci.c | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index c9d4d3a7b0fe..e9ec931f5b9a 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c @@ -57,15 +57,14 @@ EXPORT_SYMBOL_GPL(of_pci_find_child_device); */ int of_pci_get_devfn(struct device_node *np) { - unsigned int size; - const __be32 *reg; + u32 reg[5]; + int error; - reg = of_get_property(np, "reg", &size); + error = of_property_read_u32_array(np, "reg", reg, ARRAY_SIZE(reg)); + if (error) + return error; - if (!reg || size < 5 * sizeof(__be32)) - return -EINVAL; - - return (be32_to_cpup(reg) >> 8) & 0xff; + return (reg[0] >> 8) & 0xff; } EXPORT_SYMBOL_GPL(of_pci_get_devfn); @@ -78,16 +77,17 @@ EXPORT_SYMBOL_GPL(of_pci_get_devfn); */ int of_pci_parse_bus_range(struct device_node *node, struct resource *res) { - const __be32 *values; - int len; + u32 bus_range[2]; + int error; - values = of_get_property(node, "bus-range", &len); - if (!values || len < sizeof(*values) * 2) - return -EINVAL; + error = of_property_read_u32_array(node, "bus-range", bus_range, + ARRAY_SIZE(bus_range)); + if (error) + return error; res->name = node->name; - res->start = be32_to_cpup(values++); - res->end = be32_to_cpup(values); + res->start = bus_range[0]; + res->end = bus_range[1]; res->flags = IORESOURCE_BUS; return 0; @@ -105,17 +105,14 @@ EXPORT_SYMBOL_GPL(of_pci_parse_bus_range); */ int of_get_pci_domain_nr(struct device_node *node) { - const __be32 *value; - int len; - u16 domain; - - value = of_get_property(node, "linux,pci-domain", &len); - if (!value || len < sizeof(*value)) - return -EINVAL; + u32 domain; + int error; - domain = (u16)be32_to_cpup(value); + error = of_property_read_u32(node, "linux,pci-domain", &domain); + if (error) + return error; - return domain; + return (u16)domain; } EXPORT_SYMBOL_GPL(of_get_pci_domain_nr); @@ -204,15 +201,15 @@ int of_pci_get_host_bridge_resources(struct device_node *dev, if (!bus_range) return -ENOMEM; - pr_info("host bridge %s ranges:\n", dev->full_name); + pr_info("host bridge %pOF ranges:\n", dev); err = of_pci_parse_bus_range(dev, bus_range); if (err) { bus_range->start = busno; bus_range->end = bus_max; bus_range->flags = IORESOURCE_BUS; - pr_info(" No bus range found for %s, using %pR\n", - dev->full_name, bus_range); + pr_info(" No bus range found for %pOF, using %pR\n", + dev, bus_range); } else { if (bus_range->end > bus_range->start + bus_max) bus_range->end = bus_range->start + bus_max; @@ -258,14 +255,14 @@ int of_pci_get_host_bridge_resources(struct device_node *dev, if (resource_type(res) == IORESOURCE_IO) { if (!io_base) { - pr_err("I/O range found for %s. Please provide an io_base pointer to save CPU base address\n", - dev->full_name); + pr_err("I/O range found for %pOF. Please provide an io_base pointer to save CPU base address\n", + dev); err = -EINVAL; goto conversion_failed; } if (*io_base != (resource_size_t)OF_BAD_ADDR) - pr_warn("More than one I/O resource converted for %s. CPU base address for old range lost!\n", - dev->full_name); + pr_warn("More than one I/O resource converted for %pOF. CPU base address for old range lost!\n", + dev); *io_base = range.cpu_addr; } @@ -325,7 +322,7 @@ int of_pci_map_rid(struct device_node *np, u32 rid, } if (!map_len || map_len % (4 * sizeof(*map))) { - pr_err("%s: Error: Bad %s length: %d\n", np->full_name, + pr_err("%pOF: Error: Bad %s length: %d\n", np, map_name, map_len); return -EINVAL; } @@ -349,8 +346,8 @@ int of_pci_map_rid(struct device_node *np, u32 rid, u32 rid_len = be32_to_cpup(map + 3); if (rid_base & ~map_mask) { - pr_err("%s: Invalid %s translation - %s-mask (0x%x) ignores rid-base (0x%x)\n", - np->full_name, map_name, map_name, + pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores rid-base (0x%x)\n", + np, map_name, map_name, map_mask, rid_base); return -EFAULT; } @@ -375,14 +372,13 @@ int of_pci_map_rid(struct device_node *np, u32 rid, if (id_out) *id_out = masked_rid - rid_base + out_base; - pr_debug("%s: %s, using mask %08x, rid-base: %08x, out-base: %08x, length: %08x, rid: %08x -> %08x\n", - np->full_name, map_name, map_mask, rid_base, out_base, + pr_debug("%pOF: %s, using mask %08x, rid-base: %08x, out-base: %08x, length: %08x, rid: %08x -> %08x\n", + np, map_name, map_mask, rid_base, out_base, rid_len, rid, *id_out); return 0; } - pr_err("%s: Invalid %s translation - no match for rid 0x%x on %s\n", - np->full_name, map_name, rid, - target && *target ? (*target)->full_name : "any target"); + pr_err("%pOF: Invalid %s translation - no match for rid 0x%x on %pOF\n", + np, map_name, rid, target && *target ? *target : NULL); return -EFAULT; } |