[PATCH v2 18/46] scsi: cxlflash: Switch to attribute groups

Bart Van Assche
2021-10-07T21:19:52Z

drivers/scsi/cxlflash/main.c | 54 ++++++++++++++++++++++++------------
1 file changed, 36 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index b2730e859df8..c11ed8f1fc71 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -3103,20 +3103,29 @@ static DEVICE_ATTR_RW(irqpoll_weight);
static DEVICE_ATTR_RW(num_hwqs);
static DEVICE_ATTR_RW(hwq_mode);

-static struct device_attribute *cxlflash_host_attrs[] = {
- &dev_attr_port0,
- &dev_attr_port1,
- &dev_attr_port2,
- &dev_attr_port3,
- &dev_attr_lun_mode,
- &dev_attr_ioctl_version,
- &dev_attr_port0_lun_table,
- &dev_attr_port1_lun_table,
- &dev_attr_port2_lun_table,
- &dev_attr_port3_lun_table,
- &dev_attr_irqpoll_weight,
- &dev_attr_num_hwqs,
- &dev_attr_hwq_mode,
+static struct attribute *cxlflash_host_attrs[] = {
+ &dev_attr_port0.attr,
+ &dev_attr_port1.attr,
+ &dev_attr_port2.attr,
+ &dev_attr_port3.attr,
+ &dev_attr_lun_mode.attr,
+ &dev_attr_ioctl_version.attr,
+ &dev_attr_port0_lun_table.attr,
+ &dev_attr_port1_lun_table.attr,
+ &dev_attr_port2_lun_table.attr,
+ &dev_attr_port3_lun_table.attr,
+ &dev_attr_irqpoll_weight.attr,
+ &dev_attr_num_hwqs.attr,
+ &dev_attr_hwq_mode.attr,
+ NULL
+};
+
+static const struct attribute_group cxlflash_host_attr_group = {
+ .attrs = cxlflash_host_attrs
+};
+
+static const struct attribute_group *cxlflash_host_attr_groups[] = {
+ &cxlflash_host_attr_group,
NULL
};

@@ -3125,8 +3134,17 @@ static struct device_attribute *cxlflash_host_attrs[] = {
*/
static DEVICE_ATTR_RO(mode);

-static struct device_attribute *cxlflash_dev_attrs[] = {
- &dev_attr_mode,
+static struct attribute *cxlflash_dev_attrs[] = {
+ &dev_attr_mode.attr,
+ NULL
+};
+
+static const struct attribute_group cxlflash_dev_attr_group = {
+ .attrs = cxlflash_dev_attrs
+};
+
+static const struct attribute_group *cxlflash_dev_attr_groups[] = {
+ &cxlflash_dev_attr_group,
NULL
};

@@ -3150,8 +3168,8 @@ static struct scsi_host_template driver_template = {
.this_id = -1,
.sg_tablesize = 1, /* No scatter gather support */
.max_sectors = CXLFLASH_MAX_SECTORS,
- .shost_attrs = cxlflash_host_attrs,
- .sdev_attrs = cxlflash_dev_attrs,
+ .shost_groups = cxlflash_host_attr_groups,
+ .sdev_groups = cxlflash_dev_attr_groups,
};

/*