This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch releases/12.8
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/releases/12.8 by this push:
new 925b8b0904 drivers/bch/bchdev_driver.c: Fix BIOC_FLUSH
925b8b0904 is described below
commit 925b8b0904dcdd8d2c36b5d0a3fe0f1960e6a5bf
Author: Jukka Laitinen <[email protected]>
AuthorDate: Wed Dec 18 10:29:34 2024 +0200
drivers/bch/bchdev_driver.c: Fix BIOC_FLUSH
Don't fail if the lowerhalf mtd driver doesn't support BIOC_FLUSH;
This is normal - if the lowerhalf has nothing to do, it doesn't handle
the IOCTL.
Signed-off-by: Jukka Laitinen <[email protected]>
---
drivers/bch/bchdev_driver.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/bch/bchdev_driver.c b/drivers/bch/bchdev_driver.c
index 726932c193..53363d5972 100644
--- a/drivers/bch/bchdev_driver.c
+++ b/drivers/bch/bchdev_driver.c
@@ -437,16 +437,31 @@ static int bch_ioctl(FAR struct file *filep, int cmd,
unsigned long arg)
case BIOC_FLUSH:
{
+ FAR struct inode *bchinode = bch->inode;
+ int ret2 = -ENOTTY;
+
/* Flush any dirty pages remaining in the cache */
ret = bchlib_flushsector(bch, false);
- if (ret < 0)
+
+ /* Also pass the IOCTL command to the contained block driver */
+
+ if (bchinode->u.i_bops->ioctl != NULL)
{
- break;
+ ret2 = bchinode->u.i_bops->ioctl(bchinode, cmd, arg);
}
- /* Go through */
+ /* If the lowerhalf supports BIOC_FLUSH, and flushsector succeeded,
+ * return the error code from the lowerhalf. Otherwise just return
+ * the error code from bchlib_flushsector
+ */
+
+ if (ret2 != -ENOTTY && ret == OK)
+ {
+ ret = ret2;
+ }
}
+ break;
/* Pass the IOCTL command on to the contained block driver. */