Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: ata: Switch to attribute groups

struct device supports attribute groups directly but does not support
struct device_attribute directly. Hence switch to attribute groups.

Link: https://lore.kernel.org/r/20211012233558.4066756-3-bvanassche@acm.org
Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
c3f69c7f 92c4b58b

+79 -41
+4 -4
drivers/ata/ahci.h
··· 376 376 377 377 extern int ahci_ignore_sss; 378 378 379 - extern struct device_attribute *ahci_shost_attrs[]; 380 - extern struct device_attribute *ahci_sdev_attrs[]; 379 + extern const struct attribute_group *ahci_shost_groups[]; 380 + extern const struct attribute_group *ahci_sdev_groups[]; 381 381 382 382 /* 383 383 * This must be instantiated by the edge drivers. Read the comments ··· 388 388 .can_queue = AHCI_MAX_CMDS, \ 389 389 .sg_tablesize = AHCI_MAX_SG, \ 390 390 .dma_boundary = AHCI_DMA_BOUNDARY, \ 391 - .shost_attrs = ahci_shost_attrs, \ 392 - .sdev_attrs = ahci_sdev_attrs, \ 391 + .shost_groups = ahci_shost_groups, \ 392 + .sdev_groups = ahci_sdev_groups, \ 393 393 .change_queue_depth = ata_scsi_change_queue_depth, \ 394 394 .tag_alloc_policy = BLK_TAG_ALLOC_RR, \ 395 395 .slave_configure = ata_scsi_slave_config
+5 -3
drivers/ata/ata_piix.c
··· 1085 1085 .set_dmamode = ich_set_dmamode, 1086 1086 }; 1087 1087 1088 - static struct device_attribute *piix_sidpr_shost_attrs[] = { 1089 - &dev_attr_link_power_management_policy, 1088 + static struct attribute *piix_sidpr_shost_attrs[] = { 1089 + &dev_attr_link_power_management_policy.attr, 1090 1090 NULL 1091 1091 }; 1092 1092 1093 + ATTRIBUTE_GROUPS(piix_sidpr_shost); 1094 + 1093 1095 static struct scsi_host_template piix_sidpr_sht = { 1094 1096 ATA_BMDMA_SHT(DRV_NAME), 1095 - .shost_attrs = piix_sidpr_shost_attrs, 1097 + .shost_groups = piix_sidpr_shost_groups, 1096 1098 }; 1097 1099 1098 1100 static struct ata_port_operations piix_sidpr_sata_ops = {
+35 -17
drivers/ata/libahci.c
··· 108 108 ahci_read_em_buffer, ahci_store_em_buffer); 109 109 static DEVICE_ATTR(em_message_supported, S_IRUGO, ahci_show_em_supported, NULL); 110 110 111 - struct device_attribute *ahci_shost_attrs[] = { 112 - &dev_attr_link_power_management_policy, 113 - &dev_attr_em_message_type, 114 - &dev_attr_em_message, 115 - &dev_attr_ahci_host_caps, 116 - &dev_attr_ahci_host_cap2, 117 - &dev_attr_ahci_host_version, 118 - &dev_attr_ahci_port_cmd, 119 - &dev_attr_em_buffer, 120 - &dev_attr_em_message_supported, 111 + static struct attribute *ahci_shost_attrs[] = { 112 + &dev_attr_link_power_management_policy.attr, 113 + &dev_attr_em_message_type.attr, 114 + &dev_attr_em_message.attr, 115 + &dev_attr_ahci_host_caps.attr, 116 + &dev_attr_ahci_host_cap2.attr, 117 + &dev_attr_ahci_host_version.attr, 118 + &dev_attr_ahci_port_cmd.attr, 119 + &dev_attr_em_buffer.attr, 120 + &dev_attr_em_message_supported.attr, 121 121 NULL 122 122 }; 123 - EXPORT_SYMBOL_GPL(ahci_shost_attrs); 124 123 125 - struct device_attribute *ahci_sdev_attrs[] = { 126 - &dev_attr_sw_activity, 127 - &dev_attr_unload_heads, 128 - &dev_attr_ncq_prio_supported, 129 - &dev_attr_ncq_prio_enable, 124 + static const struct attribute_group ahci_shost_attr_group = { 125 + .attrs = ahci_shost_attrs 126 + }; 127 + 128 + const struct attribute_group *ahci_shost_groups[] = { 129 + &ahci_shost_attr_group, 130 130 NULL 131 131 }; 132 - EXPORT_SYMBOL_GPL(ahci_sdev_attrs); 132 + EXPORT_SYMBOL_GPL(ahci_shost_groups); 133 + 134 + struct attribute *ahci_sdev_attrs[] = { 135 + &dev_attr_sw_activity.attr, 136 + &dev_attr_unload_heads.attr, 137 + &dev_attr_ncq_prio_supported.attr, 138 + &dev_attr_ncq_prio_enable.attr, 139 + NULL 140 + }; 141 + 142 + static const struct attribute_group ahci_sdev_attr_group = { 143 + .attrs = ahci_sdev_attrs 144 + }; 145 + 146 + const struct attribute_group *ahci_sdev_groups[] = { 147 + &ahci_sdev_attr_group, 148 + NULL 149 + }; 150 + EXPORT_SYMBOL_GPL(ahci_sdev_groups); 133 151 134 152 struct ata_port_operations ahci_ops = { 135 153 .inherits = &sata_pmp_port_ops,
+14 -5
drivers/ata/libata-sata.c
··· 922 922 ata_ncq_prio_enable_show, ata_ncq_prio_enable_store); 923 923 EXPORT_SYMBOL_GPL(dev_attr_ncq_prio_enable); 924 924 925 - struct device_attribute *ata_ncq_sdev_attrs[] = { 926 - &dev_attr_unload_heads, 927 - &dev_attr_ncq_prio_enable, 928 - &dev_attr_ncq_prio_supported, 925 + struct attribute *ata_ncq_sdev_attrs[] = { 926 + &dev_attr_unload_heads.attr, 927 + &dev_attr_ncq_prio_enable.attr, 928 + &dev_attr_ncq_prio_supported.attr, 929 929 NULL 930 930 }; 931 - EXPORT_SYMBOL_GPL(ata_ncq_sdev_attrs); 931 + 932 + static const struct attribute_group ata_ncq_sdev_attr_group = { 933 + .attrs = ata_ncq_sdev_attrs 934 + }; 935 + 936 + const struct attribute_group *ata_ncq_sdev_groups[] = { 937 + &ata_ncq_sdev_attr_group, 938 + NULL 939 + }; 940 + EXPORT_SYMBOL_GPL(ata_ncq_sdev_groups); 932 941 933 942 static ssize_t 934 943 ata_scsi_em_message_store(struct device *dev, struct device_attribute *attr,
+12 -3
drivers/ata/libata-scsi.c
··· 234 234 field, 0xff, 0); 235 235 } 236 236 237 - struct device_attribute *ata_common_sdev_attrs[] = { 238 - &dev_attr_unload_heads, 237 + static struct attribute *ata_common_sdev_attrs[] = { 238 + &dev_attr_unload_heads.attr, 239 239 NULL 240 240 }; 241 - EXPORT_SYMBOL_GPL(ata_common_sdev_attrs); 241 + 242 + static const struct attribute_group ata_common_sdev_attr_group = { 243 + .attrs = ata_common_sdev_attrs 244 + }; 245 + 246 + const struct attribute_group *ata_common_sdev_groups[] = { 247 + &ata_common_sdev_attr_group, 248 + NULL 249 + }; 250 + EXPORT_SYMBOL_GPL(ata_common_sdev_groups); 242 251 243 252 /** 244 253 * ata_std_bios_param - generic bios head/sector/cylinder calculator used by sd.
+1 -1
drivers/ata/pata_macio.c
··· 923 923 */ 924 924 .max_segment_size = MAX_DBDMA_SEG, 925 925 .slave_configure = pata_macio_slave_config, 926 - .sdev_attrs = ata_common_sdev_attrs, 926 + .sdev_groups = ata_common_sdev_groups, 927 927 .can_queue = ATA_DEF_QUEUE, 928 928 .tag_alloc_policy = BLK_TAG_ALLOC_RR, 929 929 };
+1 -1
drivers/ata/sata_mv.c
··· 670 670 .can_queue = MV_MAX_Q_DEPTH - 1, 671 671 .sg_tablesize = MV_MAX_SG_CT / 2, 672 672 .dma_boundary = MV_DMA_BOUNDARY, 673 - .sdev_attrs = ata_ncq_sdev_attrs, 673 + .sdev_groups = ata_ncq_sdev_groups, 674 674 .change_queue_depth = ata_scsi_change_queue_depth, 675 675 .tag_alloc_policy = BLK_TAG_ALLOC_RR, 676 676 .slave_configure = ata_scsi_slave_config
+2 -2
drivers/ata/sata_nv.c
··· 380 380 .sg_tablesize = NV_ADMA_SGTBL_TOTAL_LEN, 381 381 .dma_boundary = NV_ADMA_DMA_BOUNDARY, 382 382 .slave_configure = nv_adma_slave_config, 383 - .sdev_attrs = ata_ncq_sdev_attrs, 383 + .sdev_groups = ata_ncq_sdev_groups, 384 384 .change_queue_depth = ata_scsi_change_queue_depth, 385 385 .tag_alloc_policy = BLK_TAG_ALLOC_RR, 386 386 }; ··· 391 391 .sg_tablesize = LIBATA_MAX_PRD, 392 392 .dma_boundary = ATA_DMA_BOUNDARY, 393 393 .slave_configure = nv_swncq_slave_config, 394 - .sdev_attrs = ata_ncq_sdev_attrs, 394 + .sdev_groups = ata_ncq_sdev_groups, 395 395 .change_queue_depth = ata_scsi_change_queue_depth, 396 396 .tag_alloc_policy = BLK_TAG_ALLOC_RR, 397 397 };
+1 -1
drivers/ata/sata_sil24.c
··· 379 379 .sg_tablesize = SIL24_MAX_SGE, 380 380 .dma_boundary = ATA_DMA_BOUNDARY, 381 381 .tag_alloc_policy = BLK_TAG_ALLOC_FIFO, 382 - .sdev_attrs = ata_ncq_sdev_attrs, 382 + .sdev_groups = ata_ncq_sdev_groups, 383 383 .change_queue_depth = ata_scsi_change_queue_depth, 384 384 .slave_configure = ata_scsi_slave_config 385 385 };
+4 -4
include/linux/libata.h
··· 1388 1388 */ 1389 1389 extern const struct ata_port_operations ata_base_port_ops; 1390 1390 extern const struct ata_port_operations sata_port_ops; 1391 - extern struct device_attribute *ata_common_sdev_attrs[]; 1391 + extern const struct attribute_group *ata_common_sdev_groups[]; 1392 1392 1393 1393 /* 1394 1394 * All sht initializers (BASE, PIO, BMDMA, NCQ) must be instantiated ··· 1418 1418 1419 1419 #define ATA_BASE_SHT(drv_name) \ 1420 1420 ATA_SUBBASE_SHT(drv_name), \ 1421 - .sdev_attrs = ata_common_sdev_attrs 1421 + .sdev_groups = ata_common_sdev_groups 1422 1422 1423 1423 #ifdef CONFIG_SATA_HOST 1424 - extern struct device_attribute *ata_ncq_sdev_attrs[]; 1424 + extern const struct attribute_group *ata_ncq_sdev_groups[]; 1425 1425 1426 1426 #define ATA_NCQ_SHT(drv_name) \ 1427 1427 ATA_SUBBASE_SHT(drv_name), \ 1428 - .sdev_attrs = ata_ncq_sdev_attrs, \ 1428 + .sdev_groups = ata_ncq_sdev_groups, \ 1429 1429 .change_queue_depth = ata_scsi_change_queue_depth 1430 1430 #endif 1431 1431