mirror of https://github.com/ARMmbed/mbed-os.git
fatfs: Adopted the trim function in the FAT filesystem
parent
6e1b9e153c
commit
ee88097cb6
|
@ -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. */
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue