mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dmaengine: ppc4xx: convert irq_of_parse_and_map to platform_get_irq
@ 2026-09-10 21:27 Rosen Penev
  2026-09-11 16:03 ` Frank Li
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-09-10 21:27 UTC (permalink / raw)
  To: dmaengine; +Cc: Vinod Koul, Frank Li, open list

Replace irq_of_parse_and_map() with platform_get_irq(), which is the
preferred way to obtain IRQ resources from platform devices.  This
eliminates the corresponding irq_dispose_mapping() calls since the
framework manages the mapping.

While here, fix a latent bug in the err_req2 error path: the error IRQ
was not freed when a subsequent step (I2O setup) failed.

The struct device_node *np declaration is moved to the scope where
it is still needed (I2O register lookup).

Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/dma/ppc4xx/adma.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
index 279a431ccae3..42fc1791662b 100644
--- a/drivers/dma/ppc4xx/adma.c
+++ b/drivers/dma/ppc4xx/adma.c
@@ -3865,28 +3865,25 @@ static int ppc440spe_adma_setup_irqs(struct ppc440spe_adma_device *adev,
 				     int *initcode)
 {
 	struct platform_device *ofdev;
-	struct device_node *np;
 	int ret;
 
 	ofdev = container_of(adev->dev, struct platform_device, dev);
-	np = ofdev->dev.of_node;
 	if (adev->id != PPC440SPE_XOR_ID) {
-		adev->err_irq = irq_of_parse_and_map(np, 1);
-		if (!adev->err_irq) {
+		adev->err_irq = platform_get_irq(ofdev, 1);
+		if (adev->err_irq < 0) {
 			dev_warn(adev->dev, "no err irq resource?\n");
 			*initcode = PPC_ADMA_INIT_IRQ2;
-			adev->err_irq = -ENXIO;
 		} else
 			atomic_inc(&ppc440spe_adma_err_irq_ref);
 	} else {
 		adev->err_irq = -ENXIO;
 	}
 
-	adev->irq = irq_of_parse_and_map(np, 0);
-	if (!adev->irq) {
+	adev->irq = platform_get_irq(ofdev, 0);
+	if (adev->irq < 0) {
 		dev_err(adev->dev, "no irq resource\n");
 		*initcode = PPC_ADMA_INIT_IRQ1;
-		ret = -ENXIO;
+		ret = adev->irq;
 		goto err_irq_map;
 	}
 	dev_dbg(adev->dev, "irq %d, err irq %d\n",
@@ -3927,6 +3924,7 @@ static int ppc440spe_adma_setup_irqs(struct ppc440spe_adma_device *adev,
 			    XOR_IE_ICIE_BIT | XOR_IE_RPTIE_BIT,
 			    &adev->xor_reg->ier);
 	} else {
+		struct device_node *np;
 		u32 mask, enable;
 
 		np = of_find_compatible_node(NULL, NULL, "ibm,i2o-440spe");
@@ -3956,14 +3954,13 @@ static int ppc440spe_adma_setup_irqs(struct ppc440spe_adma_device *adev,
 	return 0;
 
 err_req2:
+	if (adev->err_irq > 0)
+		free_irq(adev->err_irq, chan);
 	free_irq(adev->irq, chan);
 err_req1:
-	irq_dispose_mapping(adev->irq);
 err_irq_map:
-	if (adev->err_irq > 0) {
-		if (atomic_dec_and_test(&ppc440spe_adma_err_irq_ref))
-			irq_dispose_mapping(adev->err_irq);
-	}
+	if (adev->err_irq > 0)
+		atomic_dec(&ppc440spe_adma_err_irq_ref);
 	return ret;
 }
 
@@ -3987,13 +3984,10 @@ static void ppc440spe_adma_release_irqs(struct ppc440spe_adma_device *adev,
 		iowrite32(mask, &adev->i2o_reg->iopim);
 	}
 	free_irq(adev->irq, chan);
-	irq_dispose_mapping(adev->irq);
 	if (adev->err_irq > 0) {
 		free_irq(adev->err_irq, chan);
-		if (atomic_dec_and_test(&ppc440spe_adma_err_irq_ref)) {
-			irq_dispose_mapping(adev->err_irq);
+		if (atomic_dec_and_test(&ppc440spe_adma_err_irq_ref))
 			iounmap(adev->i2o_reg);
-		}
 	}
 }
 
-- 
2.55.0


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

* Re: [PATCH] dmaengine: ppc4xx: convert irq_of_parse_and_map to platform_get_irq
  2026-09-10 21:27 [PATCH] dmaengine: ppc4xx: convert irq_of_parse_and_map to platform_get_irq Rosen Penev
@ 2026-09-11 16:03 ` Frank Li
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2026-09-11 16:03 UTC (permalink / raw)
  To: Rosen Penev; +Cc: dmaengine, Vinod Koul, Frank Li, open list

