linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] media: sunxi: Fix some error handling path of sun8i_a83t_mipi_csi2_probe()
@ 2022-07-31 19:22 Christophe JAILLET
  2022-07-31 19:22 ` [PATCH 2/2] media: sunxi: Fix some error handling path of sun6i_mipi_csi2_probe() Christophe JAILLET
  2022-08-05 14:10 ` [PATCH 1/2] media: sunxi: Fix some error handling path of sun8i_a83t_mipi_csi2_probe() Paul Kocialkowski
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-07-31 19:22 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, Paul Kocialkowski, Maxime Ripard, Hans Verkuil
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-media,
	linux-arm-kernel, linux-sunxi

Release some resources in the error handling path of the probe and of
sun8i_a83t_mipi_csi2_resources_setup(), as already done in the remove
function.

Fixes: 576d196c522b ("media: sunxi: Add support for the A83T MIPI CSI-2 controller")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
I'm unsure about the phy_exit() call in
sun8i_a83t_mipi_csi2_resources_cleanup() because no explicit phy_init()
call is performed.

The same code is in sun6i-mipi-csi2/sun6i_mipi_csi2.c, but in this driver
phy_init() IS called.

I leave it as-is because I don't if it is an issue or not.
My feeling is that it is a copy'n'paste error and that it should be
removed.
---
 .../sun8i_a83t_mipi_csi2.c                    | 21 ++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
