linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: sh: rz-dmac: Improve probe()/remove()
@ 2023-05-18 15:20 Biju Das
  2023-06-30 14:59 ` Biju Das
  0 siblings, 1 reply; 2+ messages in thread
From: Biju Das @ 2023-05-18 15:20 UTC (permalink / raw)
  To: Vinod Koul, Philipp Zabel
  Cc: Biju Das, Geert Uytterhoeven, Lad Prabhakar, dmaengine,
	Fabrizio Castro, linux-renesas-soc, Pavel Machek

We usually do cleanup in reverse order of init. Currently, in case of
error, this is not followed in rz_dmac_probe() and similar case for
remove().

This patch improves error handling in probe() error path and
in remove() do cleanup in reverse order of init.

Reported-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/dma/sh/rz-dmac.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 9479f29692d3..229f642fde6b 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -947,7 +947,6 @@ static int rz_dmac_probe(struct platform_device *pdev)
 dma_register_err:
 	of_dma_controller_free(pdev->dev.of_node);
 err:
-	reset_control_assert(dmac->rstc);
 	channel_num = i ? i - 1 : 0;
 	for (i = 0; i < channel_num; i++) {
 		struct rz_dmac_chan *channel = &dmac->channels[i];
@@ -958,6 +957,7 @@ static int rz_dmac_probe(struct platform_device *pdev)
 				  channel->lmdesc.base_dma);
 	}
 
+	reset_control_assert(dmac->rstc);
 err_pm_runtime_put:
 	pm_runtime_put(&pdev->dev);
 err_pm_disable:
@@ -971,6 +971,8 @@ static int rz_dmac_remove(struct platform_device *pdev)
 	struct rz_dmac *dmac = platform_get_drvdata(pdev);
 	unsigned int i;
 
+	dma_async_device_unregister(&dmac->engine);
+	of_dma_controller_free(pdev->dev.of_node);
 	for (i = 0; i < dmac->n_channels; i++) {
 		struct rz_dmac_chan *channel = &dmac->channels[i];
 
@@ -979,8 +981,6 @@ static int rz_dmac_remove(struct platform_device *pdev)
 				  channel->lmdesc.base,
 				  channel->lmdesc.base_dma);
 	}
-	of_dma_controller_free(pdev->dev.of_node);
-	dma_async_device_unregister(&dmac->engine);
 	reset_control_assert(dmac->rstc);
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-- 
2.25.1


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

* RE: [PATCH] dmaengine: sh: rz-dmac: Improve probe()/remove()
  2023-05-18 15:20 [PATCH] dmaengine: sh: rz-dmac: Improve probe()/remove() Biju Das
@ 2023-06-30 14:59 ` Biju Das
  0 siblings, 0 replies; 2+ messages in thread
From: Biju Das @ 2023-06-30 14:59 UTC (permalink / raw)
  To: Biju Das, Vinod Koul, Philipp Zabel
  Cc: Geert Uytterhoeven, Prabhakar Mahadev Lad, dmaengine,
	Fabrizio Castro, linux-renesas-soc, Pavel Machek

Hi Vinod,

Gentle ping. Looks like it missed out.
Anyway, I will rebase and Resend.

Cheers,
Biju

> -----Original Message-----
> From: Biju Das <biju.das.jz@bp.renesas.com>
> Sent: Thursday, May 18, 2023 4:20 PM
> To: Vinod Koul <vkoul@kernel.org>; Philipp Zabel
> <p.zabel@pengutronix.de>
> Cc: Biju Das <biju.das.jz@bp.renesas.com>; Geert Uytterhoeven
> <geert+renesas@glider.be>; Prabhakar Mahadev Lad <prabhakar.mahadev-
> lad.rj@bp.renesas.com>; dmaengine@vger.kernel.org; Fabrizio Castro
> <fabrizio.castro.jz@renesas.com>; linux-renesas-soc@vger.kernel.org;
> Pavel Machek <pavel@denx.de>
> Subject: [PATCH] dmaengine: sh: rz-dmac: Improve probe()/remove()
> 
> We usually do cleanup in reverse order of init. Currently, in case of
> error, this is not followed in rz_dmac_probe() and similar case for
> remove().
> 
> This patch improves error handling in probe() error path and in remove()
> do cleanup in reverse order of init.
> 
> Reported-by: Pavel Machek <pavel@denx.de>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
>  drivers/dma/sh/rz-dmac.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index
> 9479f29692d3..229f642fde6b 100644
> --- a/drivers/dma/sh/rz-dmac.c
> +++ b/drivers/dma/sh/rz-dmac.c
> @@ -947,7 +947,6 @@ static int rz_dmac_probe(struct platform_device
> *pdev)
>  dma_register_err:
>  	of_dma_controller_free(pdev->dev.of_node);
>  err:
> -	reset_control_assert(dmac->rstc);
>  	channel_num = i ? i - 1 : 0;
>  	for (i = 0; i < channel_num; i++) {
>  		struct rz_dmac_chan *channel = &dmac->channels[i]; @@ -958,6
> +957,7 @@ static int rz_dmac_probe(struct platform_device *pdev)
>  				  channel->lmdesc.base_dma);
>  	}
> 
> +	reset_control_assert(dmac->rstc);
>  err_pm_runtime_put:
>  	pm_runtime_put(&pdev->dev);
>  err_pm_disable:
> @@ -971,6 +971,8 @@ static int rz_dmac_remove(struct platform_device
> *pdev)
>  	struct rz_dmac *dmac = platform_get_drvdata(pdev);
>  	unsigned int i;
> 
> +	dma_async_device_unregister(&dmac->engine);
> +	of_dma_controller_free(pdev->dev.of_node);
>  	for (i = 0; i < dmac->n_channels; i++) {
>  		struct rz_dmac_chan *channel = &dmac->channels[i];
> 
> @@ -979,8 +981,6 @@ static int rz_dmac_remove(struct platform_device
> *pdev)
>  				  channel->lmdesc.base,
>  				  channel->lmdesc.base_dma);
>  	}
> -	of_dma_controller_free(pdev->dev.of_node);
> -	dma_async_device_unregister(&dmac->engine);
>  	reset_control_assert(dmac->rstc);
>  	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
> --
> 2.25.1


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

end of thread, other threads:[~2023-06-30 15:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-18 15:20 [PATCH] dmaengine: sh: rz-dmac: Improve probe()/remove() Biju Das
2023-06-30 14:59 ` Biju Das

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).