Skip to content

Commit 1f3dcfe

Browse files
ISCAS-Vulabmiquelraynal
authored andcommitted
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. Suggested-by: Vladimir Zapolskiy <vz@mleia.com> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Reviewed-by: Vladimir Zapolskiy <vz@mleia.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent 88fd4e4 commit 1f3dcfe

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

drivers/mtd/nand/raw/lpc32xx_slc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
854854
}
855855

856856
/* Start with WP disabled, if available */
857-
host->wp_gpio = gpiod_get_optional(&pdev->dev, NULL, GPIOD_OUT_LOW);
857+
host->wp_gpio = devm_gpiod_get_optional(&pdev->dev, NULL, GPIOD_OUT_LOW);
858858
res = PTR_ERR_OR_ZERO(host->wp_gpio);
859859
if (res) {
860860
if (res != -EPROBE_DEFER)
@@ -937,7 +937,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
937937
dma_release_channel(host->dma_chan);
938938
enable_wp:
939939
lpc32xx_wp_enable(host);
940-
gpiod_put(host->wp_gpio);
941940

942941
return res;
943942
}
@@ -963,7 +962,6 @@ static void lpc32xx_nand_remove(struct platform_device *pdev)
963962
writel(tmp, SLC_CTRL(host->io_base));
964963

965964
lpc32xx_wp_enable(host);
966-
gpiod_put(host->wp_gpio);
967965
}
968966

969967
static int lpc32xx_nand_resume(struct platform_device *pdev)

0 commit comments

Comments
 (0)