[PATCH v2 13/20] mtd: dataflash: Warn about failure to unregister mtd device

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Tue Oct 12 08:39:38 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/mtd_dataflash.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index 9802e265fca8..2691b6b79df8 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -919,7 +919,10 @@ static int dataflash_remove(struct spi_device *spi)
 	status = mtd_device_unregister(&flash->mtd);
 	if (status == 0)
 		kfree(flash);
-	return status;
+	else
+		dev_warn(&spi->dev, "Failed to unregister mtd device (%pe)\n",
+			 ERR_PTR(status));
+	return 0;
 }
 
 static struct spi_driver dataflash_driver = {
-- 
2.30.2




More information about the linux-mtd mailing list