You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/04/07 10:50:09 UTC
(nuttx) 02/02: driver/filemtd:support isbad & markbad
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit d19486e1f862b7bf52a9b927af6ba5f497bb0ffe
Author: chenrun1 <ch...@xiaomi.com>
AuthorDate: Fri Jan 26 16:38:41 2024 +0800
driver/filemtd:support isbad & markbad
In this change, we can mount a filesystem on filemtd that works like Yaffs and works on the Nand driver
Signed-off-by: chenrun1 <ch...@xiaomi.com>
---
drivers/mtd/filemtd.c | 44 +++++++++++++++++++++++++++++++++++---------
1 file changed, 35 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/filemtd.c b/drivers/mtd/filemtd.c
index 4857e7e414..5fd6d614cf 100644
--- a/drivers/mtd/filemtd.c
+++ b/drivers/mtd/filemtd.c
@@ -119,6 +119,8 @@ static ssize_t file_bytewrite(FAR struct mtd_dev_s *dev, off_t offset,
#endif
static int filemtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
unsigned long arg);
+static int filemtd_isbad(FAR struct mtd_dev_s *dev, off_t block);
+static int filemtd_markbad(FAR struct mtd_dev_s *dev, off_t block);
#ifdef CONFIG_MTD_LOOP
static ssize_t mtd_loop_read(FAR struct file *filep, FAR char *buffer,
@@ -149,6 +151,28 @@ static const struct file_operations g_fops =
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: filemtd_isbad
+ ****************************************************************************/
+
+static int filemtd_isbad(FAR struct mtd_dev_s *dev, off_t block)
+{
+ /* We always think it's all GOODBLOCK */
+
+ return 0;
+}
+
+/****************************************************************************
+ * Name: filemtd_markbad
+ ****************************************************************************/
+
+static int filemtd_markbad(FAR struct mtd_dev_s *dev, off_t block)
+{
+ /* Provides a dummy interface */
+
+ return 0;
+}
+
/****************************************************************************
* Name: filemtd_write
****************************************************************************/
@@ -800,17 +824,19 @@ FAR struct mtd_dev_s *filemtd_initialize(FAR const char *path, size_t offset,
* nullified by kmm_zalloc).
*/
- priv->mtd.erase = filemtd_erase;
- priv->mtd.bread = filemtd_bread;
- priv->mtd.bwrite = filemtd_bwrite;
- priv->mtd.read = filemtd_byteread;
+ priv->mtd.erase = filemtd_erase;
+ priv->mtd.bread = filemtd_bread;
+ priv->mtd.bwrite = filemtd_bwrite;
+ priv->mtd.read = filemtd_byteread;
#ifdef CONFIG_MTD_BYTE_WRITE
- priv->mtd.write = file_bytewrite;
+ priv->mtd.write = file_bytewrite;
#endif
- priv->mtd.ioctl = filemtd_ioctl;
- priv->mtd.name = "filemtd";
- priv->offset = offset;
- priv->nblocks = nblocks;
+ priv->mtd.ioctl = filemtd_ioctl;
+ priv->mtd.isbad = filemtd_isbad;
+ priv->mtd.markbad = filemtd_markbad;
+ priv->mtd.name = "filemtd";
+ priv->offset = offset;
+ priv->nblocks = nblocks;
return &priv->mtd;
}