On Thu, Sep 10, 2026 at 02:27:20PM -0700, Rosen Penev wrote:

subject: function need ().

> Replace irq_of_parse_and_map() with platform_get_irq(), which is the
> preferred way to obtain IRQ resources from platform devices.  This
> eliminates the corresponding irq_dispose_mapping() calls

> since the
> framework manages the mapping.


Needn't this

>
> While here, fix a latent bug in the err_req2 error path: the error IRQ

remove "While here", just Fix ...

> was not freed when a subsequent step (I2O setup) failed.
>
> The struct device_node *np declaration is moved to the scope where
> it is still needed (I2O register lookup).
>
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  drivers/dma/ppc4xx/adma.c | 28 +++++++++++-----------------
>  1 file changed, 11 insertions(+), 17 deletions(-)

please collect all ppc4xx fix into a patch serial.

>
> diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
> index 279a431ccae3..42fc1791662b 100644
> --- a/drivers/dma/ppc4xx/adma.c
> +++ b/drivers/dma/ppc4xx/adma.c
> @@ -3865,28 +3865,25 @@ static int ppc440spe_adma_setup_irqs(struct ppc440spe_adma_device *adev,
>  				     int *initcode)
>  {
>  	struct platform_device *ofdev;
> -	struct device_node *np;
>  	int ret;
>
>  	ofdev = container_of(adev->dev, struct platform_device, dev);
> -	np = ofdev->dev.of_node;
>  	if (adev->id != PPC440SPE_XOR_ID) {
> -		adev->err_irq = irq_of_parse_and_map(np, 1);
> -		if (!adev->err_irq) {
> +		adev->err_irq = platform_get_irq(ofdev, 1);
> +		if (adev->err_irq < 0) {
>  			dev_warn(adev->dev, "no err irq resource?\n");
>  			*initcode = PPC_ADMA_INIT_IRQ2;
> -			adev->err_irq = -ENXIO;

need descript in comment message to propagate irq number instead return
-ENXIO.

Frank
>  		} else
>  			atomic_inc(&ppc440spe_adma_err_irq_ref);
>  	} else {
>  		adev->err_irq = -ENXIO;
>  	}
>
> -	adev->irq = irq_of_parse_and_map(np, 0);
> -	if (!adev->irq) {
> +	adev->irq = platform_get_irq(ofdev, 0);
> +	if (adev->irq < 0) {
>  		dev_err(adev->dev, "no irq resource\n");
>  		*initcode = PPC_ADMA_INIT_IRQ1;
> -		ret = -ENXIO;
> +		ret = adev->irq;
>  		goto err_irq_map;
>  	}
>  	dev_dbg(adev->dev, "irq %d, err irq %d\n",
> @@ -3927,6 +3924,7 @@ static int ppc440spe_adma_setup_irqs(struct ppc440spe_adma_device *adev,
>  			    XOR_IE_ICIE_BIT | XOR_IE_RPTIE_BIT,
>  			    &adev->xor_reg->ier);
>  	} else {
> +		struct device_node *np;
>  		u32 mask, enable;
>
>  		np = of_find_compatible_node(NULL, NULL, "ibm,i2o-440spe");
> @@ -3956,14 +3954,13 @@ static int ppc440spe_adma_setup_irqs(struct ppc440spe_adma_device *adev,
>  	return 0;
>
>  err_req2:
> +	if (adev->err_irq > 0)
> +		free_irq(adev->err_irq, chan);
>  	free_irq(adev->irq, chan);
>  err_req1:
> -	irq_dispose_mapping(adev->irq);
>  err_irq_map:
> -	if (adev->err_irq > 0) {
> -		if (atomic_dec_and_test(&ppc440spe_adma_err_irq_ref))
> -			irq_dispose_mapping(adev->err_irq);
> -	}
> +	if (adev->err_irq > 0)
> +		atomic_dec(&ppc440spe_adma_err_irq_ref);
>  	return ret;
>  }
>
> @@ -3987,13 +3984,10 @@ static void ppc440spe_adma_release_irqs(struct ppc440spe_adma_device *adev,
>  		iowrite32(mask, &adev->i2o_reg->iopim);
>  	}
>  	free_irq(adev->irq, chan);
> -	irq_dispose_mapping(adev->irq);
>  	if (adev->err_irq > 0) {
>  		free_irq(adev->err_irq, chan);
> -		if (atomic_dec_and_test(&ppc440spe_adma_err_irq_ref)) {
> -			irq_dispose_mapping(adev->err_irq);
> +		if (atomic_dec_and_test(&ppc440spe_adma_err_irq_ref))
>  			iounmap(adev->i2o_reg);
> -		}
>  	}
>  }
>
> --
> 2.55.0
>

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

end of thread, other threads:[~2026-09-11 16:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-10 21:27 [PATCH] dmaengine: ppc4xx: convert irq_of_parse_and_map to platform_get_irq Rosen Penev
2026-09-11 16:03 ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®