index d052ee77ef0a..67c7475d5d10 100644
--- a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
+++ b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
@@ -719,13 +719,15 @@ sun8i_a83t_mipi_csi2_resources_setup(struct sun8i_a83t_mipi_csi2_device *csi2_de
 	csi2_dev->clock_mipi = devm_clk_get(dev, "mipi");
 	if (IS_ERR(csi2_dev->clock_mipi)) {
 		dev_err(dev, "failed to acquire mipi clock\n");
-		return PTR_ERR(csi2_dev->clock_mipi);
+		ret = PTR_ERR(csi2_dev->clock_mipi);
+		goto err_put_clk_rate;
 	}
 
 	csi2_dev->clock_misc = devm_clk_get(dev, "misc");
 	if (IS_ERR(csi2_dev->clock_misc)) {
 		dev_err(dev, "failed to acquire misc clock\n");
-		return PTR_ERR(csi2_dev->clock_misc);
+		ret = PTR_ERR(csi2_dev->clock_misc);
+		goto err_put_clk_rate;
 	}
 
 	/* Reset */
@@ -733,7 +735,8 @@ sun8i_a83t_mipi_csi2_resources_setup(struct sun8i_a83t_mipi_csi2_device *csi2_de
 	csi2_dev->reset = devm_reset_control_get_shared(dev, NULL);
 	if (IS_ERR(csi2_dev->reset)) {
 		dev_err(dev, "failed to get reset controller\n");
-		return PTR_ERR(csi2_dev->reset);
+		ret = PTR_ERR(csi2_dev->reset);
+		goto err_put_clk_rate;
 	}
 
 	/* D-PHY */
@@ -741,7 +744,7 @@ sun8i_a83t_mipi_csi2_resources_setup(struct sun8i_a83t_mipi_csi2_device *csi2_de
 	ret = sun8i_a83t_dphy_register(csi2_dev);
 	if (ret) {
 		dev_err(dev, "failed to initialize MIPI D-PHY\n");
-		return ret;
+		goto err_put_clk_rate;
 	}
 
 	/* Runtime PM */
@@ -749,6 +752,10 @@ sun8i_a83t_mipi_csi2_resources_setup(struct sun8i_a83t_mipi_csi2_device *csi2_de
 	pm_runtime_enable(dev);
 
 	return 0;
+
+err_put_clk_rate:
+	clk_rate_exclusive_put(csi2_dev->clock_mod);
+	return ret;
 }
 
 static void
@@ -778,9 +785,13 @@ static int sun8i_a83t_mipi_csi2_probe(struct platform_device *platform_dev)
 
 	ret = sun8i_a83t_mipi_csi2_bridge_setup(csi2_dev);
 	if (ret)
-		return ret;
+		goto err_cleanup_resources;
 
 	return 0;
+
+err_cleanup_resources:
+	sun8i_a83t_mipi_csi2_resources_cleanup(csi2_dev);
+	return ret;
 }
 
 static int sun8i_a83t_mipi_csi2_remove(struct platform_device *platform_dev)
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] media: sunxi: Fix some error handling path of sun6i_mipi_csi2_probe()
  2022-07-31 19:22 [PATCH 1/2] media: sunxi: Fix some error handling path of sun8i_a83t_mipi_csi2_probe() Christophe JAILLET
@ 2022-07-31 19:22 ` Christophe JAILLET
  2022-08-05 14:11   ` Paul Kocialkowski
  2022-08-05 14:10 ` [PATCH 1/2] media: sunxi: Fix some error handling path of sun8i_a83t_mipi_csi2_probe() Paul Kocialkowski
  1 sibling, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2022-07-31 19:22 UTC (permalink / raw)
  To: Paul Kocialkowski, Mauro Carvalho Chehab, Chen-Yu Tsai,
	Jernej Skrabec, Samuel Holland, Hans Verkuil, Maxime Ripard
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-media,
	linux-arm-kernel, linux-sunxi

Release some resources in the error handling path of the probe and of
sun6i_mipi_csi2_resources_setup(), as already done in the remove
function.

Fixes: af54b4f4c17f ("media: sunxi: Add support for the A31 MIPI CSI-2 controller")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c    | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
index a4e3f9a6b2ff..1ee8501e25f6 100644
--- a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
+++ b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
@@ -661,7 +661,8 @@ sun6i_mipi_csi2_resources_setup(struct sun6i_mipi_csi2_device *csi2_dev,
 	csi2_dev->reset = devm_reset_control_get_shared(dev, NULL);
 	if (IS_ERR(csi2_dev->reset)) {
 		dev_err(dev, "failed to get reset controller\n");
-		return PTR_ERR(csi2_dev->reset);
+		ret = PTR_ERR(csi2_dev->reset);
+		goto err_put_clk_rate;
 	}
 
 	/* D-PHY */
@@ -669,13 +670,14 @@ sun6i_mipi_csi2_resources_setup(struct sun6i_mipi_csi2_device *csi2_dev,
 	csi2_dev->dphy = devm_phy_get(dev, "dphy");
 	if (IS_ERR(csi2_dev->dphy)) {
 		dev_err(dev, "failed to get MIPI D-PHY\n");
-		return PTR_ERR(csi2_dev->dphy);
+		ret = PTR_ERR(csi2_dev->dphy);
+		goto err_put_clk_rate;
 	}
 
 	ret = phy_init(csi2_dev->dphy);
 	if (ret) {
 		dev_err(dev, "failed to initialize MIPI D-PHY\n");
-		return ret;
+		goto err_put_clk_rate;
 	}
 
 	/* Runtime PM */
@@ -683,6 +685,10 @@ sun6i_mipi_csi2_resources_setup(struct sun6i_mipi_csi2_device *csi2_dev,
 	pm_runtime_enable(dev);
 
 	return 0;
+
+err_put_clk_rate:
+	clk_rate_exclusive_put(csi2_dev->clock_mod);
+	return ret;
 }
 
 static void
@@ -712,9 +718,13 @@ static int sun6i_mipi_csi2_probe(struct platform_device *platform_dev)
 
 	ret = sun6i_mipi_csi2_bridge_setup(csi2_dev);
 	if (ret)
-		return ret;
+		goto err_cleanup_resources;
 
 	return 0;
+
+err_cleanup_resources:
+	sun6i_mipi_csi2_resources_cleanup(csi2_dev);
+	return ret;
 }
 
 static int sun6i_mipi_csi2_remove(struct platform_device *platform_dev)
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] media: sunxi: Fix some error handling path of sun8i_a83t_mipi_csi2_probe()
  2022-07-31 19:22 [PATCH 1/2] media: sunxi: Fix some error handling path of sun8i_a83t_mipi_csi2_probe() Christophe JAILLET
  2022-07-31 19:22 ` [PATCH 2/2] media: sunxi: Fix some error handling path of sun6i_mipi_csi2_probe() Christophe JAILLET
@ 2022-08-05 14:10 ` Paul Kocialkowski
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Kocialkowski @ 2022-08-05 14:10 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Mauro Carvalho Chehab, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, Maxime Ripard, Hans Verkuil, linux-kernel,
	kernel-janitors, linux-media, linux-arm-kernel, linux-sunxi


[-- Attachment #1.1: Type: text/plain, Size: 3832 bytes --]

Hi Christophe,

On Sun 31 Jul 22, 21:22, Christophe JAILLET wrote:
> Release some resources in the error handling path of the probe and of
> sun8i_a83t_mipi_csi2_resources_setup(), as already done in the remove
> function.

Great finds, thanks! Just some nitpick about the label names to make them
consistent with other labels (also from the sun6i-csi rework).
 
> Fixes: 576d196c522b ("media: sunxi: Add support for the A83T MIPI CSI-2 controller")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> I'm unsure about the phy_exit() call in
> sun8i_a83t_mipi_csi2_resources_cleanup() because no explicit phy_init()
> call is performed.
> 
> The same code is in sun6i-mipi-csi2/sun6i_mipi_csi2.c, but in this driver
> phy_init() IS called.
> 
> I leave it as-is because I don't if it is an issue or not.
> My feeling is that it is a copy'n'paste error and that it should be
> removed.
> ---
>  .../sun8i_a83t_mipi_csi2.c                    | 21 ++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
> index d052ee77ef0a..67c7475d5d10 100644
> --- a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
> +++ b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
> @@ -719,13 +719,15 @@ sun8i_a83t_mipi_csi2_resources_setup(struct sun8i_a83t_mipi_csi2_device *csi2_de
>  	csi2_dev->clock_mipi = devm_clk_get(dev, "mipi");
>  	if (IS_ERR(csi2_dev->clock_mipi)) {
>  		dev_err(dev, "failed to acquire mipi clock\n");
> -		return PTR_ERR(csi2_dev->clock_mipi);
> +		ret = PTR_ERR(csi2_dev->clock_mipi);
> +		goto err_put_clk_rate;
>  	}
>  
>  	csi2_dev->clock_misc = devm_clk_get(dev, "misc");
>  	if (IS_ERR(csi2_dev->clock_misc)) {
>  		dev_err(dev, "failed to acquire misc clock\n");
> -		return PTR_ERR(csi2_dev->clock_misc);
> +		ret = PTR_ERR(csi2_dev->clock_misc);
> +		goto err_put_clk_rate;
>  	}
>  
>  	/* Reset */
> @@ -733,7 +735,8 @@ sun8i_a83t_mipi_csi2_resources_setup(struct sun8i_a83t_mipi_csi2_device *csi2_de
>  	csi2_dev->reset = devm_reset_control_get_shared(dev, NULL);
>  	if (IS_ERR(csi2_dev->reset)) {
>  		dev_err(dev, "failed to get reset controller\n");
> -		return PTR_ERR(csi2_dev->reset);
> +		ret = PTR_ERR(csi2_dev->reset);
> +		goto err_put_clk_rate;
>  	}
>  
>  	/* D-PHY */
> @@ -741,7 +744,7 @@ sun8i_a83t_mipi_csi2_resources_setup(struct sun8i_a83t_mipi_csi2_device *csi2_de
>  	ret = sun8i_a83t_dphy_register(csi2_dev);
>  	if (ret) {
>  		dev_err(dev, "failed to initialize MIPI D-PHY\n");
> -		return ret;
> +		goto err_put_clk_rate;
>  	}
>  
>  	/* Runtime PM */
> @@ -749,6 +752,10 @@ sun8i_a83t_mipi_csi2_resources_setup(struct sun8i_a83t_mipi_csi2_device *csi2_de
>  	pm_runtime_enable(dev);
>  
>  	return 0;
> +
> +err_put_clk_rate:

Please call this "error_clock_rate_exclusive",

> +	clk_rate_exclusive_put(csi2_dev->clock_mod);

and add a blank line here.

> +	return ret;
>  }
>  
>  static void
> @@ -778,9 +785,13 @@ static int sun8i_a83t_mipi_csi2_probe(struct platform_device *platform_dev)
>  
>  	ret = sun8i_a83t_mipi_csi2_bridge_setup(csi2_dev);
>  	if (ret)
> -		return ret;
> +		goto err_cleanup_resources;
>  
>  	return 0;
> +
> +err_cleanup_resources:

Please call this "error_resources",

> +	sun8i_a83t_mipi_csi2_resources_cleanup(csi2_dev);

and add a blank line here.

Thanks!

Paul

> +	return ret;
>  }
>  
>  static int sun8i_a83t_mipi_csi2_remove(struct platform_device *platform_dev)
> -- 
> 2.34.1
> 

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] media: sunxi: Fix some error handling path of sun6i_mipi_csi2_probe()
  2022-07-31 19:22 ` [PATCH 2/2] media: sunxi: Fix some error handling path of sun6i_mipi_csi2_probe() Christophe JAILLET
@ 2022-08-05 14:11   ` Paul Kocialkowski
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Kocialkowski @ 2022-08-05 14:11 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Mauro Carvalho Chehab, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, Hans Verkuil, Maxime Ripard, linux-kernel,
	kernel-janitors, linux-media, linux-arm-kernel, linux-sunxi


[-- Attachment #1.1: Type: text/plain, Size: 2826 bytes --]

Hi Christophe,

On Sun 31 Jul 22, 21:22, Christophe JAILLET wrote:
> Release some resources in the error handling path of the probe and of
> sun6i_mipi_csi2_resources_setup(), as already done in the remove
> function.

Thanks again, my comments are the same as in the other patch!

> Fixes: af54b4f4c17f ("media: sunxi: Add support for the A31 MIPI CSI-2 controller")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c    | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
> index a4e3f9a6b2ff..1ee8501e25f6 100644
> --- a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
> +++ b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
> @@ -661,7 +661,8 @@ sun6i_mipi_csi2_resources_setup(struct sun6i_mipi_csi2_device *csi2_dev,
>  	csi2_dev->reset = devm_reset_control_get_shared(dev, NULL);
>  	if (IS_ERR(csi2_dev->reset)) {
>  		dev_err(dev, "failed to get reset controller\n");
> -		return PTR_ERR(csi2_dev->reset);
> +		ret = PTR_ERR(csi2_dev->reset);
> +		goto err_put_clk_rate;
>  	}
>  
>  	/* D-PHY */
> @@ -669,13 +670,14 @@ sun6i_mipi_csi2_resources_setup(struct sun6i_mipi_csi2_device *csi2_dev,
>  	csi2_dev->dphy = devm_phy_get(dev, "dphy");
>  	if (IS_ERR(csi2_dev->dphy)) {
>  		dev_err(dev, "failed to get MIPI D-PHY\n");
> -		return PTR_ERR(csi2_dev->dphy);
> +		ret = PTR_ERR(csi2_dev->dphy);
> +		goto err_put_clk_rate;
>  	}
>  
>  	ret = phy_init(csi2_dev->dphy);
>  	if (ret) {
>  		dev_err(dev, "failed to initialize MIPI D-PHY\n");
> -		return ret;
> +		goto err_put_clk_rate;
>  	}
>  
>  	/* Runtime PM */
> @@ -683,6 +685,10 @@ sun6i_mipi_csi2_resources_setup(struct sun6i_mipi_csi2_device *csi2_dev,
>  	pm_runtime_enable(dev);
>  
>  	return 0;
> +
> +err_put_clk_rate:

Please call this "error_clock_rate_exclusive",

> +	clk_rate_exclusive_put(csi2_dev->clock_mod);

and add a blank line here.

> +	return ret;
>  }
>  
>  static void
> @@ -712,9 +718,13 @@ static int sun6i_mipi_csi2_probe(struct platform_device *platform_dev)
>  
>  	ret = sun6i_mipi_csi2_bridge_setup(csi2_dev);
>  	if (ret)
> -		return ret;
> +		goto err_cleanup_resources;
>  
>  	return 0;
> +
> +err_cleanup_resources:

Please call this "error_resources",

> +	sun6i_mipi_csi2_resources_cleanup(csi2_dev);

and add a blank line here.

Thanks,

Paul

> +	return ret;
>  }
>  
>  static int sun6i_mipi_csi2_remove(struct platform_device *platform_dev)
> -- 
> 2.34.1
> 

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-05 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-31 19:22 [PATCH 1/2] media: sunxi: Fix some error handling path of sun8i_a83t_mipi_csi2_probe() Christophe JAILLET
2022-07-31 19:22 ` [PATCH 2/2] media: sunxi: Fix some error handling path of sun6i_mipi_csi2_probe() Christophe JAILLET
2022-08-05 14:11   ` Paul Kocialkowski
2022-08-05 14:10 ` [PATCH 1/2] media: sunxi: Fix some error handling path of sun8i_a83t_mipi_csi2_probe() Paul Kocialkowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).