From 58fb82ccbccca25fd46775731283eb451fc165ba Mon Sep 17 00:00:00 2001 From: Ding Xiang Date: Mon, 30 Mar 2020 18:05:02 +0800 Subject: of: of_detach_node() remove unneeded local return variable rc is unneeded, just return 0. Signed-off-by: Ding Xiang Signed-off-by: Rob Herring --- drivers/of/dynamic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 08fd823edac9..fe64430b438a 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -286,7 +286,6 @@ int of_detach_node(struct device_node *np) { struct of_reconfig_data rd; unsigned long flags; - int rc = 0; memset(&rd, 0, sizeof(rd)); rd.dn = np; @@ -301,7 +300,7 @@ int of_detach_node(struct device_node *np) of_reconfig_notify(OF_RECONFIG_DETACH_NODE, &rd); - return rc; + return 0; } EXPORT_SYMBOL_GPL(of_detach_node); -- cgit v1.2.3 From 78056e701c61132d15e0942e415926a6393fcf17 Mon Sep 17 00:00:00 2001 From: Saravana Kannan Date: Wed, 1 Apr 2020 15:52:03 -0700 Subject: of: property: Add device link support for extcon Add support for creating device links out of more DT properties. Cc: MyungJoo Ham Cc: Chanwoo Choi Signed-off-by: Saravana Kannan Signed-off-by: Rob Herring --- drivers/of/property.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/of') diff --git a/drivers/of/property.c b/drivers/of/property.c index b4916dcc9e72..252e4f600155 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1206,6 +1206,7 @@ DEFINE_SIMPLE_PROP(interrupt_parent, "interrupt-parent", NULL) DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells") DEFINE_SIMPLE_PROP(power_domains, "power-domains", "#power-domain-cells") DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells") +DEFINE_SIMPLE_PROP(extcon, "extcon", NULL) DEFINE_SUFFIX_PROP(regulators, "-supply", NULL) DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells") DEFINE_SUFFIX_PROP(gpios, "-gpios", "#gpio-cells") @@ -1230,6 +1231,7 @@ static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_dmas, }, { .parse_prop = parse_power_domains, }, { .parse_prop = parse_hwlocks, }, + { .parse_prop = parse_extcon, }, { .parse_prop = parse_regulators, }, { .parse_prop = parse_gpio, }, { .parse_prop = parse_gpios, }, -- cgit v1.2.3 From 8d3cdfeca808f2b2dee11dda4282770c4b579b48 Mon Sep 17 00:00:00 2001 From: tangjianqiang Date: Fri, 10 Apr 2020 16:32:04 +0800 Subject: of: fix the warnings from command line. Gerrit will complain with this warnings: ERROR: (foo*) should be (foo *) Signed-off-by: tangjianqiang Reviewed-by: Frank Rowand Signed-off-by: Rob Herring --- drivers/of/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/of') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 2cdf64d2456f..8a8e07a8f03d 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1078,7 +1078,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, #endif #endif /* CONFIG_CMDLINE */ - pr_debug("Command line is: %s\n", (char*)data); + pr_debug("Command line is: %s\n", (char *)data); rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l); if (rng_seed && l > 0) { -- cgit v1.2.3 From 8f88fad370bb0884f7f7217dea254b202df44716 Mon Sep 17 00:00:00 2001 From: Saravana Kannan Date: Thu, 16 Apr 2020 13:58:38 -0700 Subject: of: property: Don't retry device_link_add() upon failure When of_link_to_phandle() was implemented initially, there was no way to tell if device_link_add() was failing because the supplier device hasn't been parsed yet, hasn't been added yet, the links were creating a cycle, etc. Some of these were transient errors that'd go away at a later point. However, with the current set of improved checks, if device_link_add() fails, it'll only be for permanent errors like cycles or out-of-memory errors. Also, with the addition of DL_FLAG_SYNC_STATE_ONLY flag [1] to device links, all the valid dependency cycles due to "proxy" device links (needed for correctness of sync_state() device callback) will never fail device_link_add() due to cycles. So, continuing to retry failing device links (by returning -EAGAIN) is no longer useful. At worst, it prevents platforms from setting fw_devlink=on (or better) because it prevents proper boot up. So, let's not do that anymore. [1] - https://lore.kernel.org/lkml/20191028220027.251605-1-saravanak@google.com/ Cc: Nicolas Saenz Julienne Cc: Greg Kroah-Hartman Signed-off-by: Saravana Kannan Tested-by: Nicolas Saenz Julienne Signed-off-by: Rob Herring --- drivers/of/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/of') diff --git a/drivers/of/property.c b/drivers/of/property.c index 252e4f600155..ee1bc267f975 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1074,7 +1074,7 @@ static int of_link_to_phandle(struct device *dev, struct device_node *sup_np, return -EAGAIN; } if (!device_link_add(dev, sup_dev, dl_flags)) - ret = -EAGAIN; + ret = -EINVAL; put_device(sup_dev); return ret; } -- cgit v1.2.3 From ed3655729182a59b9bef1b564c6fc2dcbbbe954e Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 20 Apr 2020 14:01:01 +0200 Subject: of: property: Fix create device links for all child-supplier dependencies Upon adding a new device from a DT node, we scan its properties and its children's properties in order to create a consumer/supplier relationship between the device and the property provider. That said, it's possible for some of the node's children to be disabled, which will create links that'll never be fulfilled. To get around this, use the for_each_available_child_of_node() function instead of for_each_available_node() when iterating over the node's children. Fixes: d4387cd11741 ("of: property: Create device links for all child-supplier depencencies") Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Saravana Kannan Signed-off-by: Rob Herring --- drivers/of/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/of') diff --git a/drivers/of/property.c b/drivers/of/property.c index ee1bc267f975..9674b3cf500d 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1298,7 +1298,7 @@ static int of_link_to_suppliers(struct device *dev, if (of_link_property(dev, con_np, p->name)) ret = -ENODEV; - for_each_child_of_node(con_np, child) + for_each_available_child_of_node(con_np, child) if (of_link_to_suppliers(dev, child) && !ret) ret = -EAGAIN; -- cgit v1.2.3 From 7456427af9def0fec5508dd8b861556038ee96a8 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 20 Apr 2020 14:01:02 +0200 Subject: of: property: Do not link to disabled devices When creating a consumer/supplier relationship between two devices, make sure the supplier node is actually active. Otherwise this will create a link relationship that will never be fulfilled. This, in the worst case scenario, will hang the system during boot. Note that, in practice, the fact that a device-tree represented consumer/supplier relationship isn't fulfilled will not prevent devices from successfully probing. Fixes: a3e1d1a7f5fc ("of: property: Add functional dependency link from DT bindings") Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Saravana Kannan Signed-off-by: Rob Herring --- drivers/of/property.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'drivers/of') diff --git a/drivers/of/property.c b/drivers/of/property.c index 9674b3cf500d..1f2086f4e7ce 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1045,8 +1045,20 @@ static int of_link_to_phandle(struct device *dev, struct device_node *sup_np, * Find the device node that contains the supplier phandle. It may be * @sup_np or it may be an ancestor of @sup_np. */ - while (sup_np && !of_find_property(sup_np, "compatible", NULL)) + while (sup_np) { + + /* Don't allow linking to a disabled supplier */ + if (!of_device_is_available(sup_np)) { + of_node_put(sup_np); + sup_np = NULL; + } + + if (of_find_property(sup_np, "compatible", NULL)) + break; + sup_np = of_get_next_parent(sup_np); + } + if (!sup_np) { dev_dbg(dev, "Not linking to %pOFP - No device\n", tmp_np); return -ENODEV; -- cgit v1.2.3 From c8813f7ec01c676a8995c894ce49d40f5de62ed0 Mon Sep 17 00:00:00 2001 From: chenqiwu Date: Mon, 11 May 2020 23:04:57 +0800 Subject: drivers/of: keep description of function consistent with function name Currently, there are some descriptions of function not consistent with function name, fixing them will make the code more readable. Signed-off-by: chenqiwu Signed-off-by: Rob Herring --- drivers/of/fdt.c | 2 +- drivers/of/of_reserved_mem.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 8a8e07a8f03d..38619e9ef6b2 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -471,7 +471,7 @@ void *initial_boot_params __ro_after_init; static u32 of_fdt_crc32; /** - * res_mem_reserve_reg() - reserve all memory described in 'reg' property + * __reserved_mem_reserve_reg() - reserve all memory described in 'reg' property */ static int __init __reserved_mem_reserve_reg(unsigned long node, const char *uname) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 1a84bc0d5fa8..6f6fea3e96de 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -46,7 +46,7 @@ static int __init early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, } /** - * res_mem_save_node() - save fdt node for second pass initialization + * fdt_reserved_mem_save_node() - save fdt node for second pass initialization */ void __init fdt_reserved_mem_save_node(unsigned long node, const char *uname, phys_addr_t base, phys_addr_t size) @@ -68,8 +68,8 @@ void __init fdt_reserved_mem_save_node(unsigned long node, const char *uname, } /** - * res_mem_alloc_size() - allocate reserved memory described by 'size', 'align' - * and 'alloc-ranges' properties + * __reserved_mem_alloc_size() - allocate reserved memory described by + * 'size', 'align' and 'alloc-ranges' properties. */ static int __init __reserved_mem_alloc_size(unsigned long node, const char *uname, phys_addr_t *res_base, phys_addr_t *res_size) @@ -165,7 +165,7 @@ static const struct of_device_id __rmem_of_table_sentinel __used __section(__reservedmem_of_table_end); /** - * res_mem_init_node() - call region specific reserved memory init code + * __reserved_mem_init_node() - call region specific reserved memory init code */ static int __init __reserved_mem_init_node(struct reserved_mem *rmem) { @@ -232,7 +232,7 @@ static void __init __rmem_check_for_overlap(void) } /** - * fdt_init_reserved_mem - allocate and init all saved reserved memory regions + * fdt_init_reserved_mem() - allocate and init all saved reserved memory regions */ void __init fdt_init_reserved_mem(void) { -- cgit v1.2.3 From 8a325dd06f2358ea0888e4ff1c9ca4bc23bd53f3 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 20 May 2020 15:04:14 +0300 Subject: of: Fix a refcounting bug in __of_attach_node_sysfs() The problem in this code is that if kobject_add() fails, then it should call of_node_put(np) to drop the reference count. I've actually moved the of_node_get(np) later in the function to avoid needing to do clean up. Fixes: 5b2c2f5a0ea3 ("of: overlay: add missing of_node_get() in __of_attach_node_sysfs") Signed-off-by: Dan Carpenter Signed-off-by: Rob Herring --- drivers/of/kobj.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index c72eef988041..a32e60b024b8 100644 --- a/drivers/of/kobj.c +++ b/drivers/of/kobj.c @@ -134,8 +134,6 @@ int __of_attach_node_sysfs(struct device_node *np) if (!name) return -ENOMEM; - of_node_get(np); - rc = kobject_add(&np->kobj, parent, "%s", name); kfree(name); if (rc) @@ -144,6 +142,7 @@ int __of_attach_node_sysfs(struct device_node *np) for_each_property_of_node(np, pp) __of_add_property_sysfs(np, pp); + of_node_get(np); return 0; } -- cgit v1.2.3 From f9a529b9d6f15a065f2ccf5ec67180df431b0c6f Mon Sep 17 00:00:00 2001 From: Qi Zheng Date: Sun, 24 May 2020 23:26:14 +0800 Subject: dt/platform: Fix comment in of_dev_lookup() The code is using of_dev_lookup() rather than of_devname_lookup(). Signed-off-by: Qi Zheng Signed-off-by: Rob Herring --- drivers/of/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/of') diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 3371e4a06248..3627fee60215 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -291,7 +291,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node, #endif /* CONFIG_ARM_AMBA */ /** - * of_devname_lookup() - Given a device node, lookup the preferred Linux name + * of_dev_lookup() - Given a device node, lookup the preferred Linux name */ static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *lookup, struct device_node *np) -- cgit v1.2.3 From 7536c7e03e745bcc6881d0af66e747040943560a Mon Sep 17 00:00:00 2001 From: Qi Zheng Date: Thu, 28 May 2020 21:25:41 +0800 Subject: of/fdt: Remove redundant kbasename function call For version 1 to 3 of the device tree, this is the node full path as a zero terminated string, starting with "/". The following equation will not hold, since the node name has been processed in the fdt_get_name(). *pathp == '/' For version 16 and later, this is the node unit name only (or an empty string for the root node). So the above equation will still not hold. So the kbasename() is redundant, just remove it. Signed-off-by: Qi Zheng Signed-off-by: Rob Herring --- drivers/of/fdt.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/of') diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 38619e9ef6b2..4602e467ca8b 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -643,8 +643,6 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, offset = fdt_next_node(blob, offset, &depth)) { pathp = fdt_get_name(blob, offset, NULL); - if (*pathp == '/') - pathp = kbasename(pathp); rc = it(offset, pathp, depth, data); } return rc; @@ -671,8 +669,6 @@ int __init of_scan_flat_dt_subnodes(unsigned long parent, int rc; pathp = fdt_get_name(blob, node, NULL); - if (*pathp == '/') - pathp = kbasename(pathp); rc = it(node, pathp, data); if (rc) return rc; -- cgit v1.2.3