[PATCH v2 14/20] mtd: mchp23k256: Warn about failure to unregister mtd device

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Tue Oct 12 08:39:39 PDT 2021


When an spi driver's remove function returns a non-zero error code
nothing happens apart from emitting a generic error message. Make this
error message more device specific and return zero instead.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
---
 drivers/mtd/devices/mchp23k256.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c
index 77c872fd3d83..23213009ebf4 100644
--- a/drivers/mtd/devices/mchp23k256.c
+++ b/drivers/mtd/devices/mchp23k256.c
@@ -212,8 +212,15 @@ static int mchp23k256_probe(struct spi_device *spi)
 static int mchp23k256_remove(struct spi_device *spi)
 {
 	struct mchp23k256_flash *flash = spi_get_drvdata(spi);
+	int ret;
 
-	return mtd_device_unregister(&flash->mtd);
+	ret = mtd_device_unregister(&flash->mtd);
+	if (ret)
+		/* There is nothing we can do about this ... */
+		dev_warn(&spi->dev, "Failed to unregister mtd device (%pe)\n",
+			 ERR_PTR(ret));
+
+	return 0;
 }
 
 static const struct of_device_id mchp23k256_of_table[] = {
-- 
2.30.2




More information about the linux-mtd mailing list