diff mbox series

[01/16] soc: imx: gpcv2: move to more ideomatic error handling in probe

Message ID 20210429073050.21039-2-peng.fan@oss.nxp.com
State Superseded
Headers show
Series soc: imx: gpcv2: support i.MX8MM | expand

Commit Message

Peng Fan (OSS) April 29, 2021, 7:30 a.m. UTC
From: Lucas Stach <l.stach@pengutronix.de>

Switch to "goto out..." error handling in domain driver probe to
avoid repeating all the error paths.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Marek Vasut <marex@denx.de>
Tested-by: Adam Ford <aford173@gmail.com>
---
 drivers/soc/imx/gpcv2.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Frieder Schrempf May 3, 2021, 1:26 p.m. UTC | #1
On 29.04.21 09:30, Peng Fan (OSS) wrote:
> From: Lucas Stach <l.stach@pengutronix.de>

> 

> Switch to "goto out..." error handling in domain driver probe to

> avoid repeating all the error paths.

> 

> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

> Reviewed-by: Marek Vasut <marex@denx.de>

> Tested-by: Adam Ford <aford173@gmail.com>


Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>


> ---

>   drivers/soc/imx/gpcv2.c | 13 +++++++++----

>   1 file changed, 9 insertions(+), 4 deletions(-)

> 

> diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c

> index db7e7fc321b1..512e6f4acafd 100644

> --- a/drivers/soc/imx/gpcv2.c

> +++ b/drivers/soc/imx/gpcv2.c

> @@ -502,18 +502,23 @@ static int imx_pgc_domain_probe(struct platform_device *pdev)

>   	ret = pm_genpd_init(&domain->genpd, NULL, true);

>   	if (ret) {

>   		dev_err(domain->dev, "Failed to init power domain\n");

> -		imx_pgc_put_clocks(domain);

> -		return ret;

> +		goto out_put_clocks;

>   	}

>   

>   	ret = of_genpd_add_provider_simple(domain->dev->of_node,

>   					   &domain->genpd);

>   	if (ret) {

>   		dev_err(domain->dev, "Failed to add genpd provider\n");

> -		pm_genpd_remove(&domain->genpd);

> -		imx_pgc_put_clocks(domain);

> +		goto out_genpd_remove;

>   	}

>   

> +	return 0;

> +

> +out_genpd_remove:

> +	pm_genpd_remove(&domain->genpd);

> +out_put_clocks:

> +	imx_pgc_put_clocks(domain);

> +

>   	return ret;

>   }

>   

>
diff mbox series

Patch

diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
index db7e7fc321b1..512e6f4acafd 100644
--- a/drivers/soc/imx/gpcv2.c
+++ b/drivers/soc/imx/gpcv2.c
@@ -502,18 +502,23 @@  static int imx_pgc_domain_probe(struct platform_device *pdev)
 	ret = pm_genpd_init(&domain->genpd, NULL, true);
 	if (ret) {
 		dev_err(domain->dev, "Failed to init power domain\n");
-		imx_pgc_put_clocks(domain);
-		return ret;
+		goto out_put_clocks;
 	}
 
 	ret = of_genpd_add_provider_simple(domain->dev->of_node,
 					   &domain->genpd);
 	if (ret) {
 		dev_err(domain->dev, "Failed to add genpd provider\n");
-		pm_genpd_remove(&domain->genpd);
-		imx_pgc_put_clocks(domain);
+		goto out_genpd_remove;
 	}
 
+	return 0;
+
+out_genpd_remove:
+	pm_genpd_remove(&domain->genpd);
+out_put_clocks:
+	imx_pgc_put_clocks(domain);
+
 	return ret;
 }