Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: lpc32xx_slc: Convert to use devm_gpiod_get_optional()
@ 2025-11-04 10:08 Haotian Zhang
  2025-11-06 14:21 ` Vladimir Zapolskiy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Haotian Zhang @ 2025-11-04 10:08 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Vladimir Zapolskiy, Piotr Wojtaszczyk
  Cc: linux-mtd, linux-arm-kernel, linux-kernel, Haotian Zhang

The initial fix for a GPIO descriptor leak added manual gpiod_put()
calls in the error path and remove function.

This follow-up patch improves upon the fix by switching to the
resource-managed devm_gpiod_get_optional() API.

Suggested-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/mtd/nand/raw/lpc32xx_slc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/raw/lpc32xx_slc.c b/drivers/mtd/nand/raw/lpc32xx_slc.c
index fea3705a2138..3ca30e7dce33 100644
--- a/drivers/mtd/nand/raw/lpc32xx_slc.c
+++ b/drivers/mtd/nand/raw/lpc32xx_slc.c
@@ -854,7 +854,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 	}
 
 	/* Start with WP disabled, if available */
-	host->wp_gpio = gpiod_get_optional(&pdev->dev, NULL, GPIOD_OUT_LOW);
+	host->wp_gpio = devm_gpiod_get_optional(&pdev->dev, NULL, GPIOD_OUT_LOW);
 	res = PTR_ERR_OR_ZERO(host->wp_gpio);
 	if (res) {
 		if (res != -EPROBE_DEFER)
@@ -937,7 +937,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 	dma_release_channel(host->dma_chan);
 enable_wp:
 	lpc32xx_wp_enable(host);
-	gpiod_put(host->wp_gpio);
 
 	return res;
 }
@@ -963,7 +962,6 @@ static void lpc32xx_nand_remove(struct platform_device *pdev)
 	writel(tmp, SLC_CTRL(host->io_base));
 
 	lpc32xx_wp_enable(host);
-	gpiod_put(host->wp_gpio);
 }
 
 static int lpc32xx_nand_resume(struct platform_device *pdev)
-- 
2.50.1.windows.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: rawnand: lpc32xx_slc: Convert to use devm_gpiod_get_optional()
  2025-11-04 10:08 [PATCH] mtd: rawnand: lpc32xx_slc: Convert to use devm_gpiod_get_optional() Haotian Zhang
@ 2025-11-06 14:21 ` Vladimir Zapolskiy
  2025-11-14  0:18 ` Vladimir Zapolskiy
  2025-11-17 10:55 ` Miquel Raynal
  2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Zapolskiy @ 2025-11-06 14:21 UTC (permalink / raw)
  To: Haotian Zhang, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Piotr Wojtaszczyk
  Cc: linux-mtd, linux-arm-kernel, linux-kernel

On 11/4/25 12:08, Haotian Zhang wrote:
> The initial fix for a GPIO descriptor leak added manual gpiod_put()
> calls in the error path and remove function.
> 
> This follow-up patch improves upon the fix by switching to the
> resource-managed devm_gpiod_get_optional() API.
> 
> Suggested-by: Vladimir Zapolskiy <vz@mleia.com>
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
>   drivers/mtd/nand/raw/lpc32xx_slc.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/lpc32xx_slc.c b/drivers/mtd/nand/raw/lpc32xx_slc.c
> index fea3705a2138..3ca30e7dce33 100644
> --- a/drivers/mtd/nand/raw/lpc32xx_slc.c
> +++ b/drivers/mtd/nand/raw/lpc32xx_slc.c
> @@ -854,7 +854,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
>   	}
>   
>   	/* Start with WP disabled, if available */
> -	host->wp_gpio = gpiod_get_optional(&pdev->dev, NULL, GPIOD_OUT_LOW);
> +	host->wp_gpio = devm_gpiod_get_optional(&pdev->dev, NULL, GPIOD_OUT_LOW);
>   	res = PTR_ERR_OR_ZERO(host->wp_gpio);
>   	if (res) {
>   		if (res != -EPROBE_DEFER)
> @@ -937,7 +937,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
>   	dma_release_channel(host->dma_chan);
>   enable_wp:
>   	lpc32xx_wp_enable(host);
> -	gpiod_put(host->wp_gpio);
>   
>   	return res;
>   }
> @@ -963,7 +962,6 @@ static void lpc32xx_nand_remove(struct platform_device *pdev)
>   	writel(tmp, SLC_CTRL(host->io_base));
>   
>   	lpc32xx_wp_enable(host);
> -	gpiod_put(host->wp_gpio);
>   }
>   
>   static int lpc32xx_nand_resume(struct platform_device *pdev)

Thank you so much for the change!

Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>

-- 
Best wishes,
Vladimir


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: rawnand: lpc32xx_slc: Convert to use devm_gpiod_get_optional()
  2025-11-04 10:08 [PATCH] mtd: rawnand: lpc32xx_slc: Convert to use devm_gpiod_get_optional() Haotian Zhang
  2025-11-06 14:21 ` Vladimir Zapolskiy
@ 2025-11-14  0:18 ` Vladimir Zapolskiy
  2025-11-17 10:55 ` Miquel Raynal
  2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Zapolskiy @ 2025-11-14  0:18 UTC (permalink / raw)
  To: Haotian Zhang, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Piotr Wojtaszczyk
  Cc: linux-mtd, linux-arm-kernel, linux-kernel

On 11/4/25 12:08, Haotian Zhang wrote:
> The initial fix for a GPIO descriptor leak added manual gpiod_put()
> calls in the error path and remove function.
> 
> This follow-up patch improves upon the fix by switching to the
> resource-managed devm_gpiod_get_optional() API.
> 
> Suggested-by: Vladimir Zapolskiy <vz@mleia.com>
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>

Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>

-- 
Best wishes,
Vladimir

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: rawnand: lpc32xx_slc: Convert to use devm_gpiod_get_optional()
  2025-11-04 10:08 [PATCH] mtd: rawnand: lpc32xx_slc: Convert to use devm_gpiod_get_optional() Haotian Zhang
  2025-11-06 14:21 ` Vladimir Zapolskiy
  2025-11-14  0:18 ` Vladimir Zapolskiy
@ 2025-11-17 10:55 ` Miquel Raynal
  2 siblings, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2025-11-17 10:55 UTC (permalink / raw)
  To: Richard Weinberger, Vignesh Raghavendra, Vladimir Zapolskiy,
	Piotr Wojtaszczyk, Haotian Zhang
  Cc: linux-mtd, linux-arm-kernel, linux-kernel

On Tue, 04 Nov 2025 18:08:41 +0800, Haotian Zhang wrote:
> The initial fix for a GPIO descriptor leak added manual gpiod_put()
> calls in the error path and remove function.
> 
> This follow-up patch improves upon the fix by switching to the
> resource-managed devm_gpiod_get_optional() API.
> 
> 
> [...]

Applied to nand/next, thanks!

[1/1] mtd: rawnand: lpc32xx_slc: Convert to use devm_gpiod_get_optional()
      commit: 1f3dcfe5fcf57739b4a82811c12e55c48d794f86

Patche(s) should be available on mtd/linux.git and will be
part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2025-11-17 10:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04 10:08 [PATCH] mtd: rawnand: lpc32xx_slc: Convert to use devm_gpiod_get_optional() Haotian Zhang
2025-11-06 14:21 ` Vladimir Zapolskiy
2025-11-14  0:18 ` Vladimir Zapolskiy
2025-11-17 10:55 ` Miquel Raynal

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