Skip to content

Commit

Permalink
drivers/bch/bchdev_driver.c: Fix BIOC_FLUSH
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jlaitine authored and xiaoxiang781216 committed Dec 19, 2024
1 parent 1200d49 commit 925b8b0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions drivers/bch/bchdev_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand Down

0 comments on commit 925b8b0

Please sign in to comment.