[PATCH 48/61] mtd: Prefer IS_ERR_OR_NULL over manual NULL check
Philipp Hahn
phahn-oss at avm.de
Tue Mar 10 04:49:14 PDT 2026
Prefer using IS_ERR_OR_NULL() over using IS_ERR() and a manual NULL
check.
Change generated with coccinelle.
To: Miquel Raynal <miquel.raynal at bootlin.com>
To: Richard Weinberger <richard at nod.at>
To: Vignesh Raghavendra <vigneshr at ti.com>
Cc: linux-mtd at lists.infradead.org
Cc: linux-kernel at vger.kernel.org
Signed-off-by: Philipp Hahn <phahn-oss at avm.de>
---
drivers/mtd/nand/raw/gpio.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/raw/gpio.c b/drivers/mtd/nand/raw/gpio.c
index 69e5e43532a448aa6273f3df79f53145784ccc05..86a8b62fb9e8510d36f925b8b468ec17c77e26d8 100644
--- a/drivers/mtd/nand/raw/gpio.c
+++ b/drivers/mtd/nand/raw/gpio.c
@@ -276,9 +276,9 @@ static void gpio_nand_remove(struct platform_device *pdev)
nand_cleanup(chip);
/* Enable write protection and disable the chip */
- if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp))
+ if (!IS_ERR_OR_NULL(gpiomtd->nwp))
gpiod_set_value(gpiomtd->nwp, 0);
- if (gpiomtd->nce && !IS_ERR(gpiomtd->nce))
+ if (!IS_ERR_OR_NULL(gpiomtd->nce))
gpiod_set_value(gpiomtd->nce, 0);
}
@@ -358,7 +358,7 @@ static int gpio_nand_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, gpiomtd);
/* Disable write protection, if wired up */
- if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp))
+ if (!IS_ERR_OR_NULL(gpiomtd->nwp))
gpiod_direction_output(gpiomtd->nwp, 1);
/*
@@ -381,10 +381,10 @@ static int gpio_nand_probe(struct platform_device *pdev)
return 0;
err_wp:
- if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp))
+ if (!IS_ERR_OR_NULL(gpiomtd->nwp))
gpiod_set_value(gpiomtd->nwp, 0);
out_ce:
- if (gpiomtd->nce && !IS_ERR(gpiomtd->nce))
+ if (!IS_ERR_OR_NULL(gpiomtd->nce))
gpiod_set_value(gpiomtd->nce, 0);
return ret;
--
2.43.0
More information about the Linux-rockchip
mailing list