* [PATCH 1/3] soc: brcmstb: Do not leak OF node reference @ 2018-01-12 13:38 ` Thierry Reding 0 siblings, 0 replies; 6+ messages in thread From: Thierry Reding @ 2018-01-12 13:38 UTC (permalink / raw) To: linux-arm-kernel From: Thierry Reding <treding@nvidia.com> The reference to the OF node should be dropped when no longer needed. Signed-off-by: Thierry Reding <treding@nvidia.com> --- drivers/soc/bcm/brcmstb/common.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c index 4fe1cb73b39a..816a0f55a9ea 100644 --- a/drivers/soc/bcm/brcmstb/common.c +++ b/drivers/soc/bcm/brcmstb/common.c @@ -70,19 +70,25 @@ static int __init brcmstb_soc_device_early_init(void) { struct device_node *sun_top_ctrl; void __iomem *sun_top_ctrl_base; + int err = 0; sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match); if (!sun_top_ctrl) return -ENODEV; sun_top_ctrl_base = of_iomap(sun_top_ctrl, 0); - if (!sun_top_ctrl_base) - return -ENODEV; + if (!sun_top_ctrl_base) { + err = -ENODEV; + goto put_node; + } family_id = readl(sun_top_ctrl_base); product_id = readl(sun_top_ctrl_base + 0x4); iounmap(sun_top_ctrl_base); - return 0; + +put_node: + of_node_put(sun_top_ctrl); + return err; } early_initcall(brcmstb_soc_device_early_init); @@ -96,6 +102,8 @@ static int __init brcmstb_soc_device_init(void) if (!sun_top_ctrl) return -ENODEV; + of_node_put(sun_top_ctrl); + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); if (!soc_dev_attr) return -ENOMEM; -- 2.15.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/3] soc: brcmstb: Do not leak OF node reference @ 2018-01-12 13:38 ` Thierry Reding 0 siblings, 0 replies; 6+ messages in thread From: Thierry Reding @ 2018-01-12 13:38 UTC (permalink / raw) To: Brian Norris, Gregory Fong, Florian Fainelli Cc: Sudeep Holla, arm, bcm-kernel-feedback-list, linux-arm-kernel, linux-kernel From: Thierry Reding <treding@nvidia.com> The reference to the OF node should be dropped when no longer needed. Signed-off-by: Thierry Reding <treding@nvidia.com> --- drivers/soc/bcm/brcmstb/common.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c index 4fe1cb73b39a..816a0f55a9ea 100644 --- a/drivers/soc/bcm/brcmstb/common.c +++ b/drivers/soc/bcm/brcmstb/common.c @@ -70,19 +70,25 @@ static int __init brcmstb_soc_device_early_init(void) { struct device_node *sun_top_ctrl; void __iomem *sun_top_ctrl_base; + int err = 0; sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match); if (!sun_top_ctrl) return -ENODEV; sun_top_ctrl_base = of_iomap(sun_top_ctrl, 0); - if (!sun_top_ctrl_base) - return -ENODEV; + if (!sun_top_ctrl_base) { + err = -ENODEV; + goto put_node; + } family_id = readl(sun_top_ctrl_base); product_id = readl(sun_top_ctrl_base + 0x4); iounmap(sun_top_ctrl_base); - return 0; + +put_node: + of_node_put(sun_top_ctrl); + return err; } early_initcall(brcmstb_soc_device_early_init); @@ -96,6 +102,8 @@ static int __init brcmstb_soc_device_init(void) if (!sun_top_ctrl) return -ENODEV; + of_node_put(sun_top_ctrl); + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); if (!soc_dev_attr) return -ENOMEM; -- 2.15.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] soc: brcmstb: Do not fail initcalls on non-STB platforms 2018-01-12 13:38 ` Thierry Reding @ 2018-01-12 13:38 ` Thierry Reding -1 siblings, 0 replies; 6+ messages in thread From: Thierry Reding @ 2018-01-12 13:38 UTC (permalink / raw) To: linux-arm-kernel From: Thierry Reding <treding@nvidia.com> If the early initcalls are run on non-STB platforms, abort early with a return value of 0. This avoids getting this expected behaviour flagged as a failure. Signed-off-by: Thierry Reding <treding@nvidia.com> --- drivers/soc/bcm/brcmstb/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c index 816a0f55a9ea..32478628bcb3 100644 --- a/drivers/soc/bcm/brcmstb/common.c +++ b/drivers/soc/bcm/brcmstb/common.c @@ -74,7 +74,7 @@ static int __init brcmstb_soc_device_early_init(void) sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match); if (!sun_top_ctrl) - return -ENODEV; + return 0; sun_top_ctrl_base = of_iomap(sun_top_ctrl, 0); if (!sun_top_ctrl_base) { @@ -100,7 +100,7 @@ static int __init brcmstb_soc_device_init(void) sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match); if (!sun_top_ctrl) - return -ENODEV; + return 0; of_node_put(sun_top_ctrl); -- 2.15.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] soc: brcmstb: Do not fail initcalls on non-STB platforms @ 2018-01-12 13:38 ` Thierry Reding 0 siblings, 0 replies; 6+ messages in thread From: Thierry Reding @ 2018-01-12 13:38 UTC (permalink / raw) To: Brian Norris, Gregory Fong, Florian Fainelli Cc: Sudeep Holla, arm, bcm-kernel-feedback-list, linux-arm-kernel, linux-kernel From: Thierry Reding <treding@nvidia.com> If the early initcalls are run on non-STB platforms, abort early with a return value of 0. This avoids getting this expected behaviour flagged as a failure. Signed-off-by: Thierry Reding <treding@nvidia.com> --- drivers/soc/bcm/brcmstb/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c index 816a0f55a9ea..32478628bcb3 100644 --- a/drivers/soc/bcm/brcmstb/common.c +++ b/drivers/soc/bcm/brcmstb/common.c @@ -74,7 +74,7 @@ static int __init brcmstb_soc_device_early_init(void) sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match); if (!sun_top_ctrl) - return -ENODEV; + return 0; sun_top_ctrl_base = of_iomap(sun_top_ctrl, 0); if (!sun_top_ctrl_base) { @@ -100,7 +100,7 @@ static int __init brcmstb_soc_device_init(void) sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match); if (!sun_top_ctrl) - return -ENODEV; + return 0; of_node_put(sun_top_ctrl); -- 2.15.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] soc: brcmstb: Avoid error messages on non-STB platforms 2018-01-12 13:38 ` Thierry Reding @ 2018-01-12 13:38 ` Thierry Reding -1 siblings, 0 replies; 6+ messages in thread From: Thierry Reding @ 2018-01-12 13:38 UTC (permalink / raw) To: linux-arm-kernel From: Thierry Reding <treding@nvidia.com> Move the check for STB platforms up into the early initcall so that the code can abort early (and without an error) if it runs on non-STB platforms. Signed-off-by: Thierry Reding <treding@nvidia.com> --- drivers/soc/bcm/brcmstb/biuctrl.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/soc/bcm/brcmstb/biuctrl.c b/drivers/soc/bcm/brcmstb/biuctrl.c index 2b23ae7b5e9b..1044cc6c3ffc 100644 --- a/drivers/soc/bcm/brcmstb/biuctrl.c +++ b/drivers/soc/bcm/brcmstb/biuctrl.c @@ -162,22 +162,15 @@ static void __init mcp_b53_set(void) cbc_writel(reg, CPU_WRITEBACK_CTRL_REG); } -static int __init setup_hifcpubiuctrl_regs(void) +static int __init setup_hifcpubiuctrl_regs(struct device_node *np) { - struct device_node *np, *cpu_dn; + struct device_node *cpu_dn; int ret = 0; - np = of_find_compatible_node(NULL, NULL, "brcm,brcmstb-cpu-biu-ctrl"); - if (!np) { - pr_err("missing BIU control node\n"); - return -ENODEV; - } - cpubiuctrl_base = of_iomap(np, 0); if (!cpubiuctrl_base) { pr_err("failed to remap BIU control base\n"); - ret = -ENOMEM; - goto out; + return -ENOMEM; } mcp_wr_pairing_en = of_property_read_bool(np, "brcm,write-pairing"); @@ -185,8 +178,7 @@ static int __init setup_hifcpubiuctrl_regs(void) cpu_dn = of_get_cpu_node(0, NULL); if (!cpu_dn) { pr_err("failed to obtain CPU device node\n"); - ret = -ENODEV; - goto out; + return -ENODEV; } if (of_device_is_compatible(cpu_dn, "brcm,brahma-b15")) @@ -201,9 +193,8 @@ static int __init setup_hifcpubiuctrl_regs(void) if (BRCM_ID(brcmstb_get_family_id()) == 0x7260) cpubiuctrl_regs = b53_cpubiuctrl_no_wb_regs; -out: - of_node_put(np); - return ret; + + return 0; } #ifdef CONFIG_PM_SLEEP @@ -242,9 +233,15 @@ static struct syscore_ops brcmstb_cpu_credit_syscore_ops = { static int __init brcmstb_biuctrl_init(void) { + struct device_node *np; int ret; - setup_hifcpubiuctrl_regs(); + np = of_find_compatible_node(NULL, NULL, "brcm,brcmstb-cpu-biu-ctrl"); + if (!np) + return 0; + + setup_hifcpubiuctrl_regs(np); + of_node_put(np); ret = mcp_write_pairing_set(); if (ret) { -- 2.15.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] soc: brcmstb: Avoid error messages on non-STB platforms @ 2018-01-12 13:38 ` Thierry Reding 0 siblings, 0 replies; 6+ messages in thread From: Thierry Reding @ 2018-01-12 13:38 UTC (permalink / raw) To: Brian Norris, Gregory Fong, Florian Fainelli Cc: Sudeep Holla, arm, bcm-kernel-feedback-list, linux-arm-kernel, linux-kernel From: Thierry Reding <treding@nvidia.com> Move the check for STB platforms up into the early initcall so that the code can abort early (and without an error) if it runs on non-STB platforms. Signed-off-by: Thierry Reding <treding@nvidia.com> --- drivers/soc/bcm/brcmstb/biuctrl.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/soc/bcm/brcmstb/biuctrl.c b/drivers/soc/bcm/brcmstb/biuctrl.c index 2b23ae7b5e9b..1044cc6c3ffc 100644 --- a/drivers/soc/bcm/brcmstb/biuctrl.c +++ b/drivers/soc/bcm/brcmstb/biuctrl.c @@ -162,22 +162,15 @@ static void __init mcp_b53_set(void) cbc_writel(reg, CPU_WRITEBACK_CTRL_REG); } -static int __init setup_hifcpubiuctrl_regs(void) +static int __init setup_hifcpubiuctrl_regs(struct device_node *np) { - struct device_node *np, *cpu_dn; + struct device_node *cpu_dn; int ret = 0; - np = of_find_compatible_node(NULL, NULL, "brcm,brcmstb-cpu-biu-ctrl"); - if (!np) { - pr_err("missing BIU control node\n"); - return -ENODEV; - } - cpubiuctrl_base = of_iomap(np, 0); if (!cpubiuctrl_base) { pr_err("failed to remap BIU control base\n"); - ret = -ENOMEM; - goto out; + return -ENOMEM; } mcp_wr_pairing_en = of_property_read_bool(np, "brcm,write-pairing"); @@ -185,8 +178,7 @@ static int __init setup_hifcpubiuctrl_regs(void) cpu_dn = of_get_cpu_node(0, NULL); if (!cpu_dn) { pr_err("failed to obtain CPU device node\n"); - ret = -ENODEV; - goto out; + return -ENODEV; } if (of_device_is_compatible(cpu_dn, "brcm,brahma-b15")) @@ -201,9 +193,8 @@ static int __init setup_hifcpubiuctrl_regs(void) if (BRCM_ID(brcmstb_get_family_id()) == 0x7260) cpubiuctrl_regs = b53_cpubiuctrl_no_wb_regs; -out: - of_node_put(np); - return ret; + + return 0; } #ifdef CONFIG_PM_SLEEP @@ -242,9 +233,15 @@ static struct syscore_ops brcmstb_cpu_credit_syscore_ops = { static int __init brcmstb_biuctrl_init(void) { + struct device_node *np; int ret; - setup_hifcpubiuctrl_regs(); + np = of_find_compatible_node(NULL, NULL, "brcm,brcmstb-cpu-biu-ctrl"); + if (!np) + return 0; + + setup_hifcpubiuctrl_regs(np); + of_node_put(np); ret = mcp_write_pairing_set(); if (ret) { -- 2.15.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-01-12 13:38 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-01-12 13:38 [PATCH 1/3] soc: brcmstb: Do not leak OF node reference Thierry Reding 2018-01-12 13:38 ` Thierry Reding 2018-01-12 13:38 ` [PATCH 2/3] soc: brcmstb: Do not fail initcalls on non-STB platforms Thierry Reding 2018-01-12 13:38 ` Thierry Reding 2018-01-12 13:38 ` [PATCH 3/3] soc: brcmstb: Avoid error messages " Thierry Reding 2018-01-12 13:38 ` Thierry Reding
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.