mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
libata: Expose TRIM capability in sysfs
Create a sysfs "trim" attribute for each ata_device that displays whether DSM TRIM is "unsupported", "unqueued", "forced_unqueued" (blacklisted) or "queued". Signed-off-by: Martin K. Petersen <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
This commit is contained in:
parent
d7b16e4f62
commit
f303074160
2 changed files with 33 additions and 0 deletions
|
|
@ -560,6 +560,27 @@ show_ata_dev_gscr(struct device *dev,
|
|||
|
||||
static DEVICE_ATTR(gscr, S_IRUGO, show_ata_dev_gscr, NULL);
|
||||
|
||||
static ssize_t
|
||||
show_ata_dev_trim(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct ata_device *ata_dev = transport_class_to_dev(dev);
|
||||
unsigned char *mode;
|
||||
|
||||
if (!ata_id_has_trim(ata_dev->id))
|
||||
mode = "unsupported";
|
||||
else if (ata_dev->horkage & ATA_HORKAGE_NO_NCQ_TRIM)
|
||||
mode = "forced_unqueued";
|
||||
else if (ata_fpdma_dsm_supported(ata_dev))
|
||||
mode = "queued";
|
||||
else
|
||||
mode = "unqueued";
|
||||
|
||||
return snprintf(buf, 20, "%s\n", mode);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(trim, S_IRUGO, show_ata_dev_trim, NULL);
|
||||
|
||||
static DECLARE_TRANSPORT_CLASS(ata_dev_class,
|
||||
"ata_device", NULL, NULL, NULL);
|
||||
|
||||
|
|
@ -733,6 +754,7 @@ struct scsi_transport_template *ata_attach_transport(void)
|
|||
SETUP_DEV_ATTRIBUTE(ering);
|
||||
SETUP_DEV_ATTRIBUTE(id);
|
||||
SETUP_DEV_ATTRIBUTE(gscr);
|
||||
SETUP_DEV_ATTRIBUTE(trim);
|
||||
BUG_ON(count > ATA_DEV_ATTRS);
|
||||
i->dev_attrs[count] = NULL;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue