scsi: libsas: Fix declaration of ncq priority attributes
authorDamien Le Moal <dlemoal@kernel.org>
Wed, 27 Mar 2024 02:01:22 +0000 (11:01 +0900)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 28 Mar 2024 00:13:52 +0000 (20:13 -0400)
Commit b4d3ddd2df75 ("scsi: libsas: Define NCQ Priority sysfs attributes
for SATA devices") introduced support for ATA NCQ priority control for ATA
devices managed by libsas. This commit introduces the ncq_prio_supported
and ncq_prio_enable sysfs device attributes to discover and control the use
of this features, similarly to libata.  However, libata publicly declares
these device attributes and export them for use in ATA low level
drivers. This leads to a compilation error when libsas and libata are
built-in due to the double definition:

ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:900:
multiple definition of `dev_attr_ncq_prio_supported';
drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:984:
first defined here
ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:1026:
multiple definition of `dev_attr_ncq_prio_enable';
drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:1022:
first defined here

Resolve this problem by directly declaring the libsas attributes instead of
using the DEVICE_ATTR() macro. And for good measure, the device attribute
variables are also renamed.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Fixes: b4d3ddd2df75 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices")
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20240327020122.439424-1-dlemoal@kernel.org
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/libsas/sas_ata.c

index b57c041a554419d97617564f50d2c2af1a0780be..4c69fc63c119669310fbaef8b97268b75cf90e12 100644 (file)
@@ -981,7 +981,8 @@ static ssize_t sas_ncq_prio_supported_show(struct device *device,
        return sysfs_emit(buf, "%d\n", supported);
 }
 
-DEVICE_ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL);
+static struct device_attribute dev_attr_sas_ncq_prio_supported =
+       __ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL);
 
 static ssize_t sas_ncq_prio_enable_show(struct device *device,
                                        struct device_attribute *attr,
@@ -1019,12 +1020,13 @@ static ssize_t sas_ncq_prio_enable_store(struct device *device,
        return len;
 }
 
-DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
-           sas_ncq_prio_enable_show, sas_ncq_prio_enable_store);
+static struct device_attribute dev_attr_sas_ncq_prio_enable =
+       __ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
+              sas_ncq_prio_enable_show, sas_ncq_prio_enable_store);
 
 static struct attribute *sas_ata_sdev_attrs[] = {
-       &dev_attr_ncq_prio_supported.attr,
-       &dev_attr_ncq_prio_enable.attr,
+       &dev_attr_sas_ncq_prio_supported.attr,
+       &dev_attr_sas_ncq_prio_enable.attr,
        NULL
 };