This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 266455f01c mtd: Extend isbad and markbad func for mtd_dev_s
266455f01c is described below
commit 266455f01ce6a141fee59d151d8e1555c52576be
Author: huxiandong <[email protected]>
AuthorDate: Wed Jan 4 22:08:03 2023 +0800
mtd: Extend isbad and markbad func for mtd_dev_s
Signed-off-by: huxiandong <[email protected]>
---
arch/arm/src/rp2040/rp2040_flash_mtd.c | 2 ++
drivers/mtd/mtd_progmem.c | 2 ++
include/nuttx/mtd/mtd.h | 7 +++++++
3 files changed, 11 insertions(+)
diff --git a/arch/arm/src/rp2040/rp2040_flash_mtd.c
b/arch/arm/src/rp2040/rp2040_flash_mtd.c
index d99e8879b8..2ef6bb44df 100644
--- a/arch/arm/src/rp2040/rp2040_flash_mtd.c
+++ b/arch/arm/src/rp2040/rp2040_flash_mtd.c
@@ -164,6 +164,8 @@ static struct rp2040_flash_dev_s my_dev =
NULL,
#endif
rp2040_flash_ioctl,
+ NULL,
+ NULL,
"rp_flash"
},
.lock = NXMUTEX_INITIALIZER,
diff --git a/drivers/mtd/mtd_progmem.c b/drivers/mtd/mtd_progmem.c
index 4773e866de..762f33735f 100644
--- a/drivers/mtd/mtd_progmem.c
+++ b/drivers/mtd/mtd_progmem.c
@@ -101,6 +101,8 @@ static struct progmem_dev_s g_progmem =
progmem_write,
#endif
progmem_ioctl,
+ NULL,
+ NULL,
"progmem",
}
};
diff --git a/include/nuttx/mtd/mtd.h b/include/nuttx/mtd/mtd.h
index b765bc40b5..b01ad550fb 100644
--- a/include/nuttx/mtd/mtd.h
+++ b/include/nuttx/mtd/mtd.h
@@ -83,6 +83,8 @@
#define MTD_READ(d,s,n,b) ((d)->read ? (d)->read(d,s,n,b) : (-ENOSYS))
#define MTD_WRITE(d,s,n,b) ((d)->write ? (d)->write(d,s,n,b) : (-ENOSYS))
#define MTD_IOCTL(d,c,a) ((d)->ioctl ? (d)->ioctl(d,c,a) : (-ENOSYS))
+#define MTD_ISBAD(d,b) ((d)->isbad ? (d)->isbad(d,b) : (-ENOSYS))
+#define MTD_MARKBAD(d,b) ((d)->markbad ? (d)->markbad(d,b) : (-ENOSYS))
/* If any of the low-level device drivers declare they want sub-sector erase
* support, then define MTD_SUBSECTOR_ERASE.
@@ -185,6 +187,11 @@ struct mtd_dev_s
int (*ioctl)(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
+ /* Check/Mark bad block for the specified block number */
+
+ int (*isbad)(FAR struct mtd_dev_s *dev, off_t block);
+ int (*markbad)(FAR struct mtd_dev_s *dev, off_t block);
+
/* Name of this MTD device */
FAR const char *name;