From 925b8b0904dcdd8d2c36b5d0a3fe0f1960e6a5bf Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Wed, 18 Dec 2024 10:29:34 +0200 Subject: [PATCH] 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 --- 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. */