fatfs: Adopted the trim function in the FAT filesystem

pull/4983/head
Christopher Haster 2017-08-28 14:33:34 -05:00
parent 6e1b9e153c
commit ee88097cb6
2 changed files with 10 additions and 1 deletions

View File

@ -171,7 +171,7 @@
/ disk_ioctl() function. */
#define _USE_TRIM 0
#define _USE_TRIM 1
/* This option switches ATA-TRIM feature. (0:Disable or 1:Enable)
/ To enable Trim feature, also CTRL_TRIM command should be implemented to the
/ disk_ioctl() function. */

View File

@ -244,6 +244,15 @@ DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff)
case GET_BLOCK_SIZE:
*((DWORD*)buff) = 1; // default when not known
return RES_OK;
case CTRL_TRIM:
if (_ffs[pdrv] == NULL) {
return RES_NOTRDY;
} else {
DWORD *sectors = (DWORD*)buff;
DWORD ssize = disk_get_sector_size(pdrv);
int err = _ffs[pdrv]->trim(sectors[0]*ssize, (sectors[1]-sectors[0]+1)*ssize);
return err ? RES_PARERR : RES_OK;
}
}
return RES_PARERR;