Skip to content

Commit

Permalink
ata: expose ncq_enable_prio sysfs attribute only on NCQ capable hosts
Browse files Browse the repository at this point in the history
There is no point in exposing ncq_enable_prio sysfs attribute for
devices on PATA and non-NCQ capable SATA hosts so:

* remove dev_attr_ncq_prio_enable from ata_common_sdev_attrs[]

* add ata_ncq_sdev_attrs[]

* update ATA_NCQ_SHT() macro to use ata_ncq_sdev_attrs[]

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Bartlomiej Zolnierkiewicz authored and Jens Axboe committed Mar 26, 2020
1 parent 3e1ee73 commit 6f09eae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 7 additions & 1 deletion drivers/ata/libata-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,11 +463,17 @@ EXPORT_SYMBOL_GPL(dev_attr_sw_activity);

struct device_attribute *ata_common_sdev_attrs[] = {
&dev_attr_unload_heads,
&dev_attr_ncq_prio_enable,
NULL
};
EXPORT_SYMBOL_GPL(ata_common_sdev_attrs);

struct device_attribute *ata_ncq_sdev_attrs[] = {
&dev_attr_unload_heads,
&dev_attr_ncq_prio_enable,
NULL
};
EXPORT_SYMBOL_GPL(ata_ncq_sdev_attrs);

/**
* ata_std_bios_param - generic bios head/sector/cylinder calculator used by sd.
* @sdev: SCSI device for which BIOS geometry is to be determined
Expand Down
11 changes: 8 additions & 3 deletions include/linux/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1334,14 +1334,15 @@ extern int ata_link_nr_enabled(struct ata_link *link);
extern const struct ata_port_operations ata_base_port_ops;
extern const struct ata_port_operations sata_port_ops;
extern struct device_attribute *ata_common_sdev_attrs[];
extern struct device_attribute *ata_ncq_sdev_attrs[];

/*
* All sht initializers (BASE, PIO, BMDMA, NCQ) must be instantiated
* by the edge drivers. Because the 'module' field of sht must be the
* edge driver's module reference, otherwise the driver can be unloaded
* even if the scsi_device is being accessed.
*/
#define ATA_BASE_SHT(drv_name) \
#define __ATA_BASE_SHT(drv_name) \
.module = THIS_MODULE, \
.name = drv_name, \
.ioctl = ata_scsi_ioctl, \
Expand All @@ -1355,11 +1356,15 @@ extern struct device_attribute *ata_common_sdev_attrs[];
.slave_configure = ata_scsi_slave_config, \
.slave_destroy = ata_scsi_slave_destroy, \
.bios_param = ata_std_bios_param, \
.unlock_native_capacity = ata_scsi_unlock_native_capacity, \
.unlock_native_capacity = ata_scsi_unlock_native_capacity

#define ATA_BASE_SHT(drv_name) \
__ATA_BASE_SHT(drv_name), \
.sdev_attrs = ata_common_sdev_attrs

#define ATA_NCQ_SHT(drv_name) \
ATA_BASE_SHT(drv_name), \
__ATA_BASE_SHT(drv_name), \
.sdev_attrs = ata_ncq_sdev_attrs, \
.change_queue_depth = ata_scsi_change_queue_depth

/*
Expand Down

0 comments on commit 6f09eae

Please sign in to comment.