soc: brcmstb: Do not leak OF node reference
PATCH 1/3 soc: brcmstb: Do not leak OF node reference
From: Thierry Reding <[email protected]>
The reference to the OF node should be dropped when no longer needed.
Signed-off-by Thierry Reding <[email protected]>
--- drivers/soc/bcm/brcmstb/common.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/soc/bcm/brcmstb/common.c +11 -3
@@ -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 ;
Signature · 1 line
2.15.1
PATCH 2/3 soc: brcmstb: Do not fail initcalls on non-STB platforms
From: Thierry Reding <[email protected]>
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 <[email protected]>
--- drivers/soc/bcm/brcmstb/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/bcm/brcmstb/common.c +2 -2
@@ -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);
Signature · 1 line
2.15.1
PATCH 3/3 soc: brcmstb: Avoid error messages on non-STB platforms
In reply to Thierry RedingFrom: Thierry Reding <[email protected]>
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 <[email protected]>
--- drivers/soc/bcm/brcmstb/biuctrl.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)
drivers/soc/bcm/brcmstb/biuctrl.c +13 -16
@@ -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) {
Signature · 1 line
2.15.1