diff options
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/base.c | 68 | ||||
-rw-r--r-- | drivers/of/device.c | 25 | ||||
-rw-r--r-- | drivers/of/fdt.c | 11 | ||||
-rw-r--r-- | drivers/of/irq.c | 19 | ||||
-rw-r--r-- | drivers/of/of_mdio.c | 1 | ||||
-rw-r--r-- | drivers/of/of_pci_irq.c | 10 | ||||
-rw-r--r-- | drivers/of/of_reserved_mem.c | 4 | ||||
-rw-r--r-- | drivers/of/overlay.c | 2 | ||||
-rw-r--r-- | drivers/of/platform.c | 2 | ||||
-rw-r--r-- | drivers/of/resolver.c | 1 | ||||
-rw-r--r-- | drivers/of/unittest.c | 5 |
11 files changed, 128 insertions, 20 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index d4bea3c797d6..d7c4629a3a2d 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -25,6 +25,7 @@ #include <linux/cpu.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/of_graph.h> #include <linux/spinlock.h> #include <linux/slab.h> @@ -842,8 +843,11 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt if (!np) np = of_node_get(of_root); while (np && *path == '/') { + struct device_node *tmp = np; + path++; /* Increment past '/' delimiter */ np = __of_find_node_by_path(np, path); + of_node_put(tmp); path = strchrnul(path, '/'); if (separator && separator < path) break; @@ -2112,7 +2116,7 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) continue; /* Allocate an alias_prop with enough space for the stem */ - ap = dt_alloc(sizeof(*ap) + len + 1, 4); + ap = dt_alloc(sizeof(*ap) + len + 1, __alignof__(*ap)); if (!ap) continue; memset(ap, 0, sizeof(*ap) + len + 1); @@ -2268,6 +2272,31 @@ struct device_node *of_find_next_cache_node(const struct device_node *np) } /** + * of_find_last_cache_level - Find the level at which the last cache is + * present for the given logical cpu + * + * @cpu: cpu number(logical index) for which the last cache level is needed + * + * Returns the the level at which the last cache is present. It is exactly + * same as the total number of cache levels for the given logical cpu. + */ +int of_find_last_cache_level(unsigned int cpu) +{ + u32 cache_level = 0; + struct device_node *prev = NULL, *np = of_cpu_device_node_get(cpu); + + while (np) { + prev = np; + of_node_put(np); + np = of_find_next_cache_node(np); + } + + of_property_read_u32(prev, "cache-level", &cache_level); + + return cache_level; +} + +/** * of_graph_parse_endpoint() - parse common endpoint node properties * @node: pointer to endpoint device_node * @endpoint: pointer to the OF endpoint data structure @@ -2469,3 +2498,40 @@ struct device_node *of_graph_get_remote_port(const struct device_node *node) return of_get_next_parent(np); } EXPORT_SYMBOL(of_graph_get_remote_port); + +/** + * of_graph_get_remote_node() - get remote parent device_node for given port/endpoint + * @node: pointer to parent device_node containing graph port/endpoint + * @port: identifier (value of reg property) of the parent port node + * @endpoint: identifier (value of reg property) of the endpoint node + * + * Return: Remote device node associated with remote endpoint node linked + * to @node. Use of_node_put() on it when done. + */ +struct device_node *of_graph_get_remote_node(const struct device_node *node, + u32 port, u32 endpoint) +{ + struct device_node *endpoint_node, *remote; + + endpoint_node = of_graph_get_endpoint_by_regs(node, port, endpoint); + if (!endpoint_node) { + pr_debug("no valid endpoint (%d, %d) for node %s\n", + port, endpoint, node->full_name); + return NULL; + } + + remote = of_graph_get_remote_port_parent(endpoint_node); + of_node_put(endpoint_node); + if (!remote) { + pr_debug("no valid remote node\n"); + return NULL; + } + + if (!of_device_is_available(remote)) { + pr_debug("not available for remote node\n"); + return NULL; + } + + return remote; +} +EXPORT_SYMBOL(of_graph_get_remote_node); diff --git a/drivers/of/device.c b/drivers/of/device.c index fd5cfad7c403..b1e6bebda3f3 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -225,6 +225,30 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) return tsize; } +EXPORT_SYMBOL_GPL(of_device_get_modalias); + +int of_device_request_module(struct device *dev) +{ + char *str; + ssize_t size; + int ret; + + size = of_device_get_modalias(dev, NULL, 0); + if (size < 0) + return size; + + str = kmalloc(size + 1, GFP_KERNEL); + if (!str) + return -ENOMEM; + + of_device_get_modalias(dev, str, size); + str[size] = '\0'; + ret = request_module(str); + kfree(str); + + return ret; +} +EXPORT_SYMBOL_GPL(of_device_request_module); /** * of_device_uevent - Display OF related uevent information @@ -287,3 +311,4 @@ int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env) return 0; } +EXPORT_SYMBOL_GPL(of_device_uevent_modalias); diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index c9b5cac03b36..e5ce4b59e162 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -9,7 +9,7 @@ * version 2 as published by the Free Software Foundation. */ -#define pr_fmt(fmt) "OF: fdt:" fmt +#define pr_fmt(fmt) "OF: fdt: " fmt #include <linux/crc32.h> #include <linux/kernel.h> @@ -738,9 +738,12 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, const char *pathp; int offset, rc = 0, depth = -1; - for (offset = fdt_next_node(blob, -1, &depth); - offset >= 0 && depth >= 0 && !rc; - offset = fdt_next_node(blob, offset, &depth)) { + if (!blob) + return 0; + + for (offset = fdt_next_node(blob, -1, &depth); + offset >= 0 && depth >= 0 && !rc; + offset = fdt_next_node(blob, offset, &depth)) { pathp = fdt_get_name(blob, offset, NULL); if (*pathp == '/') diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 3fda9a32defb..7c56b72d1dc6 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -104,7 +104,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) const __be32 *match_array = initial_match_array; const __be32 *tmp, *imap, *imask, dummy_imask[] = { [0 ... MAX_PHANDLE_ARGS] = ~0 }; u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; - int imaplen, match, i; + int imaplen, match, i, rc = -EINVAL; #ifdef DEBUG of_print_phandle_args("of_irq_parse_raw: ", out_irq); @@ -134,7 +134,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) pr_debug("of_irq_parse_raw: ipar=%s, size=%d\n", of_node_full_name(ipar), intsize); if (out_irq->args_count != intsize) - return -EINVAL; + goto fail; /* Look for this #address-cells. We have to implement the old linux * trick of looking for the parent here as some device-trees rely on it @@ -153,8 +153,10 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) pr_debug(" -> addrsize=%d\n", addrsize); /* Range check so that the temporary buffer doesn't overflow */ - if (WARN_ON(addrsize + intsize > MAX_PHANDLE_ARGS)) + if (WARN_ON(addrsize + intsize > MAX_PHANDLE_ARGS)) { + rc = -EFAULT; goto fail; + } /* Precalculate the match array - this simplifies match loop */ for (i = 0; i < addrsize; i++) @@ -240,10 +242,11 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) newintsize, newaddrsize); /* Check for malformed properties */ - if (WARN_ON(newaddrsize + newintsize > MAX_PHANDLE_ARGS)) - goto fail; - if (imaplen < (newaddrsize + newintsize)) + if (WARN_ON(newaddrsize + newintsize > MAX_PHANDLE_ARGS) + || (imaplen < (newaddrsize + newintsize))) { + rc = -EFAULT; goto fail; + } imap += newaddrsize + newintsize; imaplen -= newaddrsize + newintsize; @@ -271,11 +274,13 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) ipar = newpar; newpar = NULL; } + rc = -ENOENT; /* No interrupt-map found */ + fail: of_node_put(ipar); of_node_put(newpar); - return -EINVAL; + return rc; } EXPORT_SYMBOL_GPL(of_irq_parse_raw); diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 262281bd68fa..0b2979816dbf 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -147,6 +147,7 @@ EXPORT_SYMBOL(of_mdio_parse_addr); */ static const struct of_device_id whitelist_phys[] = { { .compatible = "brcm,40nm-ephy" }, + { .compatible = "broadcom,bcm5241" }, { .compatible = "marvell,88E1111", }, { .compatible = "marvell,88e1116", }, { .compatible = "marvell,88e1118", }, diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c index 2306313c0029..c175d9cd0bb5 100644 --- a/drivers/of/of_pci_irq.c +++ b/drivers/of/of_pci_irq.c @@ -93,7 +93,15 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq goto err; return 0; err: - dev_err(&pdev->dev, "of_irq_parse_pci() failed with rc=%d\n", rc); + if (rc == -ENOENT) { + dev_warn(&pdev->dev, + "%s: no interrupt-map found, INTx interrupts not available\n", + __func__); + pr_warn_once("%s: possibly some PCI slots don't have level triggered interrupts capability\n", + __func__); + } else { + dev_err(&pdev->dev, "%s: failed with rc=%d\n", __func__, rc); + } return rc; } EXPORT_SYMBOL_GPL(of_irq_parse_pci); diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 366d8c3c7989..d507c3569a88 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -354,6 +354,10 @@ int of_reserved_mem_device_init_by_idx(struct device *dev, mutex_lock(&of_rmem_assigned_device_mutex); list_add(&rd->list, &of_rmem_assigned_device_list); mutex_unlock(&of_rmem_assigned_device_mutex); + /* ensure that dma_ops is set for virtual devices + * using reserved memory + */ + of_dma_configure(dev, np); dev_info(dev, "assigned reserved memory node %s\n", rmem->name); } else { diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 0d4cda7050e0..7827786718d8 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -18,7 +18,6 @@ #include <linux/string.h> #include <linux/ctype.h> #include <linux/errno.h> -#include <linux/string.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/idr.h> @@ -314,7 +313,6 @@ static int of_build_overlay_info(struct of_overlay *ov, cnt = 0; for_each_child_of_node(tree, node) { - memset(&ovinfo[cnt], 0, sizeof(*ovinfo)); err = of_fill_overlay_info(ov, node, &ovinfo[cnt]); if (err == 0) cnt++; diff --git a/drivers/of/platform.c b/drivers/of/platform.c index f5bbb500ab80..45b413e5a444 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -76,7 +76,7 @@ EXPORT_SYMBOL(of_find_device_by_node); * derive a unique name. If it cannot, then it will prepend names from * parent nodes until a unique name can be derived. */ -void of_device_make_bus_id(struct device *dev) +static void of_device_make_bus_id(struct device *dev) { struct device_node *node = dev->of_node; const __be32 *reg; diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index 8bf12e904fd2..7ae9863cb0a4 100644 --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c @@ -18,7 +18,6 @@ #include <linux/string.h> #include <linux/ctype.h> #include <linux/errno.h> -#include <linux/string.h> #include <linux/slab.h> /* illegal phandle value (set when unresolved) */ diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 53c83d66eb7e..62db55b97c10 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -17,7 +17,6 @@ #include <linux/slab.h> #include <linux/device.h> #include <linux/platform_device.h> -#include <linux/of_platform.h> #include <linux/i2c.h> #include <linux/i2c-mux.h> @@ -1181,7 +1180,7 @@ static void of_unittest_destroy_tracked_overlays(void) } while (defers > 0); } -static int of_unittest_apply_overlay(int unittest_nr, int overlay_nr, +static int of_unittest_apply_overlay(int overlay_nr, int unittest_nr, int *overlay_id) { struct device_node *np = NULL; @@ -1840,7 +1839,7 @@ static void of_unittest_overlay_i2c_15(void) int ret; /* device should enable */ - ret = of_unittest_apply_overlay_check(16, 15, 0, 1, I2C_OVERLAY); + ret = of_unittest_apply_overlay_check(15, 15, 0, 1, I2C_OVERLAY); if (ret != 0) return; |