summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/mtd-uclass.c12
-rw-r--r--drivers/mtd/nand/spi/core.c11
2 files changed, 18 insertions, 5 deletions
diff --git a/drivers/mtd/mtd-uclass.c b/drivers/mtd/mtd-uclass.c
index 5418217431..cf749b4a16 100644
--- a/drivers/mtd/mtd-uclass.c
+++ b/drivers/mtd/mtd-uclass.c
@@ -24,6 +24,18 @@ int mtd_probe(struct udevice *dev)
return device_probe(dev);
}
+/**
+ * mtd_remove - Remove the device @dev
+ *
+ * @dev: U-Boot device to probe
+ *
+ * @return 0 on success, an error otherwise.
+ */
+int mtd_remove(struct mtd_info *mtd)
+{
+ return device_remove(mtd->dev, DM_REMOVE_NORMAL);
+}
+
/*
* Implement a MTD uclass which should include most flash drivers.
* The uclass private is pointed to mtd_info.
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index f3dab39930..0c88310e28 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1297,26 +1297,25 @@ err_spinand_cleanup:
return ret;
}
-#ifndef __UBOOT__
static int spinand_remove(struct udevice *slave)
{
- struct spinand_device *spinand;
+ struct spinand_device *spinand = dev_get_priv(slave);
struct mtd_info *mtd;
- int ret;
- spinand = spi_mem_get_drvdata(slave);
mtd = spinand_to_mtd(spinand);
free(mtd->name);
+#ifndef __UBOOT__
ret = mtd_device_unregister(mtd);
if (ret)
return ret;
-
+#endif
spinand_cleanup(spinand);
return 0;
}
+#ifndef __UBOOT__
static const struct spi_device_id spinand_ids[] = {
{ .name = "spi-nand" },
{ /* sentinel */ },
@@ -1358,4 +1357,6 @@ U_BOOT_DRIVER(spinand) = {
.of_match = spinand_ids,
.priv_auto_alloc_size = sizeof(struct spinand_device),
.probe = spinand_probe,
+ .remove = spinand_remove,
+ .flags = DM_FLAG_OS_PREPARE,
};