michallenc commented on code in PR #16642: URL: https://github.com/apache/nuttx/pull/16642#discussion_r2189460540
########## drivers/mtd/ftl.c: ########## @@ -478,6 +467,86 @@ static ssize_t ftl_read(FAR struct inode *inode, unsigned char *buffer, * ****************************************************************************/ +static int ftl_alloc_eblock(FAR struct ftl_struct_s *dev) +{ + if (dev->eblock == NULL) + { + /* Allocate one, in-memory erase block buffer */ + + dev->eblock = kmm_malloc(dev->geo.erasesize); + } + + return dev->eblock != NULL ? OK : -ENOMEM; +} + +/**************************************************************************** + * Name: ftl_flush_direct + * + * Description: Write the specified number of sectors without cache + * + ****************************************************************************/ + +static ssize_t ftl_flush_direct(FAR struct ftl_struct_s *dev, + FAR const uint8_t *buffer, + off_t startblock, size_t nblocks) +{ + size_t blocksize = dev->geo.blocksize; + off_t starteraseblock; + off_t offset; + ssize_t ret; + size_t count; + + while (nblocks) + { + starteraseblock = startblock / dev->blkper; + offset = startblock & (dev->blkper - 1); + count = MIN(dev->blkper - offset, nblocks); + + if (offset == 0 && dev->mtd->erase != NULL && !(dev->oflags & O_SYNC)) Review Comment: My bad, the writes are in a while loop for each write block, thus this logic is enough. :facepalm: -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org