Skip to contentSkip to conversation

mtd: rawnand: lpc32xx_slc: Convert to use devm_gpiod_get_optional()

PATCH Applied Haotian Zhang 3 participants 4 messages Nov 4, 2025 – Nov 17, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: lpc32xx_slc: Convert to use devm_gpiod_get_optional()

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.

---
 drivers/mtd/nand/raw/lpc32xx_slc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/raw/lpc32xx_slc.c +1 -3
index fea3705a2138..3ca30e7dce33 100644
@@ -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)
Signature · 1 line
2.50.1.windows.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · 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.

---
  drivers/mtd/nand/raw/lpc32xx_slc.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mtd/nand/raw/lpc32xx_slc.c +1 -2
index fea3705a2138..3ca30e7dce33 100644
@@ -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;
  }

drivers/mtd/nand/raw/lpc32xx_slc.c static void lpc32xx_nand_remove(struct platform_device *pdev) · line 967

Quoted 7 lines
drivers/mtd/nand/raw/lpc32xx_slc.c +0 -1
@@ -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!

Signature · 2 lines
Best wishes,
Vladimir
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Haotian Zhang
Quoted 8 lines · 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.

Signature · 2 lines
Best wishes,
Vladimir
maintainer Applied
#3 lore raw
In reply to Haotian Zhang
Quoted 8 lines · 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.

[...]

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