diff options
Diffstat (limited to 'drivers/of/address.c')
-rw-r--r-- | drivers/of/address.c | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/drivers/of/address.c b/drivers/of/address.c index 5c0663066a7f..f0f8f0dd191c 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -16,25 +16,12 @@ #include <linux/string.h> #include <linux/dma-direct.h> /* for bus_dma_region */ -#include "of_private.h" +#include <kunit/visibility.h> -/* Max address size we deal with */ -#define OF_MAX_ADDR_CELLS 4 -#define OF_CHECK_ADDR_COUNT(na) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS) -#define OF_CHECK_COUNTS(na, ns) (OF_CHECK_ADDR_COUNT(na) && (ns) > 0) +/* Uncomment me to enable of_dump_addr() debugging output */ +// #define DEBUG -/* Debug utility */ -#ifdef DEBUG -static void of_dump_addr(const char *s, const __be32 *addr, int na) -{ - pr_debug("%s", s); - while (na--) - pr_cont(" %08x", be32_to_cpu(*(addr++))); - pr_cont("\n"); -} -#else -static void of_dump_addr(const char *s, const __be32 *addr, int na) { } -#endif +#include "of_private.h" /* Callbacks for bus specific translators */ struct of_bus { @@ -198,7 +185,7 @@ static u64 of_bus_pci_map(__be32 *addr, const __be32 *range, int na, int ns, #endif /* CONFIG_PCI */ -static int __of_address_resource_bounds(struct resource *r, u64 start, u64 size) +VISIBLE_IF_KUNIT int __of_address_resource_bounds(struct resource *r, u64 start, u64 size) { if (overflows_type(start, r->start)) return -EOVERFLOW; @@ -212,6 +199,7 @@ static int __of_address_resource_bounds(struct resource *r, u64 start, u64 size) return 0; } +EXPORT_SYMBOL_IF_KUNIT(__of_address_resource_bounds); /* * of_pci_range_to_resource - Create a resource from an of_pci_range @@ -826,6 +814,8 @@ struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser, else range->cpu_addr = of_translate_address(parser->node, parser->range + na); + + range->parent_bus_addr = of_read_number(parser->range + na, parser->pna); range->size = of_read_number(parser->range + parser->pna + na, ns); parser->range += np; @@ -1041,20 +1031,15 @@ EXPORT_SYMBOL_GPL(of_dma_is_coherent); * * Returns true if the "nonposted-mmio" property was found for * the device's bus. - * - * This is currently only enabled on builds that support Apple ARM devices, as - * an optimization. */ static bool of_mmio_is_nonposted(const struct device_node *np) { - if (!IS_ENABLED(CONFIG_ARCH_APPLE)) - return false; - struct device_node *parent __free(device_node) = of_get_parent(np); - if (!parent) - return false; - return of_property_read_bool(parent, "nonposted-mmio"); + if (of_property_read_bool(np, "nonposted-mmio")) + return true; + + return parent && of_property_read_bool(parent, "nonposted-mmio"); } static int __of_address_to_resource(struct device_node *dev, int index, int bar_no, |