Fix for a bug that would show up if CONFIG_MTD_BYTE_WRITE was not selected and the SMART sector size was larger than the mtd device's block size (like it would be if using SMARTFS on larger flash devices). From Ken Pettit

This commit is contained in:
Gregory Nutt 2014-07-03 18:14:51 -06:00
parent 9f5418e5d3
commit f881abe2da

View file

@ -578,7 +578,9 @@ static ssize_t smart_bytewrite(struct smart_struct_s *dev, size_t offset,
/* First calculate the start block and number of blocks affected */
startblock = offset / dev->geo.blocksize;
nblocks = (nbytes + dev->geo.blocksize-1) / dev->geo.blocksize;
nblocks = (offset - startblock * dev->geo.blocksize + nbytes +
dev->geo.blocksize-1) / dev->geo.blocksize;
DEBUGASSERT(nblocks <= dev->mtdBlksPerSector);
/* Do a block read */