All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/46] Register SCSI sysfs attributes earlier
@ 2021-10-08 20:23 Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 01/46] scsi: core: Register " Bart Van Assche
                   ` (45 more replies)
  0 siblings, 46 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, Bart Van Assche

Hi Martin,

For certain user space software, e.g. udev, it is important that sysfs
attributes are registered before the KOBJ_ADD uevent is emitted. Hence
this patch series that removes the device_create_file() and
sysfs_create_groups() calls from the SCSI core. Please consider this
patch series for kernel v5.16.

Thanks,

Bart.

Changes compared to v2:
- Use the ATTRIBUTE_GROUPS() macro where appropriate.

Changes compared to v1:
- Switched from struct attribute ** to struct attribute_group **.
- Added comments that explain how the size of the new arrays have been chosen.
- Cleaned up the code in the qla2xxx driver that modifies a struct
  device_attribute array by introducing an .is_visible() callback.
- Split this patch series into one patch per driver.

Bart Van Assche (46):
  scsi: core: Register sysfs attributes earlier
  ata: Switch to attribute groups
  firewire: sbp2: Switch to attribute groups
  RDMA/srp: Switch to attribute groups
  scsi: message: fusion: Switch to attribute groups
  scsi: zfcp: Switch to attribute groups
  scsi: 3w-9xxx: Switch to attribute groups
  scsi: 3w-sas: Switch to attribute groups
  scsi: 3w-xxxx: Switch to attribute groups
  scsi: 53c700: Switch to attribute groups
  scsi: aacraid: Switch to attribute groups
  scsi: arcmsr: Switch to attribute groups
  scsi: be2iscsi: Switch to attribute groups
  scsi: bfa: Switch to attribute groups
  scsi: bnx2fc: Switch to attribute groups
  scsi: bnx2i: Switch to attribute groups
  scsi: csiostor: Switch to attribute groups
  scsi: cxlflash: Switch to attribute groups
  scsi: fnic: Switch to attribute groups
  scsi: hisi_sas: Switch to attribute groups
  scsi: hpsa: Switch to attribute groups
  scsi: hptiop: Switch to attribute groups
  scsi: ibmvscsi: Switch to attribute groups
  scsi: ibmvfc: Switch to attribute groups
  scsi: ipr: Switch to attribute groups
  scsi: isci: Switch to attribute groups
  scsi: lpfc: Switch to attribute groups
  scsi: megaraid: Switch to attribute groups
  scsi: mpt3sas: Switch to attribute groups
  scsi: mvsas: Switch to attribute groups
  scsi: myrb: Switch to attribute groups
  scsi: myrs: Switch to attribute groups
  scsi: ncr53c8xx: Switch to attribute groups
  scsi: sym53c500_cs: Switch to attribute groups
  scsi: pm8001: Switch to attribute groups
  scsi: pmcraid: Switch to attribute groups
  scsi: qedf: Switch to attribute groups
  scsi: qedi: Switch to attribute groups
  scsi: qla2xxx: Remove a declaration
  scsi: qla2xxx: Switch to attribute groups
  scsi: qla4xxx: Switch to attribute groups
  scsi: smartpqi: Switch to attribute groups
  scsi: snic: Switch to attribute groups
  scsi: unisys: Remove the shost_attrs member
  scsi: usb: Switch to attribute groups
  scsi: core: Remove two host template members that are no longer used

 drivers/ata/ahci.h                            |   8 +-
 drivers/ata/ata_piix.c                        |   8 +-
 drivers/ata/libahci.c                         |  52 ++-
 drivers/ata/libata-sata.c                     |  19 +-
 drivers/ata/libata-scsi.c                     |  15 +-
 drivers/ata/pata_macio.c                      |   2 +-
 drivers/ata/sata_mv.c                         |   2 +-
 drivers/ata/sata_nv.c                         |   4 +-
 drivers/ata/sata_sil24.c                      |   2 +-
 drivers/firewire/sbp2.c                       |   8 +-
 drivers/infiniband/ulp/srp/ib_srp.c           |  51 +--
 drivers/message/fusion/mptfc.c                |   2 +-
 drivers/message/fusion/mptsas.c               |   2 +-
 drivers/message/fusion/mptscsih.c             |  36 +-
 drivers/message/fusion/mptscsih.h             |   2 +-
 drivers/message/fusion/mptspi.c               |   2 +-
 drivers/s390/scsi/zfcp_ext.h                  |   4 +-
 drivers/s390/scsi/zfcp_scsi.c                 |   4 +-
 drivers/s390/scsi/zfcp_sysfs.c                |  52 ++-
 drivers/scsi/3w-9xxx.c                        |   8 +-
 drivers/scsi/3w-sas.c                         |   8 +-
 drivers/scsi/3w-xxxx.c                        |   8 +-
 drivers/scsi/53c700.c                         |  12 +-
 drivers/scsi/aacraid/linit.c                  |  38 ++-
 drivers/scsi/arcmsr/arcmsr.h                  |   2 +-
 drivers/scsi/arcmsr/arcmsr_attr.c             |  33 +-
 drivers/scsi/arcmsr/arcmsr_hba.c              |   2 +-
 drivers/scsi/be2iscsi/be_main.c               |  21 +-
 drivers/scsi/bfa/bfad_attr.c                  |  68 ++--
 drivers/scsi/bfa/bfad_im.c                    |   4 +-
 drivers/scsi/bfa/bfad_im.h                    |   4 +-
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c             |   8 +-
 drivers/scsi/bnx2i/bnx2i.h                    |   2 +-
 drivers/scsi/bnx2i/bnx2i_iscsi.c              |   2 +-
 drivers/scsi/bnx2i/bnx2i_sysfs.c              |  15 +-
 drivers/scsi/csiostor/csio_scsi.c             |  24 +-
 drivers/scsi/cxlflash/main.c                  |  40 ++-
 drivers/scsi/fnic/fnic.h                      |   2 +-
 drivers/scsi/fnic/fnic_attrs.c                |  17 +-
 drivers/scsi/fnic/fnic_main.c                 |   2 +-
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c        |   8 +-
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c        |   8 +-
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c        |  14 +-
 drivers/scsi/hosts.c                          |  14 +-
 drivers/scsi/hpsa.c                           |  44 +--
 drivers/scsi/hptiop.c                         |  10 +-
 drivers/scsi/ibmvscsi/ibmvfc.c                |  22 +-
 drivers/scsi/ibmvscsi/ibmvscsi.c              |  22 +-
 drivers/scsi/ipr.c                            |  38 ++-
 drivers/scsi/isci/init.c                      |   8 +-
 drivers/scsi/lpfc/lpfc_attr.c                 | 314 +++++++++---------
 drivers/scsi/lpfc/lpfc_crtn.h                 |   4 +-
 drivers/scsi/lpfc/lpfc_init.c                 |   2 +-
 drivers/scsi/lpfc/lpfc_scsi.c                 |   4 +-
 drivers/scsi/megaraid/megaraid_mbox.c         |  15 +-
 drivers/scsi/megaraid/megaraid_sas_base.c     |  24 +-
 drivers/scsi/mpt3sas/mpt3sas_base.h           |   4 +-
 drivers/scsi/mpt3sas/mpt3sas_ctl.c            |  84 +++--
 drivers/scsi/mpt3sas/mpt3sas_scsih.c          |   8 +-
 drivers/scsi/mvsas/mv_init.c                  |  12 +-
 drivers/scsi/myrb.c                           |  28 +-
 drivers/scsi/myrs.c                           |  40 ++-
 drivers/scsi/ncr53c8xx.c                      |  10 +-
 drivers/scsi/pcmcia/sym53c500_cs.c            |   8 +-
 drivers/scsi/pm8001/pm8001_ctl.c              |  64 ++--
 drivers/scsi/pm8001/pm8001_init.c             |   2 +-
 drivers/scsi/pm8001/pm8001_sas.h              |   2 +-
 drivers/scsi/pmcraid.c                        |  11 +-
 drivers/scsi/qedf/qedf.h                      |   2 +-
 drivers/scsi/qedf/qedf_attr.c                 |  15 +-
 drivers/scsi/qedf/qedf_main.c                 |   2 +-
 drivers/scsi/qedi/qedi_gbl.h                  |   2 +-
 drivers/scsi/qedi/qedi_iscsi.c                |   2 +-
 drivers/scsi/qedi/qedi_sysfs.c                |  15 +-
 drivers/scsi/qla2xxx/qla_attr.c               | 118 +++----
 drivers/scsi/qla2xxx/qla_gbl.h                |   4 +-
 drivers/scsi/qla2xxx/qla_os.c                 |   5 +-
 drivers/scsi/qla4xxx/ql4_attr.c               |  41 ++-
 drivers/scsi/qla4xxx/ql4_glbl.h               |   3 +-
 drivers/scsi/qla4xxx/ql4_os.c                 |   2 +-
 drivers/scsi/scsi_priv.h                      |   2 +-
 drivers/scsi/scsi_sysfs.c                     |  53 +--
 drivers/scsi/smartpqi/smartpqi_init.c         |  46 +--
 drivers/scsi/snic/snic.h                      |   2 +-
 drivers/scsi/snic/snic_attrs.c                |  19 +-
 drivers/scsi/snic/snic_main.c                 |   2 +-
 .../staging/unisys/visorhba/visorhba_main.c   |   1 -
 drivers/usb/storage/scsiglue.c                |   8 +-
 include/linux/libata.h                        |   8 +-
 include/scsi/scsi_device.h                    |   6 +
 include/scsi/scsi_host.h                      |  15 +-
 91 files changed, 1025 insertions(+), 767 deletions(-)


^ permalink raw reply	[flat|nested] 57+ messages in thread

* [PATCH v3 01/46] scsi: core: Register sysfs attributes earlier
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
       [not found]   ` <YWQ3mHOZ+881X+j1@t480-pf1aa2c2.linux.ibm.com>
  2021-10-11 13:37   ` Benjamin Block
  2021-10-08 20:23 ` [PATCH v3 02/46] ata: Switch to attribute groups Bart Van Assche
                   ` (44 subsequent siblings)
  45 siblings, 2 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Greg Kroah-Hartman, James E.J. Bottomley

A quote from Documentation/driver-api/driver-model/device.rst:
"Word of warning:  While the kernel allows device_create_file() and
device_remove_file() to be called on a device at any time, userspace has
strict expectations on when attributes get created.  When a new device is
registered in the kernel, a uevent is generated to notify userspace (like
udev) that a new device is available.  If attributes are added after the
device is registered, then userspace won't get notified and userspace will
not know about the new attributes."

Hence register SCSI host sysfs attributes before the SCSI host shost_dev
uevent is emitted instead of after that event has been emitted.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/hosts.c       | 23 ++++++++++-
 drivers/scsi/scsi_priv.h   |  4 +-
 drivers/scsi/scsi_sysfs.c  | 81 +++++++++++++++++++-------------------
 include/scsi/scsi_device.h |  7 ++++
 include/scsi/scsi_host.h   | 12 ++++++
 5 files changed, 84 insertions(+), 43 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 3f6f14f0cafb..3443f009a9e8 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -376,7 +376,7 @@ static struct device_type scsi_host_type = {
 struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
 {
 	struct Scsi_Host *shost;
-	int index;
+	int index, i, j = 0;
 
 	shost = kzalloc(sizeof(struct Scsi_Host) + privsize, GFP_KERNEL);
 	if (!shost)
@@ -480,7 +480,26 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
 	shost->shost_dev.parent = &shost->shost_gendev;
 	shost->shost_dev.class = &shost_class;
 	dev_set_name(&shost->shost_dev, "host%d", shost->host_no);
-	shost->shost_dev.groups = scsi_sysfs_shost_attr_groups;
+	shost->shost_dev.groups = shost->shost_dev_attr_groups;
+	shost->shost_dev_attr_groups[j++] = &scsi_shost_attr_group;
+	if (sht->shost_attrs) {
+		shost->lld_attr_group = (struct attribute_group){
+			.attrs = scsi_convert_dev_attrs(&shost->shost_gendev,
+							sht->shost_attrs)
+		};
+		if (shost->lld_attr_group.attrs)
+			shost->shost_dev_attr_groups[j++] =
+				&shost->lld_attr_group;
+	}
+	if (sht->shost_groups) {
+		for (i = 0; sht->shost_groups[i] &&
+			     j < ARRAY_SIZE(shost->shost_dev_attr_groups);
+		     i++, j++) {
+			shost->shost_dev_attr_groups[j] =
+				sht->shost_groups[i];
+		}
+	}
+	WARN_ON_ONCE(j >= ARRAY_SIZE(shost->shost_dev_attr_groups));
 
 	shost->ehandler = kthread_run(scsi_error_handler, shost,
 			"scsi_eh_%d", shost->host_no);
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 6d9152031a40..a5a2f18cc734 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -137,13 +137,15 @@ extern int scsi_sysfs_add_sdev(struct scsi_device *);
 extern int scsi_sysfs_add_host(struct Scsi_Host *);
 extern int scsi_sysfs_register(void);
 extern void scsi_sysfs_unregister(void);
+struct attribute **scsi_convert_dev_attrs(struct device *dev,
+					  struct device_attribute **dev_attr);
 extern void scsi_sysfs_device_initialize(struct scsi_device *);
 extern int scsi_sysfs_target_initialize(struct scsi_device *);
 extern struct scsi_transport_template blank_transport_template;
 extern void __scsi_remove_device(struct scsi_device *);
 
 extern struct bus_type scsi_bus_type;
-extern const struct attribute_group *scsi_sysfs_shost_attr_groups[];
+extern const struct attribute_group scsi_shost_attr_group;
 
 /* scsi_netlink.c */
 #ifdef CONFIG_SCSI_NETLINK
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 86793259e541..05b4d69d53d4 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -424,15 +424,10 @@ static struct attribute *scsi_sysfs_shost_attrs[] = {
 	NULL
 };
 
-static struct attribute_group scsi_shost_attr_group = {
+const struct attribute_group scsi_shost_attr_group = {
 	.attrs =	scsi_sysfs_shost_attrs,
 };
 
-const struct attribute_group *scsi_sysfs_shost_attr_groups[] = {
-	&scsi_shost_attr_group,
-	NULL
-};
-
 static void scsi_device_cls_release(struct device *class_dev)
 {
 	struct scsi_device *sdev;
@@ -1333,7 +1328,7 @@ static int scsi_target_add(struct scsi_target *starget)
  **/
 int scsi_sysfs_add_sdev(struct scsi_device *sdev)
 {
-	int error, i;
+	int error;
 	struct scsi_target *starget = sdev->sdev_target;
 
 	error = scsi_target_add(starget);
@@ -1386,23 +1381,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
 		}
 	}
 
-	/* add additional host specific attributes */
-	if (sdev->host->hostt->sdev_attrs) {
-		for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) {
-			error = device_create_file(&sdev->sdev_gendev,
-					sdev->host->hostt->sdev_attrs[i]);
-			if (error)
-				return error;
-		}
-	}
-
-	if (sdev->host->hostt->sdev_groups) {
-		error = sysfs_create_groups(&sdev->sdev_gendev.kobj,
-				sdev->host->hostt->sdev_groups);
-		if (error)
-			return error;
-	}
-
 	scsi_autopm_put_device(sdev);
 	return error;
 }
@@ -1442,10 +1420,6 @@ void __scsi_remove_device(struct scsi_device *sdev)
 		if (res != 0)
 			return;
 
-		if (sdev->host->hostt->sdev_groups)
-			sysfs_remove_groups(&sdev->sdev_gendev.kobj,
-					sdev->host->hostt->sdev_groups);
-
 		if (IS_ENABLED(CONFIG_BLK_DEV_BSG) && sdev->bsg_dev)
 			bsg_unregister_queue(sdev->bsg_dev);
 		device_unregister(&sdev->sdev_dev);
@@ -1584,23 +1558,31 @@ EXPORT_SYMBOL(scsi_register_interface);
  **/
 int scsi_sysfs_add_host(struct Scsi_Host *shost)
 {
-	int error, i;
-
-	/* add host specific attributes */
-	if (shost->hostt->shost_attrs) {
-		for (i = 0; shost->hostt->shost_attrs[i]; i++) {
-			error = device_create_file(&shost->shost_dev,
-					shost->hostt->shost_attrs[i]);
-			if (error)
-				return error;
-		}
-	}
-
 	transport_register_device(&shost->shost_gendev);
 	transport_configure_device(&shost->shost_gendev);
 	return 0;
 }
 
+/*
+ * Convert an array of struct device_attribute pointers into an array of
+ * struct attribute pointers.
+ */
+struct attribute **scsi_convert_dev_attrs(struct device *dev,
+					  struct device_attribute **dev_attr)
+{
+	struct attribute **attrs;
+	int i;
+
+	for (i = 0; dev_attr[i]; i++)
+		;
+	attrs = devm_kzalloc(dev, (i + 1) * sizeof(*attrs), GFP_KERNEL);
+	if (!attrs)
+		return NULL;
+	for (i = 0; dev_attr[i]; i++)
+		attrs[i] = &dev_attr[i]->attr;
+	return attrs;
+}
+
 static struct device_type scsi_dev_type = {
 	.name =		"scsi_device",
 	.release =	scsi_device_dev_release,
@@ -1609,8 +1591,10 @@ static struct device_type scsi_dev_type = {
 
 void scsi_sysfs_device_initialize(struct scsi_device *sdev)
 {
+	int i, j = 0;
 	unsigned long flags;
 	struct Scsi_Host *shost = sdev->host;
+	struct scsi_host_template *hostt = shost->hostt;
 	struct scsi_target  *starget = sdev->sdev_target;
 
 	device_initialize(&sdev->sdev_gendev);
@@ -1618,6 +1602,23 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev)
 	sdev->sdev_gendev.type = &scsi_dev_type;
 	dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%llu",
 		     sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
+	sdev->gendev_attr_groups[j++] = &scsi_sdev_attr_group;
+	if (hostt->sdev_attrs) {
+		sdev->lld_attr_group = (struct attribute_group){
+			.attrs = scsi_convert_dev_attrs(&sdev->sdev_gendev,
+							hostt->sdev_attrs)
+		};
+		if (sdev->lld_attr_group.attrs)
+			sdev->gendev_attr_groups[j++] = &sdev->lld_attr_group;
+	}
+	if (hostt->sdev_groups) {
+		for (i = 0; hostt->sdev_groups[i] &&
+			     j < ARRAY_SIZE(sdev->gendev_attr_groups);
+		     i++, j++) {
+			sdev->gendev_attr_groups[j] = hostt->sdev_groups[i];
+		}
+	}
+	WARN_ON_ONCE(j >= ARRAY_SIZE(sdev->gendev_attr_groups));
 
 	device_initialize(&sdev->sdev_dev);
 	sdev->sdev_dev.parent = get_device(&sdev->sdev_gendev);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index b97e142a7ca9..01732aabd7c3 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -225,6 +225,13 @@ struct scsi_device {
 
 	struct device		sdev_gendev,
 				sdev_dev;
+	struct attribute_group	lld_attr_group;
+	/*
+	 * The array size 6 provides space for one attribute group for the
+	 * SCSI core, four attribute groups defined by SCSI LLDs and one
+	 * terminating NULL pointer.
+	 */
+	const struct attribute_group *gendev_attr_groups[6];
 
 	struct execute_work	ew; /* used to get process context on put */
 	struct work_struct	requeue_work;
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index bc9c45ced145..ab8775811e6f 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -483,6 +483,11 @@ struct scsi_host_template {
 	 */
 	struct device_attribute **sdev_attrs;
 
+	/*
+	 * Pointer to the SCSI host sysfs attribute groups, NULL terminated.
+	 */
+	const struct attribute_group **shost_groups;
+
 	/*
 	 * Pointer to the SCSI device attribute groups for this host,
 	 * NULL terminated.
@@ -695,6 +700,13 @@ struct Scsi_Host {
 
 	/* ldm bits */
 	struct device		shost_gendev, shost_dev;
+	struct attribute_group	lld_attr_group;
+	/*
+	 * The array size 3 provides space for one attribute group defined by
+	 * the SCSI core, one attribute group defined by the SCSI LLD and one
+	 * terminating NULL pointer.
+	 */
+	const struct attribute_group *shost_dev_attr_groups[3];
 
 	/*
 	 * Points to the transport data (if any) which is allocated

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 02/46] ata: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 01/46] scsi: core: Register " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-12  0:59   ` Damien Le Moal
  2021-10-08 20:23 ` [PATCH v3 03/46] firewire: sbp2: " Bart Van Assche
                   ` (43 subsequent siblings)
  45 siblings, 1 reply; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, Bart Van Assche, Damien Le Moal

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ata/ahci.h        |  8 +++---
 drivers/ata/ata_piix.c    |  8 +++---
 drivers/ata/libahci.c     | 52 ++++++++++++++++++++++++++-------------
 drivers/ata/libata-sata.c | 19 ++++++++++----
 drivers/ata/libata-scsi.c | 15 ++++++++---
 drivers/ata/pata_macio.c  |  2 +-
 drivers/ata/sata_mv.c     |  2 +-
 drivers/ata/sata_nv.c     |  4 +--
 drivers/ata/sata_sil24.c  |  2 +-
 include/linux/libata.h    |  8 +++---
 10 files changed, 79 insertions(+), 41 deletions(-)

diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 2e89499bd9c3..eeac5482f1d1 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -376,8 +376,8 @@ struct ahci_host_priv {
 
 extern int ahci_ignore_sss;
 
-extern struct device_attribute *ahci_shost_attrs[];
-extern struct device_attribute *ahci_sdev_attrs[];
+extern const struct attribute_group *ahci_shost_groups[];
+extern const struct attribute_group *ahci_sdev_groups[];
 
 /*
  * This must be instantiated by the edge drivers.  Read the comments
@@ -388,8 +388,8 @@ extern struct device_attribute *ahci_sdev_attrs[];
 	.can_queue		= AHCI_MAX_CMDS,			\
 	.sg_tablesize		= AHCI_MAX_SG,				\
 	.dma_boundary		= AHCI_DMA_BOUNDARY,			\
-	.shost_attrs		= ahci_shost_attrs,			\
-	.sdev_attrs		= ahci_sdev_attrs,			\
+	.shost_groups		= ahci_shost_groups,			\
+	.sdev_groups		= ahci_sdev_groups,			\
 	.change_queue_depth     = ata_scsi_change_queue_depth,		\
 	.tag_alloc_policy       = BLK_TAG_ALLOC_RR,             	\
 	.slave_configure        = ata_scsi_slave_config
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 3ca7720e7d8f..0b2fcf0d1d6c 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -1085,14 +1085,16 @@ static struct ata_port_operations ich_pata_ops = {
 	.set_dmamode		= ich_set_dmamode,
 };
 
-static struct device_attribute *piix_sidpr_shost_attrs[] = {
-	&dev_attr_link_power_management_policy,
+static struct attribute *piix_sidpr_shost_attrs[] = {
+	&dev_attr_link_power_management_policy.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(piix_sidpr_shost);
+
 static struct scsi_host_template piix_sidpr_sht = {
 	ATA_BMDMA_SHT(DRV_NAME),
-	.shost_attrs		= piix_sidpr_shost_attrs,
+	.shost_groups		= piix_sidpr_shost_groups,
 };
 
 static struct ata_port_operations piix_sidpr_sata_ops = {
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 5b3fa2cbe722..28430c093a7f 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -108,28 +108,46 @@ static DEVICE_ATTR(em_buffer, S_IWUSR | S_IRUGO,
 		   ahci_read_em_buffer, ahci_store_em_buffer);
 static DEVICE_ATTR(em_message_supported, S_IRUGO, ahci_show_em_supported, NULL);
 
-struct device_attribute *ahci_shost_attrs[] = {
-	&dev_attr_link_power_management_policy,
-	&dev_attr_em_message_type,
-	&dev_attr_em_message,
-	&dev_attr_ahci_host_caps,
-	&dev_attr_ahci_host_cap2,
-	&dev_attr_ahci_host_version,
-	&dev_attr_ahci_port_cmd,
-	&dev_attr_em_buffer,
-	&dev_attr_em_message_supported,
+static struct attribute *ahci_shost_attrs[] = {
+	&dev_attr_link_power_management_policy.attr,
+	&dev_attr_em_message_type.attr,
+	&dev_attr_em_message.attr,
+	&dev_attr_ahci_host_caps.attr,
+	&dev_attr_ahci_host_cap2.attr,
+	&dev_attr_ahci_host_version.attr,
+	&dev_attr_ahci_port_cmd.attr,
+	&dev_attr_em_buffer.attr,
+	&dev_attr_em_message_supported.attr,
 	NULL
 };
-EXPORT_SYMBOL_GPL(ahci_shost_attrs);
 
-struct device_attribute *ahci_sdev_attrs[] = {
-	&dev_attr_sw_activity,
-	&dev_attr_unload_heads,
-	&dev_attr_ncq_prio_supported,
-	&dev_attr_ncq_prio_enable,
+static const struct attribute_group ahci_shost_attr_group = {
+	.attrs = ahci_shost_attrs
+};
+
+const struct attribute_group *ahci_shost_groups[] = {
+	&ahci_shost_attr_group,
+	NULL
+};
+EXPORT_SYMBOL_GPL(ahci_shost_groups);
+
+struct attribute *ahci_sdev_attrs[] = {
+	&dev_attr_sw_activity.attr,
+	&dev_attr_unload_heads.attr,
+	&dev_attr_ncq_prio_supported.attr,
+	&dev_attr_ncq_prio_enable.attr,
+	NULL
+};
+
+static const struct attribute_group ahci_sdev_attr_group = {
+	.attrs = ahci_sdev_attrs
+};
+
+const struct attribute_group *ahci_sdev_groups[] = {
+	&ahci_sdev_attr_group,
 	NULL
 };
-EXPORT_SYMBOL_GPL(ahci_sdev_attrs);
+EXPORT_SYMBOL_GPL(ahci_sdev_groups);
 
 struct ata_port_operations ahci_ops = {
 	.inherits		= &sata_pmp_port_ops,
diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
index 8f3ff830ab0c..79e0f86aa3ae 100644
--- a/drivers/ata/libata-sata.c
+++ b/drivers/ata/libata-sata.c
@@ -922,13 +922,22 @@ DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
 	    ata_ncq_prio_enable_show, ata_ncq_prio_enable_store);
 EXPORT_SYMBOL_GPL(dev_attr_ncq_prio_enable);
 
-struct device_attribute *ata_ncq_sdev_attrs[] = {
-	&dev_attr_unload_heads,
-	&dev_attr_ncq_prio_enable,
-	&dev_attr_ncq_prio_supported,
+struct attribute *ata_ncq_sdev_attrs[] = {
+	&dev_attr_unload_heads.attr,
+	&dev_attr_ncq_prio_enable.attr,
+	&dev_attr_ncq_prio_supported.attr,
 	NULL
 };
-EXPORT_SYMBOL_GPL(ata_ncq_sdev_attrs);
+
+static const struct attribute_group ata_ncq_sdev_attr_group = {
+	.attrs = ata_ncq_sdev_attrs
+};
+
+const struct attribute_group *ata_ncq_sdev_groups[] = {
+	&ata_ncq_sdev_attr_group,
+	NULL
+};
+EXPORT_SYMBOL_GPL(ata_ncq_sdev_groups);
 
 static ssize_t
 ata_scsi_em_message_store(struct device *dev, struct device_attribute *attr,
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 1fb4611f7eeb..75c54b2761bf 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -234,11 +234,20 @@ static void ata_scsi_set_invalid_parameter(struct ata_device *dev,
 				     field, 0xff, 0);
 }
 
-struct device_attribute *ata_common_sdev_attrs[] = {
-	&dev_attr_unload_heads,
+static struct attribute *ata_common_sdev_attrs[] = {
+	&dev_attr_unload_heads.attr,
 	NULL
 };
-EXPORT_SYMBOL_GPL(ata_common_sdev_attrs);
+
+static const struct attribute_group ata_common_sdev_attr_group = {
+	.attrs = ata_common_sdev_attrs
+};
+
+const struct attribute_group *ata_common_sdev_groups[] = {
+	&ata_common_sdev_attr_group,
+	NULL
+};
+EXPORT_SYMBOL_GPL(ata_common_sdev_groups);
 
 /**
  *	ata_std_bios_param - generic bios head/sector/cylinder calculator used by sd.
diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c
index be0ca8d5b345..16e8aa184a75 100644
--- a/drivers/ata/pata_macio.c
+++ b/drivers/ata/pata_macio.c
@@ -923,7 +923,7 @@ static struct scsi_host_template pata_macio_sht = {
 	 */
 	.max_segment_size	= MAX_DBDMA_SEG,
 	.slave_configure	= pata_macio_slave_config,
-	.sdev_attrs		= ata_common_sdev_attrs,
+	.sdev_groups		= ata_common_sdev_groups,
 	.can_queue		= ATA_DEF_QUEUE,
 	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,
 };
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 9d86203e1e7a..24130e551b26 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -670,7 +670,7 @@ static struct scsi_host_template mv6_sht = {
 	.can_queue		= MV_MAX_Q_DEPTH - 1,
 	.sg_tablesize		= MV_MAX_SG_CT / 2,
 	.dma_boundary		= MV_DMA_BOUNDARY,
-	.sdev_attrs             = ata_ncq_sdev_attrs,
+	.sdev_groups		= ata_ncq_sdev_groups,
 	.change_queue_depth	= ata_scsi_change_queue_depth,
 	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,
 	.slave_configure	= ata_scsi_slave_config
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index c385d18ce87b..16272c111208 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -380,7 +380,7 @@ static struct scsi_host_template nv_adma_sht = {
 	.sg_tablesize		= NV_ADMA_SGTBL_TOTAL_LEN,
 	.dma_boundary		= NV_ADMA_DMA_BOUNDARY,
 	.slave_configure	= nv_adma_slave_config,
-	.sdev_attrs             = ata_ncq_sdev_attrs,
+	.sdev_groups		= ata_ncq_sdev_groups,
 	.change_queue_depth     = ata_scsi_change_queue_depth,
 	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,
 };
@@ -391,7 +391,7 @@ static struct scsi_host_template nv_swncq_sht = {
 	.sg_tablesize		= LIBATA_MAX_PRD,
 	.dma_boundary		= ATA_DMA_BOUNDARY,
 	.slave_configure	= nv_swncq_slave_config,
-	.sdev_attrs             = ata_ncq_sdev_attrs,
+	.sdev_groups		= ata_ncq_sdev_groups,
 	.change_queue_depth     = ata_scsi_change_queue_depth,
 	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,
 };
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 06a1e27c4f84..f99ec6f7d7c0 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -379,7 +379,7 @@ static struct scsi_host_template sil24_sht = {
 	.sg_tablesize		= SIL24_MAX_SGE,
 	.dma_boundary		= ATA_DMA_BOUNDARY,
 	.tag_alloc_policy	= BLK_TAG_ALLOC_FIFO,
-	.sdev_attrs		= ata_ncq_sdev_attrs,
+	.sdev_groups		= ata_ncq_sdev_groups,
 	.change_queue_depth	= ata_scsi_change_queue_depth,
 	.slave_configure	= ata_scsi_slave_config
 };
diff --git a/include/linux/libata.h b/include/linux/libata.h
index c0c64f03e107..bd1b782d1bbf 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1388,7 +1388,7 @@ 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 const struct attribute_group *ata_common_sdev_groups[];
 
 /*
  * All sht initializers (BASE, PIO, BMDMA, NCQ) must be instantiated
@@ -1418,14 +1418,14 @@ extern struct device_attribute *ata_common_sdev_attrs[];
 
 #define ATA_BASE_SHT(drv_name)					\
 	ATA_SUBBASE_SHT(drv_name),				\
-	.sdev_attrs		= ata_common_sdev_attrs
+	.sdev_groups		= ata_common_sdev_groups
 
 #ifdef CONFIG_SATA_HOST
-extern struct device_attribute *ata_ncq_sdev_attrs[];
+extern const struct attribute_group *ata_ncq_sdev_groups[];
 
 #define ATA_NCQ_SHT(drv_name)					\
 	ATA_SUBBASE_SHT(drv_name),				\
-	.sdev_attrs		= ata_ncq_sdev_attrs,		\
+	.sdev_groups		= ata_ncq_sdev_groups,		\
 	.change_queue_depth	= ata_scsi_change_queue_depth
 #endif
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 03/46] firewire: sbp2: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 01/46] scsi: core: Register " Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 02/46] ata: Switch to attribute groups Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 04/46] RDMA/srp: " Bart Van Assche
                   ` (42 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, Bart Van Assche, Stefan Richter

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/firewire/sbp2.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
index 4d5054211550..c2a9d7d0bd1e 100644
--- a/drivers/firewire/sbp2.c
+++ b/drivers/firewire/sbp2.c
@@ -1578,11 +1578,13 @@ static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev,
 
 static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
 
-static struct device_attribute *sbp2_scsi_sysfs_attrs[] = {
-	&dev_attr_ieee1394_id,
+static struct attribute *sbp2_scsi_sysfs_attrs[] = {
+	&dev_attr_ieee1394_id.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(sbp2_scsi_sysfs);
+
 static struct scsi_host_template scsi_driver_template = {
 	.module			= THIS_MODULE,
 	.name			= "SBP-2 IEEE-1394",
@@ -1595,7 +1597,7 @@ static struct scsi_host_template scsi_driver_template = {
 	.sg_tablesize		= SG_ALL,
 	.max_segment_size	= SBP2_MAX_SEG_SIZE,
 	.can_queue		= 1,
-	.sdev_attrs		= sbp2_scsi_sysfs_attrs,
+	.sdev_groups		= sbp2_scsi_sysfs_groups,
 };
 
 MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 04/46] RDMA/srp: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (2 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 03/46] firewire: sbp2: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 05/46] scsi: message: fusion: " Bart Van Assche
                   ` (41 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Doug Ledford, Jason Gunthorpe

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/infiniband/ulp/srp/ib_srp.c | 51 +++++++++++++++++------------
 1 file changed, 30 insertions(+), 21 deletions(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 71eda91e810c..089e09bfe002 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1026,10 +1026,17 @@ static int srp_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
  */
 static void srp_del_scsi_host_attr(struct Scsi_Host *shost)
 {
-	struct device_attribute **attr;
+	const struct attribute_group **g;
+	struct attribute **attr;
 
-	for (attr = shost->hostt->shost_attrs; attr && *attr; ++attr)
-		device_remove_file(&shost->shost_dev, *attr);
+	for (g = shost->hostt->shost_groups; *g; ++g) {
+		for (attr = (*g)->attrs; *attr; ++attr) {
+			struct device_attribute *dev_attr =
+				container_of(*attr, typeof(*dev_attr), attr);
+
+			device_remove_file(&shost->shost_dev, dev_attr);
+		}
+	}
 }
 
 static void srp_remove_target(struct srp_target_port *target)
@@ -3050,26 +3057,28 @@ static ssize_t allow_ext_sg_show(struct device *dev,
 
 static DEVICE_ATTR_RO(allow_ext_sg);
 
-static struct device_attribute *srp_host_attrs[] = {
-	&dev_attr_id_ext,
-	&dev_attr_ioc_guid,
-	&dev_attr_service_id,
-	&dev_attr_pkey,
-	&dev_attr_sgid,
-	&dev_attr_dgid,
-	&dev_attr_orig_dgid,
-	&dev_attr_req_lim,
-	&dev_attr_zero_req_lim,
-	&dev_attr_local_ib_port,
-	&dev_attr_local_ib_device,
-	&dev_attr_ch_count,
-	&dev_attr_comp_vector,
-	&dev_attr_tl_retry_count,
-	&dev_attr_cmd_sg_entries,
-	&dev_attr_allow_ext_sg,
+static struct attribute *srp_host_attrs[] = {
+	&dev_attr_id_ext.attr,
+	&dev_attr_ioc_guid.attr,
+	&dev_attr_service_id.attr,
+	&dev_attr_pkey.attr,
+	&dev_attr_sgid.attr,
+	&dev_attr_dgid.attr,
+	&dev_attr_orig_dgid.attr,
+	&dev_attr_req_lim.attr,
+	&dev_attr_zero_req_lim.attr,
+	&dev_attr_local_ib_port.attr,
+	&dev_attr_local_ib_device.attr,
+	&dev_attr_ch_count.attr,
+	&dev_attr_comp_vector.attr,
+	&dev_attr_tl_retry_count.attr,
+	&dev_attr_cmd_sg_entries.attr,
+	&dev_attr_allow_ext_sg.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(srp_host);
+
 static struct scsi_host_template srp_template = {
 	.module				= THIS_MODULE,
 	.name				= "InfiniBand SRP initiator",
@@ -3090,7 +3099,7 @@ static struct scsi_host_template srp_template = {
 	.can_queue			= SRP_DEFAULT_CMD_SQ_SIZE,
 	.this_id			= -1,
 	.cmd_per_lun			= SRP_DEFAULT_CMD_SQ_SIZE,
-	.shost_attrs			= srp_host_attrs,
+	.shost_groups			= srp_host_groups,
 	.track_queue_depth		= 1,
 	.cmd_size			= sizeof(struct srp_request),
 };

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 05/46] scsi: message: fusion: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (3 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 04/46] RDMA/srp: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 06/46] scsi: zfcp: " Bart Van Assche
                   ` (40 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Sathya Prakash, Sreekanth Reddy,
	Suganath Prabu Subramani

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/message/fusion/mptfc.c    |  2 +-
 drivers/message/fusion/mptsas.c   |  2 +-
 drivers/message/fusion/mptscsih.c | 36 +++++++++++++++++++------------
 drivers/message/fusion/mptscsih.h |  2 +-
 drivers/message/fusion/mptspi.c   |  2 +-
 5 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 572333fadd68..ecca95d2b9bf 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -129,7 +129,7 @@ static struct scsi_host_template mptfc_driver_template = {
 	.sg_tablesize			= MPT_SCSI_SG_DEPTH,
 	.max_sectors			= 8192,
 	.cmd_per_lun			= 7,
-	.shost_attrs			= mptscsih_host_attrs,
+	.shost_groups			= mptscsih_host_attr_groups,
 };
 
 /****************************************************************************
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 85285ba8e817..e31167446a02 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -2020,7 +2020,7 @@ static struct scsi_host_template mptsas_driver_template = {
 	.sg_tablesize			= MPT_SCSI_SG_DEPTH,
 	.max_sectors			= 8192,
 	.cmd_per_lun			= 7,
-	.shost_attrs			= mptscsih_host_attrs,
+	.shost_groups			= mptscsih_host_attr_groups,
 	.no_write_same			= 1,
 };
 
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index ce2e5b21978e..03573670c395 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -3218,23 +3218,31 @@ mptscsih_debug_level_store(struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR,
 	mptscsih_debug_level_show, mptscsih_debug_level_store);
 
-struct device_attribute *mptscsih_host_attrs[] = {
-	&dev_attr_version_fw,
-	&dev_attr_version_bios,
-	&dev_attr_version_mpi,
-	&dev_attr_version_product,
-	&dev_attr_version_nvdata_persistent,
-	&dev_attr_version_nvdata_default,
-	&dev_attr_board_name,
-	&dev_attr_board_assembly,
-	&dev_attr_board_tracer,
-	&dev_attr_io_delay,
-	&dev_attr_device_delay,
-	&dev_attr_debug_level,
+static struct attribute *mptscsih_host_attrs[] = {
+	&dev_attr_version_fw.attr,
+	&dev_attr_version_bios.attr,
+	&dev_attr_version_mpi.attr,
+	&dev_attr_version_product.attr,
+	&dev_attr_version_nvdata_persistent.attr,
+	&dev_attr_version_nvdata_default.attr,
+	&dev_attr_board_name.attr,
+	&dev_attr_board_assembly.attr,
+	&dev_attr_board_tracer.attr,
+	&dev_attr_io_delay.attr,
+	&dev_attr_device_delay.attr,
+	&dev_attr_debug_level.attr,
 	NULL,
 };
 
-EXPORT_SYMBOL(mptscsih_host_attrs);
+static const struct attribute_group mptscsih_host_attr_group = {
+	.attrs = mptscsih_host_attrs
+};
+
+const struct attribute_group *mptscsih_host_attr_groups[] = {
+	&mptscsih_host_attr_group,
+	NULL
+};
+EXPORT_SYMBOL(mptscsih_host_attr_groups);
 
 EXPORT_SYMBOL(mptscsih_remove);
 EXPORT_SYMBOL(mptscsih_shutdown);
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 2baeefd9be7a..a22c5eaf703c 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -131,7 +131,7 @@ extern int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
 extern int mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth);
 extern u8 mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id);
 extern int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id);
-extern struct device_attribute *mptscsih_host_attrs[];
+extern const struct attribute_group *mptscsih_host_attr_groups[];
 extern struct scsi_cmnd	*mptscsih_get_scsi_lookup(MPT_ADAPTER *ioc, int i);
 extern void mptscsih_taskmgmt_response_code(MPT_ADAPTER *ioc, u8 response_code);
 extern void mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd);
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index af0ce5611e4a..63c25877a413 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -843,7 +843,7 @@ static struct scsi_host_template mptspi_driver_template = {
 	.sg_tablesize			= MPT_SCSI_SG_DEPTH,
 	.max_sectors			= 8192,
 	.cmd_per_lun			= 7,
-	.shost_attrs			= mptscsih_host_attrs,
+	.shost_groups			= mptscsih_host_attr_groups,
 };
 
 static int mptspi_write_spi_device_pg1(struct scsi_target *starget,

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 06/46] scsi: zfcp: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (4 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 05/46] scsi: message: fusion: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-11 13:26   ` Benjamin Block
  2021-10-08 20:23 ` [PATCH v3 07/46] scsi: 3w-9xxx: " Bart Van Assche
                   ` (39 subsequent siblings)
  45 siblings, 1 reply; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Steffen Maier, Benjamin Block,
	Heiko Carstens, Vasily Gorbik, Christian Borntraeger

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/s390/scsi/zfcp_ext.h   |  4 +--
 drivers/s390/scsi/zfcp_scsi.c  |  4 +--
 drivers/s390/scsi/zfcp_sysfs.c | 52 +++++++++++++++++++++++-----------
 3 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index 6bc96d70254d..7b7b567186d6 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -184,8 +184,8 @@ extern const struct attribute_group *zfcp_sysfs_adapter_attr_groups[];
 extern const struct attribute_group *zfcp_unit_attr_groups[];
 extern const struct attribute_group *zfcp_port_attr_groups[];
 extern struct mutex zfcp_sysfs_port_units_mutex;
-extern struct device_attribute *zfcp_sysfs_sdev_attrs[];
-extern struct device_attribute *zfcp_sysfs_shost_attrs[];
+extern const struct attribute_group *zfcp_sdev_attr_groups[];
+extern const struct attribute_group *zfcp_shost_attr_groups[];
 bool zfcp_sysfs_port_is_removing(const struct zfcp_port *const port);
 
 /* zfcp_unit.c */
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 9da9b2b2a580..0b40e2331f97 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -444,8 +444,8 @@ static struct scsi_host_template zfcp_scsi_host_template = {
 	/* report size limit per scatter-gather segment */
 	.max_segment_size	 = ZFCP_QDIO_SBALE_LEN,
 	.dma_boundary		 = ZFCP_QDIO_SBALE_LEN - 1,
-	.shost_attrs		 = zfcp_sysfs_shost_attrs,
-	.sdev_attrs		 = zfcp_sysfs_sdev_attrs,
+	.shost_groups		 = zfcp_shost_attr_groups,
+	.sdev_groups		 = zfcp_sdev_attr_groups,
 	.track_queue_depth	 = 1,
 	.supported_mode		 = MODE_INITIATOR,
 };
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index b8cd75a872ee..fe1974658d82 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -672,17 +672,26 @@ ZFCP_DEFINE_SCSI_ATTR(zfcp_in_recovery, "%d\n",
 ZFCP_DEFINE_SCSI_ATTR(zfcp_status, "0x%08x\n",
 		      atomic_read(&zfcp_sdev->status));
 
-struct device_attribute *zfcp_sysfs_sdev_attrs[] = {
-	&dev_attr_fcp_lun,
-	&dev_attr_wwpn,
-	&dev_attr_hba_id,
-	&dev_attr_read_latency,
-	&dev_attr_write_latency,
-	&dev_attr_cmd_latency,
-	&dev_attr_zfcp_access_denied,
-	&dev_attr_zfcp_failed,
-	&dev_attr_zfcp_in_recovery,
-	&dev_attr_zfcp_status,
+struct attribute *zfcp_sdev_attrs[] = {
+	&dev_attr_fcp_lun.attr,
+	&dev_attr_wwpn.attr,
+	&dev_attr_hba_id.attr,
+	&dev_attr_read_latency.attr,
+	&dev_attr_write_latency.attr,
+	&dev_attr_cmd_latency.attr,
+	&dev_attr_zfcp_access_denied.attr,
+	&dev_attr_zfcp_failed.attr,
+	&dev_attr_zfcp_in_recovery.attr,
+	&dev_attr_zfcp_status.attr,
+	NULL
+};
+
+static const struct attribute_group zfcp_sdev_attr_group = {
+	.attrs = zfcp_sdev_attrs
+};
+
+const struct attribute_group *zfcp_sdev_attr_groups[] = {
+	&zfcp_sdev_attr_group,
 	NULL
 };
 
@@ -783,12 +792,21 @@ static ssize_t zfcp_sysfs_adapter_q_full_show(struct device *dev,
 }
 static DEVICE_ATTR(queue_full, S_IRUGO, zfcp_sysfs_adapter_q_full_show, NULL);
 
-struct device_attribute *zfcp_sysfs_shost_attrs[] = {
-	&dev_attr_utilization,
-	&dev_attr_requests,
-	&dev_attr_megabytes,
-	&dev_attr_seconds_active,
-	&dev_attr_queue_full,
+static struct attribute *zfcp_sysfs_shost_attrs[] = {
+	&dev_attr_utilization.attr,
+	&dev_attr_requests.attr,
+	&dev_attr_megabytes.attr,
+	&dev_attr_seconds_active.attr,
+	&dev_attr_queue_full.attr,
+	NULL
+};
+
+static const struct attribute_group zfcp_shost_attr_group = {
+	.attrs = zfcp_sysfs_shost_attrs
+};
+
+const struct attribute_group *zfcp_shost_attr_groups[] = {
+	&zfcp_shost_attr_group,
 	NULL
 };
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 07/46] scsi: 3w-9xxx: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (5 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 06/46] scsi: zfcp: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 08/46] scsi: 3w-sas: " Bart Van Assche
                   ` (38 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Adam Radford, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/3w-9xxx.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index e41cc354cc8a..a2a42f29bc06 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -197,11 +197,13 @@ static struct device_attribute twa_host_stats_attr = {
 };
 
 /* Host attributes initializer */
-static struct device_attribute *twa_host_attrs[] = {
-	&twa_host_stats_attr,
+static struct attribute *twa_host_attrs[] = {
+	&twa_host_stats_attr.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(twa_host);
+
 /* File operations struct for character device */
 static const struct file_operations twa_fops = {
 	.owner		= THIS_MODULE,
@@ -1990,7 +1992,7 @@ static struct scsi_host_template driver_template = {
 	.sg_tablesize		= TW_APACHE_MAX_SGL_LENGTH,
 	.max_sectors		= TW_MAX_SECTORS,
 	.cmd_per_lun		= TW_MAX_CMDS_PER_LUN,
-	.shost_attrs		= twa_host_attrs,
+	.shost_groups		= twa_host_groups,
 	.emulated		= 1,
 	.no_write_same		= 1,
 };

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 08/46] scsi: 3w-sas: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (6 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 07/46] scsi: 3w-9xxx: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 09/46] scsi: 3w-xxxx: " Bart Van Assche
                   ` (37 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Adam Radford, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/3w-sas.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index 4fde39da54e4..42414a58f368 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -198,11 +198,13 @@ static struct device_attribute twl_host_stats_attr = {
 };
 
 /* Host attributes initializer */
-static struct device_attribute *twl_host_attrs[] = {
-	&twl_host_stats_attr,
+static struct attribute *twl_host_attrs[] = {
+	&twl_host_stats_attr.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(twl_host);
+
 /* This function will look up an AEN severity string */
 static char *twl_aen_severity_lookup(unsigned char severity_code)
 {
@@ -1544,7 +1546,7 @@ static struct scsi_host_template driver_template = {
 	.sg_tablesize		= TW_LIBERATOR_MAX_SGL_LENGTH,
 	.max_sectors		= TW_MAX_SECTORS,
 	.cmd_per_lun		= TW_MAX_CMDS_PER_LUN,
-	.shost_attrs		= twl_host_attrs,
+	.shost_groups		= twl_host_groups,
 	.emulated		= 1,
 	.no_write_same		= 1,
 };

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 09/46] scsi: 3w-xxxx: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (7 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 08/46] scsi: 3w-sas: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 10/46] scsi: 53c700: " Bart Van Assche
                   ` (36 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Adam Radford, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/3w-xxxx.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index 4ee485ab2714..db4e5449d516 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -532,11 +532,13 @@ static struct device_attribute tw_host_stats_attr = {
 };
 
 /* Host attributes initializer */
-static struct device_attribute *tw_host_attrs[] = {
-	&tw_host_stats_attr,
+static struct attribute *tw_host_attrs[] = {
+	&tw_host_stats_attr.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(tw_host);
+
 /* This function will read the aen queue from the isr */
 static int tw_aen_read_queue(TW_Device_Extension *tw_dev, int request_id)
 {
@@ -2242,7 +2244,7 @@ static struct scsi_host_template driver_template = {
 	.sg_tablesize		= TW_MAX_SGL_LENGTH,
 	.max_sectors		= TW_MAX_SECTORS,
 	.cmd_per_lun		= TW_MAX_CMDS_PER_LUN,
-	.shost_attrs		= tw_host_attrs,
+	.shost_groups		= tw_host_groups,
 	.emulated		= 1,
 	.no_write_same		= 1,
 };

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 10/46] scsi: 53c700: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (8 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 09/46] scsi: 3w-xxxx: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 11/46] scsi: aacraid: " Bart Van Assche
                   ` (35 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, Bart Van Assche, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/53c700.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index a12e3525977d..931f9d44e83c 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -163,7 +163,7 @@ STATIC int NCR_700_slave_configure(struct scsi_device *SDpnt);
 STATIC void NCR_700_slave_destroy(struct scsi_device *SDpnt);
 static int NCR_700_change_queue_depth(struct scsi_device *SDpnt, int depth);
 
-STATIC struct device_attribute *NCR_700_dev_attrs[];
+STATIC const struct attribute_group *NCR_700_dev_groups[];
 
 STATIC struct scsi_transport_template *NCR_700_transport_template = NULL;
 
@@ -300,8 +300,8 @@ NCR_700_detect(struct scsi_host_template *tpnt,
 	static int banner = 0;
 	int j;
 
-	if(tpnt->sdev_attrs == NULL)
-		tpnt->sdev_attrs = NCR_700_dev_attrs;
+	if (tpnt->sdev_groups == NULL)
+		tpnt->sdev_groups = NCR_700_dev_groups;
 
 	memory = dma_alloc_coherent(dev, TOTAL_MEM_SIZE, &pScript, GFP_KERNEL);
 	if (!memory) {
@@ -2087,11 +2087,13 @@ static struct device_attribute NCR_700_active_tags_attr = {
 	.show = NCR_700_show_active_tags,
 };
 
-STATIC struct device_attribute *NCR_700_dev_attrs[] = {
-	&NCR_700_active_tags_attr,
+STATIC struct attribute *NCR_700_dev_attrs[] = {
+	&NCR_700_active_tags_attr.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(NCR_700_dev);
+
 EXPORT_SYMBOL(NCR_700_detect);
 EXPORT_SYMBOL(NCR_700_release);
 EXPORT_SYMBOL(NCR_700_intr);

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 11/46] scsi: aacraid: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (9 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 10/46] scsi: 53c700: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 12/46] scsi: arcmsr: " Bart Van Assche
                   ` (34 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Adaptec OEM Raid Solutions,
	James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/aacraid/linit.c | 38 ++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 3168915adaa7..a911252075a6 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -605,12 +605,14 @@ static struct device_attribute aac_unique_id_attr = {
 
 
 
-static struct device_attribute *aac_dev_attrs[] = {
-	&aac_raid_level_attr,
-	&aac_unique_id_attr,
+static struct attribute *aac_dev_attrs[] = {
+	&aac_raid_level_attr.attr,
+	&aac_unique_id_attr.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(aac_dev);
+
 static int aac_ioctl(struct scsi_device *sdev, unsigned int cmd,
 		     void __user *arg)
 {
@@ -1442,21 +1444,23 @@ static struct device_attribute aac_reset = {
 	.show = aac_show_reset_adapter,
 };
 
-static struct device_attribute *aac_attrs[] = {
-	&aac_model,
-	&aac_vendor,
-	&aac_flags,
-	&aac_kernel_version,
-	&aac_monitor_version,
-	&aac_bios_version,
-	&aac_lld_version,
-	&aac_serial_number,
-	&aac_max_channel,
-	&aac_max_id,
-	&aac_reset,
+static struct attribute *aac_host_attrs[] = {
+	&aac_model.attr,
+	&aac_vendor.attr,
+	&aac_flags.attr,
+	&aac_kernel_version.attr,
+	&aac_monitor_version.attr,
+	&aac_bios_version.attr,
+	&aac_lld_version.attr,
+	&aac_serial_number.attr,
+	&aac_max_channel.attr,
+	&aac_max_id.attr,
+	&aac_reset.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(aac_host);
+
 ssize_t aac_get_serial_number(struct device *device, char *buf)
 {
 	return aac_show_serial_number(device, &aac_serial_number, buf);
@@ -1483,10 +1487,10 @@ static struct scsi_host_template aac_driver_template = {
 #endif
 	.queuecommand			= aac_queuecommand,
 	.bios_param			= aac_biosparm,
-	.shost_attrs			= aac_attrs,
+	.shost_groups			= aac_host_groups,
 	.slave_configure		= aac_slave_configure,
 	.change_queue_depth		= aac_change_queue_depth,
-	.sdev_attrs			= aac_dev_attrs,
+	.sdev_groups			= aac_dev_groups,
 	.eh_abort_handler		= aac_eh_abort,
 	.eh_device_reset_handler	= aac_eh_dev_reset,
 	.eh_target_reset_handler	= aac_eh_target_reset,

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 12/46] scsi: arcmsr: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (10 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 11/46] scsi: aacraid: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 13/46] scsi: be2iscsi: " Bart Van Assche
                   ` (33 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, James E.J. Bottomley, ching Huang,
	Vaibhav Gupta, Hannes Reinecke, Lee Jones, Kees Cook

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/arcmsr/arcmsr.h      |  2 +-
 drivers/scsi/arcmsr/arcmsr_attr.c | 33 +++++++++++++++++++------------
 drivers/scsi/arcmsr/arcmsr_hba.c  |  2 +-
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
index 6ce57f031df5..07df255c4b1b 100644
--- a/drivers/scsi/arcmsr/arcmsr.h
+++ b/drivers/scsi/arcmsr/arcmsr.h
@@ -1041,6 +1041,6 @@ extern uint32_t arcmsr_Read_iop_rqbuffer_data(struct AdapterControlBlock *,
 	struct QBUFFER __iomem *);
 extern void arcmsr_clear_iop2drv_rqueue_buffer(struct AdapterControlBlock *);
 extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *);
-extern struct device_attribute *arcmsr_host_attrs[];
+extern const struct attribute_group *arcmsr_host_groups[];
 extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *);
 void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb);
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c
index 57be9609d504..baeb5e795690 100644
--- a/drivers/scsi/arcmsr/arcmsr_attr.c
+++ b/drivers/scsi/arcmsr/arcmsr_attr.c
@@ -58,8 +58,6 @@
 #include <scsi/scsi_transport.h>
 #include "arcmsr.h"
 
-struct device_attribute *arcmsr_host_attrs[];
-
 static ssize_t arcmsr_sysfs_iop_message_read(struct file *filp,
 					     struct kobject *kobj,
 					     struct bin_attribute *bin,
@@ -389,16 +387,25 @@ static DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_q
 static DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL);
 static DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL);
 
-struct device_attribute *arcmsr_host_attrs[] = {
-	&dev_attr_host_driver_version,
-	&dev_attr_host_driver_posted_cmd,
-	&dev_attr_host_driver_reset,
-	&dev_attr_host_driver_abort,
-	&dev_attr_host_fw_model,
-	&dev_attr_host_fw_version,
-	&dev_attr_host_fw_request_len,
-	&dev_attr_host_fw_numbers_queue,
-	&dev_attr_host_fw_sdram_size,
-	&dev_attr_host_fw_hd_channels,
+static struct attribute *arcmsr_host_attrs[] = {
+	&dev_attr_host_driver_version.attr,
+	&dev_attr_host_driver_posted_cmd.attr,
+	&dev_attr_host_driver_reset.attr,
+	&dev_attr_host_driver_abort.attr,
+	&dev_attr_host_fw_model.attr,
+	&dev_attr_host_fw_version.attr,
+	&dev_attr_host_fw_request_len.attr,
+	&dev_attr_host_fw_numbers_queue.attr,
+	&dev_attr_host_fw_sdram_size.attr,
+	&dev_attr_host_fw_hd_channels.attr,
 	NULL,
 };
+
+static const struct attribute_group arcmsr_host_attr_group = {
+	.attrs = arcmsr_host_attrs,
+};
+
+const struct attribute_group *arcmsr_host_groups[] = {
+	&arcmsr_host_attr_group,
+	NULL
+};
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index ec1a834c922d..a2d7de96ff2b 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -167,7 +167,7 @@ static struct scsi_host_template arcmsr_scsi_host_template = {
 	.sg_tablesize	        = ARCMSR_DEFAULT_SG_ENTRIES,
 	.max_sectors		= ARCMSR_MAX_XFER_SECTORS_C,
 	.cmd_per_lun		= ARCMSR_DEFAULT_CMD_PERLUN,
-	.shost_attrs		= arcmsr_host_attrs,
+	.shost_groups		= arcmsr_host_groups,
 	.no_write_same		= 1,
 };
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 13/46] scsi: be2iscsi: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (11 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 12/46] scsi: arcmsr: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 14/46] scsi: bfa: " Bart Van Assche
                   ` (32 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Ketan Mukadam, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/be2iscsi/be_main.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index e70f69f791db..ab55681145f8 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -163,17 +163,20 @@ DEVICE_ATTR(beiscsi_active_session_count, S_IRUGO,
 	     beiscsi_active_session_disp, NULL);
 DEVICE_ATTR(beiscsi_free_session_count, S_IRUGO,
 	     beiscsi_free_session_disp, NULL);
-static struct device_attribute *beiscsi_attrs[] = {
-	&dev_attr_beiscsi_log_enable,
-	&dev_attr_beiscsi_drvr_ver,
-	&dev_attr_beiscsi_adapter_family,
-	&dev_attr_beiscsi_fw_ver,
-	&dev_attr_beiscsi_active_session_count,
-	&dev_attr_beiscsi_free_session_count,
-	&dev_attr_beiscsi_phys_port,
+
+static struct attribute *beiscsi_attrs[] = {
+	&dev_attr_beiscsi_log_enable.attr,
+	&dev_attr_beiscsi_drvr_ver.attr,
+	&dev_attr_beiscsi_adapter_family.attr,
+	&dev_attr_beiscsi_fw_ver.attr,
+	&dev_attr_beiscsi_active_session_count.attr,
+	&dev_attr_beiscsi_free_session_count.attr,
+	&dev_attr_beiscsi_phys_port.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(beiscsi);
+
 static char const *cqe_desc[] = {
 	"RESERVED_DESC",
 	"SOL_CMD_COMPLETE",
@@ -391,7 +394,7 @@ static struct scsi_host_template beiscsi_sht = {
 	.eh_abort_handler = beiscsi_eh_abort,
 	.eh_device_reset_handler = beiscsi_eh_device_reset,
 	.eh_target_reset_handler = iscsi_eh_session_reset,
-	.shost_attrs = beiscsi_attrs,
+	.shost_groups = beiscsi_groups,
 	.sg_tablesize = BEISCSI_SGLIST_ELEMENTS,
 	.can_queue = BE2_IO_DEPTH,
 	.this_id = -1,

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 14/46] scsi: bfa: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (12 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 13/46] scsi: be2iscsi: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 15/46] scsi: bnx2fc: " Bart Van Assche
                   ` (31 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Anil Gurumurthy, Sudarsana Kalluru,
	James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/bfa/bfad_attr.c | 68 ++++++++++++++++++++++--------------
 drivers/scsi/bfa/bfad_im.c   |  4 +--
 drivers/scsi/bfa/bfad_im.h   |  4 +--
 3 files changed, 46 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c
index 5ae1e3f78910..c8b947c16069 100644
--- a/drivers/scsi/bfa/bfad_attr.c
+++ b/drivers/scsi/bfa/bfad_attr.c
@@ -956,36 +956,52 @@ static          DEVICE_ATTR(driver_name, S_IRUGO, bfad_im_drv_name_show, NULL);
 static          DEVICE_ATTR(number_of_discovered_ports, S_IRUGO,
 				bfad_im_num_of_discovered_ports_show, NULL);
 
-struct device_attribute *bfad_im_host_attrs[] = {
-	&dev_attr_serial_number,
-	&dev_attr_model,
-	&dev_attr_model_description,
-	&dev_attr_node_name,
-	&dev_attr_symbolic_name,
-	&dev_attr_hardware_version,
-	&dev_attr_driver_version,
-	&dev_attr_option_rom_version,
-	&dev_attr_firmware_version,
-	&dev_attr_number_of_ports,
-	&dev_attr_driver_name,
-	&dev_attr_number_of_discovered_ports,
+static struct attribute *bfad_im_host_attrs[] = {
+	&dev_attr_serial_number.attr,
+	&dev_attr_model.attr,
+	&dev_attr_model_description.attr,
+	&dev_attr_node_name.attr,
+	&dev_attr_symbolic_name.attr,
+	&dev_attr_hardware_version.attr,
+	&dev_attr_driver_version.attr,
+	&dev_attr_option_rom_version.attr,
+	&dev_attr_firmware_version.attr,
+	&dev_attr_number_of_ports.attr,
+	&dev_attr_driver_name.attr,
+	&dev_attr_number_of_discovered_ports.attr,
 	NULL,
 };
 
-struct device_attribute *bfad_im_vport_attrs[] = {
-	&dev_attr_serial_number,
-	&dev_attr_model,
-	&dev_attr_model_description,
-	&dev_attr_node_name,
-	&dev_attr_symbolic_name,
-	&dev_attr_hardware_version,
-	&dev_attr_driver_version,
-	&dev_attr_option_rom_version,
-	&dev_attr_firmware_version,
-	&dev_attr_number_of_ports,
-	&dev_attr_driver_name,
-	&dev_attr_number_of_discovered_ports,
+static const struct attribute_group bfad_im_host_attr_group = {
+	.attrs = bfad_im_host_attrs
+};
+
+const struct attribute_group *bfad_im_host_groups[] = {
+	&bfad_im_host_attr_group,
+	NULL
+};
+
+struct attribute *bfad_im_vport_attrs[] = {
+	&dev_attr_serial_number.attr,
+	&dev_attr_model.attr,
+	&dev_attr_model_description.attr,
+	&dev_attr_node_name.attr,
+	&dev_attr_symbolic_name.attr,
+	&dev_attr_hardware_version.attr,
+	&dev_attr_driver_version.attr,
+	&dev_attr_option_rom_version.attr,
+	&dev_attr_firmware_version.attr,
+	&dev_attr_number_of_ports.attr,
+	&dev_attr_driver_name.attr,
+	&dev_attr_number_of_discovered_ports.attr,
 	NULL,
 };
 
+static const struct attribute_group bfad_im_vport_attr_group = {
+	.attrs = bfad_im_vport_attrs
+};
 
+const struct attribute_group *bfad_im_vport_groups[] = {
+	&bfad_im_vport_attr_group,
+	NULL
+};
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 6b5841b1c06e..c074088afe12 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -809,7 +809,7 @@ struct scsi_host_template bfad_im_scsi_host_template = {
 	.this_id = -1,
 	.sg_tablesize = BFAD_IO_MAX_SGE,
 	.cmd_per_lun = 3,
-	.shost_attrs = bfad_im_host_attrs,
+	.shost_groups = bfad_im_host_groups,
 	.max_sectors = BFAD_MAX_SECTORS,
 	.vendor_id = BFA_PCI_VENDOR_ID_BROCADE,
 };
@@ -831,7 +831,7 @@ struct scsi_host_template bfad_im_vport_template = {
 	.this_id = -1,
 	.sg_tablesize = BFAD_IO_MAX_SGE,
 	.cmd_per_lun = 3,
-	.shost_attrs = bfad_im_vport_attrs,
+	.shost_groups = bfad_im_vport_groups,
 	.max_sectors = BFAD_MAX_SECTORS,
 };
 
diff --git a/drivers/scsi/bfa/bfad_im.h b/drivers/scsi/bfa/bfad_im.h
index f16d4b219e44..829345b514d1 100644
--- a/drivers/scsi/bfa/bfad_im.h
+++ b/drivers/scsi/bfa/bfad_im.h
@@ -174,8 +174,8 @@ extern struct fc_function_template bfad_im_vport_fc_function_template;
 extern struct scsi_transport_template *bfad_im_scsi_transport_template;
 extern struct scsi_transport_template *bfad_im_scsi_vport_transport_template;
 
-extern struct device_attribute *bfad_im_host_attrs[];
-extern struct device_attribute *bfad_im_vport_attrs[];
+extern const struct attribute_group *bfad_im_host_groups[];
+extern const struct attribute_group *bfad_im_vport_groups[];
 
 irqreturn_t bfad_intx(int irq, void *dev_id);
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 15/46] scsi: bnx2fc: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (13 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 14/46] scsi: bfa: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 16/46] scsi: bnx2i: " Bart Van Assche
                   ` (30 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Saurav Kashyap, Javed Hasan,
	GR-QLogic-Storage-Upstream, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 8863a74e6c57..71fa62bd3083 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2951,11 +2951,13 @@ bnx2fc_tm_timeout_store(struct device *dev,
 static DEVICE_ATTR(tm_timeout, S_IRUGO|S_IWUSR, bnx2fc_tm_timeout_show,
 	bnx2fc_tm_timeout_store);
 
-static struct device_attribute *bnx2fc_host_attrs[] = {
-	&dev_attr_tm_timeout,
+static struct attribute *bnx2fc_host_attrs[] = {
+	&dev_attr_tm_timeout.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(bnx2fc_host);
+
 /*
  * scsi_host_template structure used while registering with SCSI-ml
  */
@@ -2977,7 +2979,7 @@ static struct scsi_host_template bnx2fc_shost_template = {
 	.max_sectors		= 0x3fbf,
 	.track_queue_depth	= 1,
 	.slave_configure	= bnx2fc_slave_configure,
-	.shost_attrs		= bnx2fc_host_attrs,
+	.shost_groups		= bnx2fc_host_groups,
 };
 
 static struct libfc_function_template bnx2fc_libfc_fcn_templ = {

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 16/46] scsi: bnx2i: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (14 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 15/46] scsi: bnx2fc: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 17/46] scsi: csiostor: " Bart Van Assche
                   ` (29 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Nilesh Javali, Manish Rangankar,
	GR-QLogic-Storage-Upstream, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/bnx2i/bnx2i.h       |  2 +-
 drivers/scsi/bnx2i/bnx2i_iscsi.c |  2 +-
 drivers/scsi/bnx2i/bnx2i_sysfs.c | 15 ++++++++++++---
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i.h b/drivers/scsi/bnx2i/bnx2i.h
index 663a63d4dae4..df7d04afce05 100644
--- a/drivers/scsi/bnx2i/bnx2i.h
+++ b/drivers/scsi/bnx2i/bnx2i.h
@@ -795,7 +795,7 @@ extern struct cnic_ulp_ops bnx2i_cnic_cb;
 extern unsigned int sq_size;
 extern unsigned int rq_size;
 
-extern struct device_attribute *bnx2i_dev_attributes[];
+extern const struct attribute_group *bnx2i_dev_groups[];
 
 
 
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 1b5f3e143f07..e21b053b4f3e 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -2266,7 +2266,7 @@ static struct scsi_host_template bnx2i_host_template = {
 	.cmd_per_lun		= 128,
 	.this_id		= -1,
 	.sg_tablesize		= ISCSI_MAX_BDS_PER_CMD,
-	.shost_attrs		= bnx2i_dev_attributes,
+	.shost_groups		= bnx2i_dev_groups,
 	.track_queue_depth	= 1,
 };
 
diff --git a/drivers/scsi/bnx2i/bnx2i_sysfs.c b/drivers/scsi/bnx2i/bnx2i_sysfs.c
index bea00073cb7c..d6b0bbb5176b 100644
--- a/drivers/scsi/bnx2i/bnx2i_sysfs.c
+++ b/drivers/scsi/bnx2i/bnx2i_sysfs.c
@@ -142,8 +142,17 @@ static DEVICE_ATTR(sq_size, S_IRUGO | S_IWUSR,
 static DEVICE_ATTR(num_ccell, S_IRUGO | S_IWUSR,
 		   bnx2i_show_ccell_info, bnx2i_set_ccell_info);
 
-struct device_attribute *bnx2i_dev_attributes[] = {
-	&dev_attr_sq_size,
-	&dev_attr_num_ccell,
+static struct attribute *bnx2i_dev_attributes[] = {
+	&dev_attr_sq_size.attr,
+	&dev_attr_num_ccell.attr,
+	NULL
+};
+
+static const struct attribute_group bnx2i_dev_attr_group = {
+	.attrs = bnx2i_dev_attributes
+};
+
+const struct attribute_group *bnx2i_dev_groups[] = {
+	&bnx2i_dev_attr_group,
 	NULL
 };

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 17/46] scsi: csiostor: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (15 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 16/46] scsi: bnx2i: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 18/46] scsi: cxlflash: " Bart Van Assche
                   ` (28 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, James E.J. Bottomley, Jiapeng Chong

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/csiostor/csio_scsi.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c
index 3b2eb6ce1fcf..bcfae3859f4c 100644
--- a/drivers/scsi/csiostor/csio_scsi.c
+++ b/drivers/scsi/csiostor/csio_scsi.c
@@ -1460,14 +1460,16 @@ static DEVICE_ATTR(disable_port, S_IWUSR, NULL, csio_disable_port);
 static DEVICE_ATTR(dbg_level, S_IRUGO | S_IWUSR, csio_show_dbg_level,
 		  csio_store_dbg_level);
 
-static struct device_attribute *csio_fcoe_lport_attrs[] = {
-	&dev_attr_hw_state,
-	&dev_attr_device_reset,
-	&dev_attr_disable_port,
-	&dev_attr_dbg_level,
+static struct attribute *csio_fcoe_lport_attrs[] = {
+	&dev_attr_hw_state.attr,
+	&dev_attr_device_reset.attr,
+	&dev_attr_disable_port.attr,
+	&dev_attr_dbg_level.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(csio_fcoe_lport);
+
 static ssize_t
 csio_show_num_reg_rnodes(struct device *dev,
 		     struct device_attribute *attr, char *buf)
@@ -1479,12 +1481,14 @@ csio_show_num_reg_rnodes(struct device *dev,
 
 static DEVICE_ATTR(num_reg_rnodes, S_IRUGO, csio_show_num_reg_rnodes, NULL);
 
-static struct device_attribute *csio_fcoe_vport_attrs[] = {
-	&dev_attr_num_reg_rnodes,
-	&dev_attr_dbg_level,
+static struct attribute *csio_fcoe_vport_attrs[] = {
+	&dev_attr_num_reg_rnodes.attr,
+	&dev_attr_dbg_level.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(csio_fcoe_vport);
+
 static inline uint32_t
 csio_scsi_copy_to_sgl(struct csio_hw *hw, struct csio_ioreq *req)
 {
@@ -2277,7 +2281,7 @@ struct scsi_host_template csio_fcoe_shost_template = {
 	.this_id		= -1,
 	.sg_tablesize		= CSIO_SCSI_MAX_SGE,
 	.cmd_per_lun		= CSIO_MAX_CMD_PER_LUN,
-	.shost_attrs		= csio_fcoe_lport_attrs,
+	.shost_groups		= csio_fcoe_lport_groups,
 	.max_sectors		= CSIO_MAX_SECTOR_SIZE,
 };
 
@@ -2296,7 +2300,7 @@ struct scsi_host_template csio_fcoe_shost_vport_template = {
 	.this_id		= -1,
 	.sg_tablesize		= CSIO_SCSI_MAX_SGE,
 	.cmd_per_lun		= CSIO_MAX_CMD_PER_LUN,
-	.shost_attrs		= csio_fcoe_vport_attrs,
+	.shost_groups		= csio_fcoe_vport_groups,
 	.max_sectors		= CSIO_MAX_SECTOR_SIZE,
 };
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 18/46] scsi: cxlflash: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (16 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 17/46] scsi: csiostor: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 19/46] scsi: fnic: " Bart Van Assche
                   ` (27 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Matthew R. Ochs, Uma Krishnan,
	James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/cxlflash/main.c | 40 ++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index b2730e859df8..0c806dc95e89 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -3103,33 +3103,37 @@ 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
 };
 
+ATTRIBUTE_GROUPS(cxlflash_host);
+
 /*
  * Device attributes
  */
 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
 };
 
+ATTRIBUTE_GROUPS(cxlflash_dev);
+
 /*
  * Host template
  */
@@ -3150,8 +3154,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_groups,
+	.sdev_groups = cxlflash_dev_groups,
 };
 
 /*

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 19/46] scsi: fnic: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (17 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 18/46] scsi: cxlflash: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 20/46] scsi: hisi_sas: " Bart Van Assche
                   ` (26 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Satish Kharat, Sesidhar Baddela,
	Karan Tilak Kumar, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/fnic/fnic.h       |  2 +-
 drivers/scsi/fnic/fnic_attrs.c | 17 +++++++++++++----
 drivers/scsi/fnic/fnic_main.c  |  2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 69f373b53132..b95d0063dedb 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -322,7 +322,7 @@ static inline struct fnic *fnic_from_ctlr(struct fcoe_ctlr *fip)
 
 extern struct workqueue_struct *fnic_event_queue;
 extern struct workqueue_struct *fnic_fip_queue;
-extern struct device_attribute *fnic_attrs[];
+extern const struct attribute_group *fnic_host_groups[];
 
 void fnic_clear_intr_mode(struct fnic *fnic);
 int fnic_set_intr_mode(struct fnic *fnic);
diff --git a/drivers/scsi/fnic/fnic_attrs.c b/drivers/scsi/fnic/fnic_attrs.c
index aea0c3becfd4..bbe2ca4971b2 100644
--- a/drivers/scsi/fnic/fnic_attrs.c
+++ b/drivers/scsi/fnic/fnic_attrs.c
@@ -48,9 +48,18 @@ static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);
 static DEVICE_ATTR(drv_version, S_IRUGO, fnic_show_drv_version, NULL);
 static DEVICE_ATTR(link_state, S_IRUGO, fnic_show_link_state, NULL);
 
-struct device_attribute *fnic_attrs[] = {
-	&dev_attr_fnic_state,
-	&dev_attr_drv_version,
-	&dev_attr_link_state,
+static struct attribute *fnic_host_attrs[] = {
+	&dev_attr_fnic_state.attr,
+	&dev_attr_drv_version.attr,
+	&dev_attr_link_state.attr,
 	NULL,
 };
+
+static const struct attribute_group fnic_host_attr_group = {
+	.attrs = fnic_host_attrs
+};
+
+const struct attribute_group *fnic_host_groups[] = {
+	&fnic_host_attr_group,
+	NULL
+};
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 786f9d2704b6..44dbaa662d94 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -122,7 +122,7 @@ static struct scsi_host_template fnic_host_template = {
 	.can_queue = FNIC_DFLT_IO_REQ,
 	.sg_tablesize = FNIC_MAX_SG_DESC_CNT,
 	.max_sectors = 0xffff,
-	.shost_attrs = fnic_attrs,
+	.shost_groups = fnic_host_groups,
 	.track_queue_depth = 1,
 };
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 20/46] scsi: hisi_sas: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (18 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 19/46] scsi: fnic: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 21/46] scsi: hpsa: " Bart Van Assche
                   ` (25 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, John Garry, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c |  8 +++++---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c |  8 +++++---
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 14 ++++++++------
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
index 862f4e8b7eb5..14a6065390ab 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
@@ -1749,11 +1749,13 @@ static int hisi_sas_v1_init(struct hisi_hba *hisi_hba)
 	return 0;
 }
 
-static struct device_attribute *host_attrs_v1_hw[] = {
-	&dev_attr_phy_event_threshold,
+static struct attribute *host_v1_hw_attrs[] = {
+	&dev_attr_phy_event_threshold.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(host_v1_hw);
+
 static struct scsi_host_template sht_v1_hw = {
 	.name			= DRV_NAME,
 	.proc_name		= DRV_NAME,
@@ -1777,7 +1779,7 @@ static struct scsi_host_template sht_v1_hw = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl		= sas_ioctl,
 #endif
-	.shost_attrs		= host_attrs_v1_hw,
+	.shost_groups		= host_v1_hw_groups,
 	.host_reset             = hisi_sas_host_reset,
 };
 
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 236cf65c2f97..2ad80171c957 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -3542,11 +3542,13 @@ static void wait_cmds_complete_timeout_v2_hw(struct hisi_hba *hisi_hba,
 
 }
 
-static struct device_attribute *host_attrs_v2_hw[] = {
-	&dev_attr_phy_event_threshold,
+static struct attribute *host_v2_hw_attrs[] = {
+	&dev_attr_phy_event_threshold.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(host_v2_hw);
+
 static int map_queues_v2_hw(struct Scsi_Host *shost)
 {
 	struct hisi_hba *hisi_hba = shost_priv(shost);
@@ -3590,7 +3592,7 @@ static struct scsi_host_template sht_v2_hw = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl		= sas_ioctl,
 #endif
-	.shost_attrs		= host_attrs_v2_hw,
+	.shost_groups		= host_v2_hw_groups,
 	.host_reset		= hisi_sas_host_reset,
 	.map_queues		= map_queues_v2_hw,
 	.host_tagset		= 1,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index f4517f3eb922..c84318869e8e 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -2771,14 +2771,16 @@ static int slave_configure_v3_hw(struct scsi_device *sdev)
 	return 0;
 }
 
-static struct device_attribute *host_attrs_v3_hw[] = {
-	&dev_attr_phy_event_threshold,
-	&dev_attr_intr_conv_v3_hw,
-	&dev_attr_intr_coal_ticks_v3_hw,
-	&dev_attr_intr_coal_count_v3_hw,
+static struct attribute *host_v3_hw_attrs[] = {
+	&dev_attr_phy_event_threshold.attr,
+	&dev_attr_intr_conv_v3_hw.attr,
+	&dev_attr_intr_coal_ticks_v3_hw.attr,
+	&dev_attr_intr_coal_count_v3_hw.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(host_v3_hw);
+
 #define HISI_SAS_DEBUGFS_REG(x) {#x, x}
 
 struct hisi_sas_debugfs_reg_lu {
@@ -3163,7 +3165,7 @@ static struct scsi_host_template sht_v3_hw = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl		= sas_ioctl,
 #endif
-	.shost_attrs		= host_attrs_v3_hw,
+	.shost_groups		= host_v3_hw_groups,
 	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,
 	.host_reset             = hisi_sas_host_reset,
 	.host_tagset		= 1,

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 21/46] scsi: hpsa: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (19 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 20/46] scsi: hisi_sas: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 22/46] scsi: hptiop: " Bart Van Assche
                   ` (24 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Don Brace, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/hpsa.c | 44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 3faa87fa296a..8b0dc4be486e 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -936,30 +936,34 @@ static DEVICE_ATTR(ctlr_num, S_IRUGO,
 static DEVICE_ATTR(legacy_board, S_IRUGO,
 	host_show_legacy_board, NULL);
 
-static struct device_attribute *hpsa_sdev_attrs[] = {
-	&dev_attr_raid_level,
-	&dev_attr_lunid,
-	&dev_attr_unique_id,
-	&dev_attr_hp_ssd_smart_path_enabled,
-	&dev_attr_path_info,
-	&dev_attr_sas_address,
+static struct attribute *hpsa_sdev_attrs[] = {
+	&dev_attr_raid_level.attr,
+	&dev_attr_lunid.attr,
+	&dev_attr_unique_id.attr,
+	&dev_attr_hp_ssd_smart_path_enabled.attr,
+	&dev_attr_path_info.attr,
+	&dev_attr_sas_address.attr,
 	NULL,
 };
 
-static struct device_attribute *hpsa_shost_attrs[] = {
-	&dev_attr_rescan,
-	&dev_attr_firmware_revision,
-	&dev_attr_commands_outstanding,
-	&dev_attr_transport_mode,
-	&dev_attr_resettable,
-	&dev_attr_hp_ssd_smart_path_status,
-	&dev_attr_raid_offload_debug,
-	&dev_attr_lockup_detected,
-	&dev_attr_ctlr_num,
-	&dev_attr_legacy_board,
+ATTRIBUTE_GROUPS(hpsa_sdev);
+
+static struct attribute *hpsa_shost_attrs[] = {
+	&dev_attr_rescan.attr,
+	&dev_attr_firmware_revision.attr,
+	&dev_attr_commands_outstanding.attr,
+	&dev_attr_transport_mode.attr,
+	&dev_attr_resettable.attr,
+	&dev_attr_hp_ssd_smart_path_status.attr,
+	&dev_attr_raid_offload_debug.attr,
+	&dev_attr_lockup_detected.attr,
+	&dev_attr_ctlr_num.attr,
+	&dev_attr_legacy_board.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(hpsa_shost);
+
 #define HPSA_NRESERVED_CMDS	(HPSA_CMDS_RESERVED_FOR_DRIVER +\
 				 HPSA_MAX_CONCURRENT_PASSTHRUS)
 
@@ -980,8 +984,8 @@ static struct scsi_host_template hpsa_driver_template = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl		= hpsa_compat_ioctl,
 #endif
-	.sdev_attrs = hpsa_sdev_attrs,
-	.shost_attrs = hpsa_shost_attrs,
+	.sdev_groups = hpsa_sdev_groups,
+	.shost_groups = hpsa_shost_groups,
 	.max_sectors = 2048,
 	.no_write_same = 1,
 };

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 22/46] scsi: hptiop: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (20 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 21/46] scsi: hpsa: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 23/46] scsi: ibmvscsi: " Bart Van Assche
                   ` (23 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, HighPoint Linux Team, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/hptiop.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index 61cda7b7624f..7250c1d7fffb 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -1150,12 +1150,14 @@ static struct device_attribute hptiop_attr_fw_version = {
 	.show = hptiop_show_fw_version,
 };
 
-static struct device_attribute *hptiop_attrs[] = {
-	&hptiop_attr_version,
-	&hptiop_attr_fw_version,
+static struct attribute *hptiop_host_attrs[] = {
+	&hptiop_attr_version.attr,
+	&hptiop_attr_fw_version.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(hptiop_host);
+
 static int hptiop_slave_config(struct scsi_device *sdev)
 {
 	if (sdev->type == TYPE_TAPE)
@@ -1172,7 +1174,7 @@ static struct scsi_host_template driver_template = {
 	.info                       = hptiop_info,
 	.emulated                   = 0,
 	.proc_name                  = driver_name,
-	.shost_attrs                = hptiop_attrs,
+	.shost_groups		    = hptiop_host_groups,
 	.slave_configure            = hptiop_slave_config,
 	.this_id                    = -1,
 	.change_queue_depth         = hptiop_adjust_disk_queue_depth,

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 23/46] scsi: ibmvscsi: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (21 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 22/46] scsi: hptiop: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 24/46] scsi: ibmvfc: " Bart Van Assche
                   ` (22 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Tyrel Datwyler, Michael Ellerman,
	James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ibmvscsi/ibmvscsi.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 50df7dd9cb91..053ca437d2a8 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -2064,18 +2064,20 @@ static int ibmvscsi_host_reset(struct Scsi_Host *shost, int reset_type)
 	return 0;
 }
 
-static struct device_attribute *ibmvscsi_attrs[] = {
-	&ibmvscsi_host_vhost_loc,
-	&ibmvscsi_host_vhost_name,
-	&ibmvscsi_host_srp_version,
-	&ibmvscsi_host_partition_name,
-	&ibmvscsi_host_partition_number,
-	&ibmvscsi_host_mad_version,
-	&ibmvscsi_host_os_type,
-	&ibmvscsi_host_config,
+static struct attribute *ibmvscsi_host_attrs[] = {
+	&ibmvscsi_host_vhost_loc.attr,
+	&ibmvscsi_host_vhost_name.attr,
+	&ibmvscsi_host_srp_version.attr,
+	&ibmvscsi_host_partition_name.attr,
+	&ibmvscsi_host_partition_number.attr,
+	&ibmvscsi_host_mad_version.attr,
+	&ibmvscsi_host_os_type.attr,
+	&ibmvscsi_host_config.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(ibmvscsi_host);
+
 /* ------------------------------------------------------------
  * SCSI driver registration
  */
@@ -2095,7 +2097,7 @@ static struct scsi_host_template driver_template = {
 	.can_queue = IBMVSCSI_MAX_REQUESTS_DEFAULT,
 	.this_id = -1,
 	.sg_tablesize = SG_ALL,
-	.shost_attrs = ibmvscsi_attrs,
+	.shost_groups = ibmvscsi_host_groups,
 };
 
 /**

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 24/46] scsi: ibmvfc: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (22 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 23/46] scsi: ibmvscsi: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 25/46] scsi: ipr: " Bart Van Assche
                   ` (21 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Tyrel Datwyler, Michael Ellerman,
	James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ibmvscsi/ibmvfc.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 1f1586ad48fe..bc3a608be136 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -3588,18 +3588,20 @@ static struct bin_attribute ibmvfc_trace_attr = {
 };
 #endif
 
-static struct device_attribute *ibmvfc_attrs[] = {
-	&dev_attr_partition_name,
-	&dev_attr_device_name,
-	&dev_attr_port_loc_code,
-	&dev_attr_drc_name,
-	&dev_attr_npiv_version,
-	&dev_attr_capabilities,
-	&dev_attr_log_level,
-	&dev_attr_nr_scsi_channels,
+static struct attribute *ibmvfc_host_attrs[] = {
+	&dev_attr_partition_name.attr,
+	&dev_attr_device_name.attr,
+	&dev_attr_port_loc_code.attr,
+	&dev_attr_drc_name.attr,
+	&dev_attr_npiv_version.attr,
+	&dev_attr_capabilities.attr,
+	&dev_attr_log_level.attr,
+	&dev_attr_nr_scsi_channels.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(ibmvfc_host);
+
 static struct scsi_host_template driver_template = {
 	.module = THIS_MODULE,
 	.name = "IBM POWER Virtual FC Adapter",
@@ -3620,7 +3622,7 @@ static struct scsi_host_template driver_template = {
 	.this_id = -1,
 	.sg_tablesize = SG_ALL,
 	.max_sectors = IBMVFC_MAX_SECTORS,
-	.shost_attrs = ibmvfc_attrs,
+	.shost_groups = ibmvfc_host_groups,
 	.track_queue_depth = 1,
 	.host_tagset = 1,
 };

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 25/46] scsi: ipr: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (23 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 24/46] scsi: ibmvfc: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 26/46] scsi: isci: " Bart Van Assche
                   ` (20 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Brian King, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ipr.c | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 5d78f7e939a3..00862e84308c 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -4236,18 +4236,20 @@ static struct bin_attribute ipr_ioa_async_err_log = {
 	.write = ipr_next_async_err_log
 };
 
-static struct device_attribute *ipr_ioa_attrs[] = {
-	&ipr_fw_version_attr,
-	&ipr_log_level_attr,
-	&ipr_diagnostics_attr,
-	&ipr_ioa_state_attr,
-	&ipr_ioa_reset_attr,
-	&ipr_update_fw_attr,
-	&ipr_ioa_fw_type_attr,
-	&ipr_iopoll_weight_attr,
+static struct attribute *ipr_ioa_attrs[] = {
+	&ipr_fw_version_attr.attr,
+	&ipr_log_level_attr.attr,
+	&ipr_diagnostics_attr.attr,
+	&ipr_ioa_state_attr.attr,
+	&ipr_ioa_reset_attr.attr,
+	&ipr_update_fw_attr.attr,
+	&ipr_ioa_fw_type_attr.attr,
+	&ipr_iopoll_weight_attr.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(ipr_ioa);
+
 #ifdef CONFIG_SCSI_IPR_DUMP
 /**
  * ipr_read_dump - Dump the adapter
@@ -4732,15 +4734,17 @@ static struct device_attribute ipr_raw_mode_attr = {
 	.store = ipr_store_raw_mode
 };
 
-static struct device_attribute *ipr_dev_attrs[] = {
-	&ipr_adapter_handle_attr,
-	&ipr_resource_path_attr,
-	&ipr_device_id_attr,
-	&ipr_resource_type_attr,
-	&ipr_raw_mode_attr,
+static struct attribute *ipr_dev_attrs[] = {
+	&ipr_adapter_handle_attr.attr,
+	&ipr_resource_path_attr.attr,
+	&ipr_device_id_attr.attr,
+	&ipr_resource_type_attr.attr,
+	&ipr_raw_mode_attr.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(ipr_dev);
+
 /**
  * ipr_biosparam - Return the HSC mapping
  * @sdev:			scsi device struct
@@ -6762,8 +6766,8 @@ static struct scsi_host_template driver_template = {
 	.sg_tablesize = IPR_MAX_SGLIST,
 	.max_sectors = IPR_IOA_MAX_SECTORS,
 	.cmd_per_lun = IPR_MAX_CMD_PER_LUN,
-	.shost_attrs = ipr_ioa_attrs,
-	.sdev_attrs = ipr_dev_attrs,
+	.shost_groups = ipr_ioa_groups,
+	.sdev_groups = ipr_dev_groups,
 	.proc_name = IPR_NAME,
 };
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 26/46] scsi: isci: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (24 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 25/46] scsi: ipr: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 27/46] scsi: lpfc: " Bart Van Assche
                   ` (19 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Artur Paszkiewicz, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/isci/init.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
index ffd33e5decae..aade707c5553 100644
--- a/drivers/scsi/isci/init.c
+++ b/drivers/scsi/isci/init.c
@@ -142,11 +142,13 @@ static ssize_t isci_show_id(struct device *dev, struct device_attribute *attr, c
 
 static DEVICE_ATTR(isci_id, S_IRUGO, isci_show_id, NULL);
 
-static struct device_attribute *isci_host_attrs[] = {
-	&dev_attr_isci_id,
+static struct attribute *isci_host_attrs[] = {
+	&dev_attr_isci_id.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(isci_host);
+
 static struct scsi_host_template isci_sht = {
 
 	.module				= THIS_MODULE,
@@ -173,7 +175,7 @@ static struct scsi_host_template isci_sht = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl			= sas_ioctl,
 #endif
-	.shost_attrs			= isci_host_attrs,
+	.shost_groups			= isci_host_groups,
 	.track_queue_depth		= 1,
 };
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 27/46] scsi: lpfc: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (25 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 26/46] scsi: isci: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 28/46] scsi: megaraid: " Bart Van Assche
                   ` (18 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, James Smart, Dick Kennedy,
	James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/lpfc/lpfc_attr.c | 314 ++++++++++++++++++----------------
 drivers/scsi/lpfc/lpfc_crtn.h |   4 +-
 drivers/scsi/lpfc/lpfc_init.c |   2 +-
 drivers/scsi/lpfc/lpfc_scsi.c |   4 +-
 4 files changed, 171 insertions(+), 153 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index b35bf70a8c0d..2a6c938b2def 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -6396,160 +6396,178 @@ LPFC_ATTR_RW(vmid_priority_tagging, LPFC_VMID_PRIO_TAG_DISABLE,
 	     LPFC_VMID_PRIO_TAG_ALL_TARGETS,
 	     "Enable Priority Tagging VMID support");
 
-struct device_attribute *lpfc_hba_attrs[] = {
-	&dev_attr_nvme_info,
-	&dev_attr_scsi_stat,
-	&dev_attr_bg_info,
-	&dev_attr_bg_guard_err,
-	&dev_attr_bg_apptag_err,
-	&dev_attr_bg_reftag_err,
-	&dev_attr_info,
-	&dev_attr_serialnum,
-	&dev_attr_modeldesc,
-	&dev_attr_modelname,
-	&dev_attr_programtype,
-	&dev_attr_portnum,
-	&dev_attr_fwrev,
-	&dev_attr_hdw,
-	&dev_attr_option_rom_version,
-	&dev_attr_link_state,
-	&dev_attr_num_discovered_ports,
-	&dev_attr_menlo_mgmt_mode,
-	&dev_attr_lpfc_drvr_version,
-	&dev_attr_lpfc_enable_fip,
-	&dev_attr_lpfc_temp_sensor,
-	&dev_attr_lpfc_log_verbose,
-	&dev_attr_lpfc_lun_queue_depth,
-	&dev_attr_lpfc_tgt_queue_depth,
-	&dev_attr_lpfc_hba_queue_depth,
-	&dev_attr_lpfc_peer_port_login,
-	&dev_attr_lpfc_nodev_tmo,
-	&dev_attr_lpfc_devloss_tmo,
-	&dev_attr_lpfc_enable_fc4_type,
-	&dev_attr_lpfc_fcp_class,
-	&dev_attr_lpfc_use_adisc,
-	&dev_attr_lpfc_first_burst_size,
-	&dev_attr_lpfc_ack0,
-	&dev_attr_lpfc_xri_rebalancing,
-	&dev_attr_lpfc_topology,
-	&dev_attr_lpfc_scan_down,
-	&dev_attr_lpfc_link_speed,
-	&dev_attr_lpfc_fcp_io_sched,
-	&dev_attr_lpfc_ns_query,
-	&dev_attr_lpfc_fcp2_no_tgt_reset,
-	&dev_attr_lpfc_cr_delay,
-	&dev_attr_lpfc_cr_count,
-	&dev_attr_lpfc_multi_ring_support,
-	&dev_attr_lpfc_multi_ring_rctl,
-	&dev_attr_lpfc_multi_ring_type,
-	&dev_attr_lpfc_fdmi_on,
-	&dev_attr_lpfc_enable_SmartSAN,
-	&dev_attr_lpfc_max_luns,
-	&dev_attr_lpfc_enable_npiv,
-	&dev_attr_lpfc_fcf_failover_policy,
-	&dev_attr_lpfc_enable_rrq,
-	&dev_attr_lpfc_fcp_wait_abts_rsp,
-	&dev_attr_nport_evt_cnt,
-	&dev_attr_board_mode,
-	&dev_attr_max_vpi,
-	&dev_attr_used_vpi,
-	&dev_attr_max_rpi,
-	&dev_attr_used_rpi,
-	&dev_attr_max_xri,
-	&dev_attr_used_xri,
-	&dev_attr_npiv_info,
-	&dev_attr_issue_reset,
-	&dev_attr_lpfc_poll,
-	&dev_attr_lpfc_poll_tmo,
-	&dev_attr_lpfc_task_mgmt_tmo,
-	&dev_attr_lpfc_use_msi,
-	&dev_attr_lpfc_nvme_oas,
-	&dev_attr_lpfc_nvme_embed_cmd,
-	&dev_attr_lpfc_fcp_imax,
-	&dev_attr_lpfc_force_rscn,
-	&dev_attr_lpfc_cq_poll_threshold,
-	&dev_attr_lpfc_cq_max_proc_limit,
-	&dev_attr_lpfc_fcp_cpu_map,
-	&dev_attr_lpfc_fcp_mq_threshold,
-	&dev_attr_lpfc_hdw_queue,
-	&dev_attr_lpfc_irq_chann,
-	&dev_attr_lpfc_suppress_rsp,
-	&dev_attr_lpfc_nvmet_mrq,
-	&dev_attr_lpfc_nvmet_mrq_post,
-	&dev_attr_lpfc_nvme_enable_fb,
-	&dev_attr_lpfc_nvmet_fb_size,
-	&dev_attr_lpfc_enable_bg,
-	&dev_attr_lpfc_soft_wwnn,
-	&dev_attr_lpfc_soft_wwpn,
-	&dev_attr_lpfc_soft_wwn_enable,
-	&dev_attr_lpfc_enable_hba_reset,
-	&dev_attr_lpfc_enable_hba_heartbeat,
-	&dev_attr_lpfc_EnableXLane,
-	&dev_attr_lpfc_XLanePriority,
-	&dev_attr_lpfc_xlane_lun,
-	&dev_attr_lpfc_xlane_tgt,
-	&dev_attr_lpfc_xlane_vpt,
-	&dev_attr_lpfc_xlane_lun_state,
-	&dev_attr_lpfc_xlane_lun_status,
-	&dev_attr_lpfc_xlane_priority,
-	&dev_attr_lpfc_sg_seg_cnt,
-	&dev_attr_lpfc_max_scsicmpl_time,
-	&dev_attr_lpfc_stat_data_ctrl,
-	&dev_attr_lpfc_aer_support,
-	&dev_attr_lpfc_aer_state_cleanup,
-	&dev_attr_lpfc_sriov_nr_virtfn,
-	&dev_attr_lpfc_req_fw_upgrade,
-	&dev_attr_lpfc_suppress_link_up,
-	&dev_attr_iocb_hw,
-	&dev_attr_pls,
-	&dev_attr_pt,
-	&dev_attr_txq_hw,
-	&dev_attr_txcmplq_hw,
-	&dev_attr_lpfc_sriov_hw_max_virtfn,
-	&dev_attr_protocol,
-	&dev_attr_lpfc_xlane_supported,
-	&dev_attr_lpfc_enable_mds_diags,
-	&dev_attr_lpfc_ras_fwlog_buffsize,
-	&dev_attr_lpfc_ras_fwlog_level,
-	&dev_attr_lpfc_ras_fwlog_func,
-	&dev_attr_lpfc_enable_bbcr,
-	&dev_attr_lpfc_enable_dpp,
-	&dev_attr_lpfc_enable_mi,
-	&dev_attr_cmf_info,
-	&dev_attr_lpfc_max_vmid,
-	&dev_attr_lpfc_vmid_inactivity_timeout,
-	&dev_attr_lpfc_vmid_app_header,
-	&dev_attr_lpfc_vmid_priority_tagging,
+static struct attribute *lpfc_hba_attrs[] = {
+	&dev_attr_nvme_info.attr,
+	&dev_attr_scsi_stat.attr,
+	&dev_attr_bg_info.attr,
+	&dev_attr_bg_guard_err.attr,
+	&dev_attr_bg_apptag_err.attr,
+	&dev_attr_bg_reftag_err.attr,
+	&dev_attr_info.attr,
+	&dev_attr_serialnum.attr,
+	&dev_attr_modeldesc.attr,
+	&dev_attr_modelname.attr,
+	&dev_attr_programtype.attr,
+	&dev_attr_portnum.attr,
+	&dev_attr_fwrev.attr,
+	&dev_attr_hdw.attr,
+	&dev_attr_option_rom_version.attr,
+	&dev_attr_link_state.attr,
+	&dev_attr_num_discovered_ports.attr,
+	&dev_attr_menlo_mgmt_mode.attr,
+	&dev_attr_lpfc_drvr_version.attr,
+	&dev_attr_lpfc_enable_fip.attr,
+	&dev_attr_lpfc_temp_sensor.attr,
+	&dev_attr_lpfc_log_verbose.attr,
+	&dev_attr_lpfc_lun_queue_depth.attr,
+	&dev_attr_lpfc_tgt_queue_depth.attr,
+	&dev_attr_lpfc_hba_queue_depth.attr,
+	&dev_attr_lpfc_peer_port_login.attr,
+	&dev_attr_lpfc_nodev_tmo.attr,
+	&dev_attr_lpfc_devloss_tmo.attr,
+	&dev_attr_lpfc_enable_fc4_type.attr,
+	&dev_attr_lpfc_fcp_class.attr,
+	&dev_attr_lpfc_use_adisc.attr,
+	&dev_attr_lpfc_first_burst_size.attr,
+	&dev_attr_lpfc_ack0.attr,
+	&dev_attr_lpfc_xri_rebalancing.attr,
+	&dev_attr_lpfc_topology.attr,
+	&dev_attr_lpfc_scan_down.attr,
+	&dev_attr_lpfc_link_speed.attr,
+	&dev_attr_lpfc_fcp_io_sched.attr,
+	&dev_attr_lpfc_ns_query.attr,
+	&dev_attr_lpfc_fcp2_no_tgt_reset.attr,
+	&dev_attr_lpfc_cr_delay.attr,
+	&dev_attr_lpfc_cr_count.attr,
+	&dev_attr_lpfc_multi_ring_support.attr,
+	&dev_attr_lpfc_multi_ring_rctl.attr,
+	&dev_attr_lpfc_multi_ring_type.attr,
+	&dev_attr_lpfc_fdmi_on.attr,
+	&dev_attr_lpfc_enable_SmartSAN.attr,
+	&dev_attr_lpfc_max_luns.attr,
+	&dev_attr_lpfc_enable_npiv.attr,
+	&dev_attr_lpfc_fcf_failover_policy.attr,
+	&dev_attr_lpfc_enable_rrq.attr,
+	&dev_attr_lpfc_fcp_wait_abts_rsp.attr,
+	&dev_attr_nport_evt_cnt.attr,
+	&dev_attr_board_mode.attr,
+	&dev_attr_max_vpi.attr,
+	&dev_attr_used_vpi.attr,
+	&dev_attr_max_rpi.attr,
+	&dev_attr_used_rpi.attr,
+	&dev_attr_max_xri.attr,
+	&dev_attr_used_xri.attr,
+	&dev_attr_npiv_info.attr,
+	&dev_attr_issue_reset.attr,
+	&dev_attr_lpfc_poll.attr,
+	&dev_attr_lpfc_poll_tmo.attr,
+	&dev_attr_lpfc_task_mgmt_tmo.attr,
+	&dev_attr_lpfc_use_msi.attr,
+	&dev_attr_lpfc_nvme_oas.attr,
+	&dev_attr_lpfc_nvme_embed_cmd.attr,
+	&dev_attr_lpfc_fcp_imax.attr,
+	&dev_attr_lpfc_force_rscn.attr,
+	&dev_attr_lpfc_cq_poll_threshold.attr,
+	&dev_attr_lpfc_cq_max_proc_limit.attr,
+	&dev_attr_lpfc_fcp_cpu_map.attr,
+	&dev_attr_lpfc_fcp_mq_threshold.attr,
+	&dev_attr_lpfc_hdw_queue.attr,
+	&dev_attr_lpfc_irq_chann.attr,
+	&dev_attr_lpfc_suppress_rsp.attr,
+	&dev_attr_lpfc_nvmet_mrq.attr,
+	&dev_attr_lpfc_nvmet_mrq_post.attr,
+	&dev_attr_lpfc_nvme_enable_fb.attr,
+	&dev_attr_lpfc_nvmet_fb_size.attr,
+	&dev_attr_lpfc_enable_bg.attr,
+	&dev_attr_lpfc_soft_wwnn.attr,
+	&dev_attr_lpfc_soft_wwpn.attr,
+	&dev_attr_lpfc_soft_wwn_enable.attr,
+	&dev_attr_lpfc_enable_hba_reset.attr,
+	&dev_attr_lpfc_enable_hba_heartbeat.attr,
+	&dev_attr_lpfc_EnableXLane.attr,
+	&dev_attr_lpfc_XLanePriority.attr,
+	&dev_attr_lpfc_xlane_lun.attr,
+	&dev_attr_lpfc_xlane_tgt.attr,
+	&dev_attr_lpfc_xlane_vpt.attr,
+	&dev_attr_lpfc_xlane_lun_state.attr,
+	&dev_attr_lpfc_xlane_lun_status.attr,
+	&dev_attr_lpfc_xlane_priority.attr,
+	&dev_attr_lpfc_sg_seg_cnt.attr,
+	&dev_attr_lpfc_max_scsicmpl_time.attr,
+	&dev_attr_lpfc_stat_data_ctrl.attr,
+	&dev_attr_lpfc_aer_support.attr,
+	&dev_attr_lpfc_aer_state_cleanup.attr,
+	&dev_attr_lpfc_sriov_nr_virtfn.attr,
+	&dev_attr_lpfc_req_fw_upgrade.attr,
+	&dev_attr_lpfc_suppress_link_up.attr,
+	&dev_attr_iocb_hw.attr,
+	&dev_attr_pls.attr,
+	&dev_attr_pt.attr,
+	&dev_attr_txq_hw.attr,
+	&dev_attr_txcmplq_hw.attr,
+	&dev_attr_lpfc_sriov_hw_max_virtfn.attr,
+	&dev_attr_protocol.attr,
+	&dev_attr_lpfc_xlane_supported.attr,
+	&dev_attr_lpfc_enable_mds_diags.attr,
+	&dev_attr_lpfc_ras_fwlog_buffsize.attr,
+	&dev_attr_lpfc_ras_fwlog_level.attr,
+	&dev_attr_lpfc_ras_fwlog_func.attr,
+	&dev_attr_lpfc_enable_bbcr.attr,
+	&dev_attr_lpfc_enable_dpp.attr,
+	&dev_attr_lpfc_enable_mi.attr,
+	&dev_attr_cmf_info.attr,
+	&dev_attr_lpfc_max_vmid.attr,
+	&dev_attr_lpfc_vmid_inactivity_timeout.attr,
+	&dev_attr_lpfc_vmid_app_header.attr,
+	&dev_attr_lpfc_vmid_priority_tagging.attr,
 	NULL,
 };
 
-struct device_attribute *lpfc_vport_attrs[] = {
-	&dev_attr_info,
-	&dev_attr_link_state,
-	&dev_attr_num_discovered_ports,
-	&dev_attr_lpfc_drvr_version,
-	&dev_attr_lpfc_log_verbose,
-	&dev_attr_lpfc_lun_queue_depth,
-	&dev_attr_lpfc_tgt_queue_depth,
-	&dev_attr_lpfc_nodev_tmo,
-	&dev_attr_lpfc_devloss_tmo,
-	&dev_attr_lpfc_hba_queue_depth,
-	&dev_attr_lpfc_peer_port_login,
-	&dev_attr_lpfc_restrict_login,
-	&dev_attr_lpfc_fcp_class,
-	&dev_attr_lpfc_use_adisc,
-	&dev_attr_lpfc_first_burst_size,
-	&dev_attr_lpfc_max_luns,
-	&dev_attr_nport_evt_cnt,
-	&dev_attr_npiv_info,
-	&dev_attr_lpfc_enable_da_id,
-	&dev_attr_lpfc_max_scsicmpl_time,
-	&dev_attr_lpfc_stat_data_ctrl,
-	&dev_attr_lpfc_static_vport,
-	&dev_attr_cmf_info,
+static const struct attribute_group lpfc_hba_attr_group = {
+	.attrs = lpfc_hba_attrs
+};
+
+const struct attribute_group *lpfc_hba_groups[] = {
+	&lpfc_hba_attr_group,
+	NULL
+};
+
+static struct attribute *lpfc_vport_attrs[] = {
+	&dev_attr_info.attr,
+	&dev_attr_link_state.attr,
+	&dev_attr_num_discovered_ports.attr,
+	&dev_attr_lpfc_drvr_version.attr,
+	&dev_attr_lpfc_log_verbose.attr,
+	&dev_attr_lpfc_lun_queue_depth.attr,
+	&dev_attr_lpfc_tgt_queue_depth.attr,
+	&dev_attr_lpfc_nodev_tmo.attr,
+	&dev_attr_lpfc_devloss_tmo.attr,
+	&dev_attr_lpfc_hba_queue_depth.attr,
+	&dev_attr_lpfc_peer_port_login.attr,
+	&dev_attr_lpfc_restrict_login.attr,
+	&dev_attr_lpfc_fcp_class.attr,
+	&dev_attr_lpfc_use_adisc.attr,
+	&dev_attr_lpfc_first_burst_size.attr,
+	&dev_attr_lpfc_max_luns.attr,
+	&dev_attr_nport_evt_cnt.attr,
+	&dev_attr_npiv_info.attr,
+	&dev_attr_lpfc_enable_da_id.attr,
+	&dev_attr_lpfc_max_scsicmpl_time.attr,
+	&dev_attr_lpfc_stat_data_ctrl.attr,
+	&dev_attr_lpfc_static_vport.attr,
+	&dev_attr_cmf_info.attr,
 	NULL,
 };
 
+static const struct attribute_group lpfc_vport_attr_group = {
+	.attrs = lpfc_vport_attrs
+};
+
+const struct attribute_group *lpfc_vport_groups[] = {
+	&lpfc_vport_attr_group,
+	NULL
+};
+
 /**
  * sysfs_ctlreg_write - Write method for writing to ctlreg
  * @filp: open sysfs file
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index c512f4199142..ad4a954ecc09 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -428,8 +428,8 @@ void lpfc_get_cfgparam(struct lpfc_hba *);
 void lpfc_get_vport_cfgparam(struct lpfc_vport *);
 int lpfc_alloc_sysfs_attr(struct lpfc_vport *);
 void lpfc_free_sysfs_attr(struct lpfc_vport *);
-extern struct device_attribute *lpfc_hba_attrs[];
-extern struct device_attribute *lpfc_vport_attrs[];
+extern const struct attribute_group *lpfc_hba_groups[];
+extern const struct attribute_group *lpfc_vport_groups[];
 extern struct scsi_host_template lpfc_template;
 extern struct scsi_host_template lpfc_template_nvme;
 extern struct fc_function_template lpfc_transport_functions;
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index ea8f929eb3f7..4201bf05aa29 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4574,7 +4574,7 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
 			/* Template for all vports this physical port creates */
 			memcpy(&phba->vport_template, &lpfc_template,
 			       sizeof(*template));
-			phba->vport_template.shost_attrs = lpfc_vport_attrs;
+			phba->vport_template.shost_groups = lpfc_vport_groups;
 			phba->vport_template.eh_bus_reset_handler = NULL;
 			phba->vport_template.eh_host_reset_handler = NULL;
 			phba->vport_template.vendor_id = 0;
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 17e677cf8dcd..67345ee6ee58 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -7203,7 +7203,7 @@ struct scsi_host_template lpfc_template_nvme = {
 	.this_id		= -1,
 	.sg_tablesize		= 1,
 	.cmd_per_lun		= 1,
-	.shost_attrs		= lpfc_hba_attrs,
+	.shost_groups		= lpfc_hba_groups,
 	.max_sectors		= 0xFFFFFFFF,
 	.vendor_id		= LPFC_NL_VENDOR_ID,
 	.track_queue_depth	= 0,
@@ -7229,7 +7229,7 @@ struct scsi_host_template lpfc_template = {
 	.this_id		= -1,
 	.sg_tablesize		= LPFC_DEFAULT_SG_SEG_CNT,
 	.cmd_per_lun		= LPFC_CMD_PER_LUN,
-	.shost_attrs		= lpfc_hba_attrs,
+	.shost_groups		= lpfc_hba_groups,
 	.max_sectors		= 0xFFFFFFFF,
 	.vendor_id		= LPFC_NL_VENDOR_ID,
 	.change_queue_depth	= scsi_change_queue_depth,

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 28/46] scsi: megaraid: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (26 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 27/46] scsi: lpfc: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 29/46] scsi: mpt3sas: " Bart Van Assche
                   ` (17 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Kashyap Desai, Sumit Saxena,
	Shivasharan S, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/megaraid/megaraid_mbox.c     | 15 ++++++++------
 drivers/scsi/megaraid/megaraid_sas_base.c | 24 ++++++++++++-----------
 2 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index d20c2e4ee793..bd1f64ae33dd 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -305,20 +305,23 @@ static struct pci_driver megaraid_pci_driver = {
 static DEVICE_ATTR_ADMIN_RO(megaraid_mbox_app_hndl);
 
 // Host template initializer for megaraid mbox sysfs device attributes
-static struct device_attribute *megaraid_shost_attrs[] = {
-	&dev_attr_megaraid_mbox_app_hndl,
+static struct attribute *megaraid_shost_attrs[] = {
+	&dev_attr_megaraid_mbox_app_hndl.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(megaraid_shost);
 
 static DEVICE_ATTR_ADMIN_RO(megaraid_mbox_ld);
 
 // Host template initializer for megaraid mbox sysfs device attributes
-static struct device_attribute *megaraid_sdev_attrs[] = {
-	&dev_attr_megaraid_mbox_ld,
+static struct attribute *megaraid_sdev_attrs[] = {
+	&dev_attr_megaraid_mbox_ld.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(megaraid_sdev);
+
 /*
  * Scsi host template for megaraid unified driver
  */
@@ -331,8 +334,8 @@ static struct scsi_host_template megaraid_template_g = {
 	.eh_host_reset_handler		= megaraid_reset_handler,
 	.change_queue_depth		= scsi_change_queue_depth,
 	.no_write_same			= 1,
-	.sdev_attrs			= megaraid_sdev_attrs,
-	.shost_attrs			= megaraid_shost_attrs,
+	.sdev_groups			= megaraid_sdev_groups,
+	.shost_groups			= megaraid_shost_groups,
 };
 
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index e4298bf4a482..2011e081bca4 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -3481,19 +3481,21 @@ static DEVICE_ATTR_RW(enable_sdev_max_qd);
 static DEVICE_ATTR_RO(dump_system_regs);
 static DEVICE_ATTR_RO(raid_map_id);
 
-static struct device_attribute *megaraid_host_attrs[] = {
-	&dev_attr_fw_crash_buffer_size,
-	&dev_attr_fw_crash_buffer,
-	&dev_attr_fw_crash_state,
-	&dev_attr_page_size,
-	&dev_attr_ldio_outstanding,
-	&dev_attr_fw_cmds_outstanding,
-	&dev_attr_enable_sdev_max_qd,
-	&dev_attr_dump_system_regs,
-	&dev_attr_raid_map_id,
+static struct attribute *megaraid_host_attrs[] = {
+	&dev_attr_fw_crash_buffer_size.attr,
+	&dev_attr_fw_crash_buffer.attr,
+	&dev_attr_fw_crash_state.attr,
+	&dev_attr_page_size.attr,
+	&dev_attr_ldio_outstanding.attr,
+	&dev_attr_fw_cmds_outstanding.attr,
+	&dev_attr_enable_sdev_max_qd.attr,
+	&dev_attr_dump_system_regs.attr,
+	&dev_attr_raid_map_id.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(megaraid_host);
+
 /*
  * Scsi host template for megaraid_sas driver
  */
@@ -3510,7 +3512,7 @@ static struct scsi_host_template megasas_template = {
 	.eh_abort_handler = megasas_task_abort,
 	.eh_host_reset_handler = megasas_reset_bus_host,
 	.eh_timed_out = megasas_reset_timer,
-	.shost_attrs = megaraid_host_attrs,
+	.shost_groups = megaraid_host_groups,
 	.bios_param = megasas_bios_param,
 	.map_queues = megasas_map_queues,
 	.mq_poll = megasas_blk_mq_poll,

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 29/46] scsi: mpt3sas: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (27 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 28/46] scsi: megaraid: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 30/46] scsi: mvsas: " Bart Van Assche
                   ` (16 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Sathya Prakash, Sreekanth Reddy,
	Suganath Prabu Subramani, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  4 +-
 drivers/scsi/mpt3sas/mpt3sas_ctl.c   | 84 +++++++++++++++++-----------
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |  8 +--
 3 files changed, 57 insertions(+), 39 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h
index f87c0911f66a..db6a759de1e9 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -1939,8 +1939,8 @@ mpt3sas_config_update_driver_trigger_pg4(struct MPT3SAS_ADAPTER *ioc,
 	struct SL_WH_MPI_TRIGGERS_T *mpi_tg, bool set);
 
 /* ctl shared API */
-extern struct device_attribute *mpt3sas_host_attrs[];
-extern struct device_attribute *mpt3sas_dev_attrs[];
+extern const struct attribute_group *mpt3sas_host_groups[];
+extern const struct attribute_group *mpt3sas_dev_groups[];
 void mpt3sas_ctl_init(ushort hbas_to_enumerate);
 void mpt3sas_ctl_exit(ushort hbas_to_enumerate);
 u8 mpt3sas_ctl_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index 770b241d7bb2..adcf97a5ca81 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -3842,37 +3842,46 @@ enable_sdev_max_qd_store(struct device *cdev,
 }
 static DEVICE_ATTR_RW(enable_sdev_max_qd);
 
-struct device_attribute *mpt3sas_host_attrs[] = {
-	&dev_attr_version_fw,
-	&dev_attr_version_bios,
-	&dev_attr_version_mpi,
-	&dev_attr_version_product,
-	&dev_attr_version_nvdata_persistent,
-	&dev_attr_version_nvdata_default,
-	&dev_attr_board_name,
-	&dev_attr_board_assembly,
-	&dev_attr_board_tracer,
-	&dev_attr_io_delay,
-	&dev_attr_device_delay,
-	&dev_attr_logging_level,
-	&dev_attr_fwfault_debug,
-	&dev_attr_fw_queue_depth,
-	&dev_attr_host_sas_address,
-	&dev_attr_ioc_reset_count,
-	&dev_attr_host_trace_buffer_size,
-	&dev_attr_host_trace_buffer,
-	&dev_attr_host_trace_buffer_enable,
-	&dev_attr_reply_queue_count,
-	&dev_attr_diag_trigger_master,
-	&dev_attr_diag_trigger_event,
-	&dev_attr_diag_trigger_scsi,
-	&dev_attr_diag_trigger_mpi,
-	&dev_attr_drv_support_bitmap,
-	&dev_attr_BRM_status,
-	&dev_attr_enable_sdev_max_qd,
+static struct attribute *mpt3sas_host_attrs[] = {
+	&dev_attr_version_fw.attr,
+	&dev_attr_version_bios.attr,
+	&dev_attr_version_mpi.attr,
+	&dev_attr_version_product.attr,
+	&dev_attr_version_nvdata_persistent.attr,
+	&dev_attr_version_nvdata_default.attr,
+	&dev_attr_board_name.attr,
+	&dev_attr_board_assembly.attr,
+	&dev_attr_board_tracer.attr,
+	&dev_attr_io_delay.attr,
+	&dev_attr_device_delay.attr,
+	&dev_attr_logging_level.attr,
+	&dev_attr_fwfault_debug.attr,
+	&dev_attr_fw_queue_depth.attr,
+	&dev_attr_host_sas_address.attr,
+	&dev_attr_ioc_reset_count.attr,
+	&dev_attr_host_trace_buffer_size.attr,
+	&dev_attr_host_trace_buffer.attr,
+	&dev_attr_host_trace_buffer_enable.attr,
+	&dev_attr_reply_queue_count.attr,
+	&dev_attr_diag_trigger_master.attr,
+	&dev_attr_diag_trigger_event.attr,
+	&dev_attr_diag_trigger_scsi.attr,
+	&dev_attr_diag_trigger_mpi.attr,
+	&dev_attr_drv_support_bitmap.attr,
+	&dev_attr_BRM_status.attr,
+	&dev_attr_enable_sdev_max_qd.attr,
 	NULL,
 };
 
+static const struct attribute_group mpt3sas_host_attr_group = {
+	.attrs = mpt3sas_host_attrs
+};
+
+const struct attribute_group *mpt3sas_host_groups[] = {
+	&mpt3sas_host_attr_group,
+	NULL
+};
+
 /* device attributes */
 
 /**
@@ -3976,14 +3985,23 @@ sas_ncq_prio_enable_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(sas_ncq_prio_enable);
 
-struct device_attribute *mpt3sas_dev_attrs[] = {
-	&dev_attr_sas_address,
-	&dev_attr_sas_device_handle,
-	&dev_attr_sas_ncq_prio_supported,
-	&dev_attr_sas_ncq_prio_enable,
+struct attribute *mpt3sas_dev_attrs[] = {
+	&dev_attr_sas_address.attr,
+	&dev_attr_sas_device_handle.attr,
+	&dev_attr_sas_ncq_prio_supported.attr,
+	&dev_attr_sas_ncq_prio_enable.attr,
 	NULL,
 };
 
+static const struct attribute_group mpt3sas_dev_attr_group = {
+	.attrs = mpt3sas_dev_attrs
+};
+
+const struct attribute_group *mpt3sas_dev_groups[] = {
+	&mpt3sas_dev_attr_group,
+	NULL
+};
+
 /* file operations table for mpt3ctl device */
 static const struct file_operations ctl_fops = {
 	.owner = THIS_MODULE,
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 2f82b1e629af..4806dd240d6b 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -11876,8 +11876,8 @@ static struct scsi_host_template mpt2sas_driver_template = {
 	.sg_tablesize			= MPT2SAS_SG_DEPTH,
 	.max_sectors			= 32767,
 	.cmd_per_lun			= 7,
-	.shost_attrs			= mpt3sas_host_attrs,
-	.sdev_attrs			= mpt3sas_dev_attrs,
+	.shost_groups			= mpt3sas_host_groups,
+	.sdev_groups			= mpt3sas_dev_groups,
 	.track_queue_depth		= 1,
 	.cmd_size			= sizeof(struct scsiio_tracker),
 };
@@ -11915,8 +11915,8 @@ static struct scsi_host_template mpt3sas_driver_template = {
 	.max_sectors			= 32767,
 	.max_segment_size		= 0xffffffff,
 	.cmd_per_lun			= 7,
-	.shost_attrs			= mpt3sas_host_attrs,
-	.sdev_attrs			= mpt3sas_dev_attrs,
+	.shost_groups			= mpt3sas_host_groups,
+	.sdev_groups			= mpt3sas_dev_groups,
 	.track_queue_depth		= 1,
 	.cmd_size			= sizeof(struct scsiio_tracker),
 	.map_queues			= scsih_map_queues,

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 30/46] scsi: mvsas: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (28 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 29/46] scsi: mpt3sas: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 31/46] scsi: myrb: " Bart Van Assche
                   ` (15 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, James E.J. Bottomley, Yufen Yu,
	Jason Yan, Zhen Lei

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/mvsas/mv_init.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index f18dd9703595..dcae2d4464f9 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -25,7 +25,7 @@ static const struct mvs_chip_info mvs_chips[] = {
 	[chip_1320] =	{ 2, 4, 0x800, 17, 64, 8,  9, &mvs_94xx_dispatch, },
 };
 
-static struct device_attribute *mvst_host_attrs[];
+static const struct attribute_group *mvst_host_groups[];
 
 #define SOC_SAS_NUM 2
 
@@ -52,7 +52,7 @@ static struct scsi_host_template mvs_sht = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl		= sas_ioctl,
 #endif
-	.shost_attrs		= mvst_host_attrs,
+	.shost_groups		= mvst_host_groups,
 	.track_queue_depth	= 1,
 };
 
@@ -773,12 +773,14 @@ static void __exit mvs_exit(void)
 	sas_release_transport(mvs_stt);
 }
 
-static struct device_attribute *mvst_host_attrs[] = {
-	&dev_attr_driver_version,
-	&dev_attr_interrupt_coalescing,
+static struct attribute *mvst_host_attrs[] = {
+	&dev_attr_driver_version.attr,
+	&dev_attr_interrupt_coalescing.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(mvst_host);
+
 module_init(mvs_init);
 module_exit(mvs_exit);
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 31/46] scsi: myrb: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (29 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 30/46] scsi: mvsas: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 32/46] scsi: myrs: " Bart Van Assche
                   ` (14 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Hannes Reinecke, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/myrb.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
index a4a88323e020..72441c014f92 100644
--- a/drivers/scsi/myrb.c
+++ b/drivers/scsi/myrb.c
@@ -2182,22 +2182,26 @@ static ssize_t flush_cache_store(struct device *dev,
 }
 static DEVICE_ATTR_WO(flush_cache);
 
-static struct device_attribute *myrb_sdev_attrs[] = {
-	&dev_attr_rebuild,
-	&dev_attr_consistency_check,
-	&dev_attr_raid_state,
-	&dev_attr_raid_level,
+static struct attribute *myrb_sdev_attrs[] = {
+	&dev_attr_rebuild.attr,
+	&dev_attr_consistency_check.attr,
+	&dev_attr_raid_state.attr,
+	&dev_attr_raid_level.attr,
 	NULL,
 };
 
-static struct device_attribute *myrb_shost_attrs[] = {
-	&dev_attr_ctlr_num,
-	&dev_attr_model,
-	&dev_attr_firmware,
-	&dev_attr_flush_cache,
+ATTRIBUTE_GROUPS(myrb_sdev);
+
+static struct attribute *myrb_shost_attrs[] = {
+	&dev_attr_ctlr_num.attr,
+	&dev_attr_model.attr,
+	&dev_attr_firmware.attr,
+	&dev_attr_flush_cache.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(myrb_shost);
+
 static struct scsi_host_template myrb_template = {
 	.module			= THIS_MODULE,
 	.name			= "DAC960",
@@ -2209,8 +2213,8 @@ static struct scsi_host_template myrb_template = {
 	.slave_destroy		= myrb_slave_destroy,
 	.bios_param		= myrb_biosparam,
 	.cmd_size		= sizeof(struct myrb_cmdblk),
-	.shost_attrs		= myrb_shost_attrs,
-	.sdev_attrs		= myrb_sdev_attrs,
+	.shost_groups		= myrb_shost_groups,
+	.sdev_groups		= myrb_sdev_groups,
 	.this_id		= -1,
 };
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 32/46] scsi: myrs: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (30 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 31/46] scsi: myrb: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 33/46] scsi: ncr53c8xx: " Bart Van Assche
                   ` (13 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Hannes Reinecke, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/myrs.c | 40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index 07f274afd7e5..ca42f7f6244b 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -1286,14 +1286,16 @@ static ssize_t consistency_check_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(consistency_check);
 
-static struct device_attribute *myrs_sdev_attrs[] = {
-	&dev_attr_consistency_check,
-	&dev_attr_rebuild,
-	&dev_attr_raid_state,
-	&dev_attr_raid_level,
+static struct attribute *myrs_sdev_attrs[] = {
+	&dev_attr_consistency_check.attr,
+	&dev_attr_rebuild.attr,
+	&dev_attr_raid_state.attr,
+	&dev_attr_raid_level.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(myrs_sdev);
+
 static ssize_t serial_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
@@ -1510,20 +1512,22 @@ static ssize_t disable_enclosure_messages_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(disable_enclosure_messages);
 
-static struct device_attribute *myrs_shost_attrs[] = {
-	&dev_attr_serial,
-	&dev_attr_ctlr_num,
-	&dev_attr_processor,
-	&dev_attr_model,
-	&dev_attr_ctlr_type,
-	&dev_attr_cache_size,
-	&dev_attr_firmware,
-	&dev_attr_discovery,
-	&dev_attr_flush_cache,
-	&dev_attr_disable_enclosure_messages,
+static struct attribute *myrs_shost_attrs[] = {
+	&dev_attr_serial.attr,
+	&dev_attr_ctlr_num.attr,
+	&dev_attr_processor.attr,
+	&dev_attr_model.attr,
+	&dev_attr_ctlr_type.attr,
+	&dev_attr_cache_size.attr,
+	&dev_attr_firmware.attr,
+	&dev_attr_discovery.attr,
+	&dev_attr_flush_cache.attr,
+	&dev_attr_disable_enclosure_messages.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(myrs_shost);
+
 /*
  * SCSI midlayer interface
  */
@@ -1923,8 +1927,8 @@ static struct scsi_host_template myrs_template = {
 	.slave_configure	= myrs_slave_configure,
 	.slave_destroy		= myrs_slave_destroy,
 	.cmd_size		= sizeof(struct myrs_cmdblk),
-	.shost_attrs		= myrs_shost_attrs,
-	.sdev_attrs		= myrs_sdev_attrs,
+	.shost_groups		= myrs_shost_groups,
+	.sdev_groups		= myrs_sdev_groups,
 	.this_id		= -1,
 };
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 33/46] scsi: ncr53c8xx: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (31 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 32/46] scsi: myrs: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 34/46] scsi: sym53c500_cs: " Bart Van Assche
                   ` (12 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, Bart Van Assche, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/ncr53c8xx.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index 2b8c6fa5e775..57fa29a1bcc0 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -8039,11 +8039,13 @@ static struct device_attribute ncr53c8xx_revision_attr = {
 	.show	= show_ncr53c8xx_revision,
 };
   
-static struct device_attribute *ncr53c8xx_host_attrs[] = {
-	&ncr53c8xx_revision_attr,
+static struct attribute *ncr53c8xx_host_attrs[] = {
+	&ncr53c8xx_revision_attr.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(ncr53c8xx_host);
+
 /*==========================================================
 **
 **	Boot command line.
@@ -8085,8 +8087,8 @@ struct Scsi_Host * __init ncr_attach(struct scsi_host_template *tpnt,
 
 	if (!tpnt->name)
 		tpnt->name	= SCSI_NCR_DRIVER_NAME;
-	if (!tpnt->shost_attrs)
-		tpnt->shost_attrs = ncr53c8xx_host_attrs;
+	if (!tpnt->shost_groups)
+		tpnt->shost_groups = ncr53c8xx_host_groups;
 
 	tpnt->queuecommand	= ncr53c8xx_queue_command;
 	tpnt->slave_configure	= ncr53c8xx_slave_configure;

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 34/46] scsi: sym53c500_cs: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (32 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 33/46] scsi: ncr53c8xx: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 35/46] scsi: pm8001: " Bart Van Assche
                   ` (11 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, Bart Van Assche, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/pcmcia/sym53c500_cs.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index a366ff1a3959..873d1121113a 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -652,11 +652,13 @@ static struct device_attribute SYM53C500_pio_attr = {
 	.store = SYM53C500_store_pio,
 };
 
-static struct device_attribute *SYM53C500_shost_attrs[] = {
-	&SYM53C500_pio_attr,
+static struct attribute *SYM53C500_shost_attrs[] = {
+	&SYM53C500_pio_attr.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(SYM53C500_shost);
+
 /*
 *  scsi_host_template initializer
 */
@@ -671,7 +673,7 @@ static struct scsi_host_template sym53c500_driver_template = {
      .can_queue			= 1,
      .this_id			= 7,
      .sg_tablesize		= 32,
-     .shost_attrs		= SYM53C500_shost_attrs
+     .shost_groups		= SYM53C500_shost_groups
 };
 
 static int SYM53C500_config_check(struct pcmcia_device *p_dev, void *priv_data)

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 35/46] scsi: pm8001: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (33 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 34/46] scsi: sym53c500_cs: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-11  4:54   ` Jinpu Wang
  2021-10-08 20:23 ` [PATCH v3 36/46] scsi: pmcraid: " Bart Van Assche
                   ` (10 subsequent siblings)
  45 siblings, 1 reply; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Jack Wang, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/pm8001/pm8001_ctl.c  | 64 +++++++++++++++++--------------
 drivers/scsi/pm8001/pm8001_init.c |  2 +-
 drivers/scsi/pm8001/pm8001_sas.h  |  2 +-
 3 files changed, 38 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
index b25e447aa3bd..397eb9f6a1dd 100644
--- a/drivers/scsi/pm8001/pm8001_ctl.c
+++ b/drivers/scsi/pm8001/pm8001_ctl.c
@@ -1002,34 +1002,42 @@ static ssize_t ctl_iop1_count_show(struct device *cdev,
 }
 static DEVICE_ATTR_RO(ctl_iop1_count);
 
-struct device_attribute *pm8001_host_attrs[] = {
-	&dev_attr_interface_rev,
-	&dev_attr_controller_fatal_error,
-	&dev_attr_fw_version,
-	&dev_attr_update_fw,
-	&dev_attr_aap_log,
-	&dev_attr_iop_log,
-	&dev_attr_fatal_log,
-	&dev_attr_non_fatal_log,
-	&dev_attr_non_fatal_count,
-	&dev_attr_gsm_log,
-	&dev_attr_max_out_io,
-	&dev_attr_max_devices,
-	&dev_attr_max_sg_list,
-	&dev_attr_sas_spec_support,
-	&dev_attr_logging_level,
-	&dev_attr_event_log_size,
-	&dev_attr_host_sas_address,
-	&dev_attr_bios_version,
-	&dev_attr_ib_log,
-	&dev_attr_ob_log,
-	&dev_attr_ila_version,
-	&dev_attr_inc_fw_ver,
-	&dev_attr_ctl_mpi_state,
-	&dev_attr_ctl_hmi_error,
-	&dev_attr_ctl_raae_count,
-	&dev_attr_ctl_iop0_count,
-	&dev_attr_ctl_iop1_count,
+static struct attribute *pm8001_host_attrs[] = {
+	&dev_attr_interface_rev.attr,
+	&dev_attr_controller_fatal_error.attr,
+	&dev_attr_fw_version.attr,
+	&dev_attr_update_fw.attr,
+	&dev_attr_aap_log.attr,
+	&dev_attr_iop_log.attr,
+	&dev_attr_fatal_log.attr,
+	&dev_attr_non_fatal_log.attr,
+	&dev_attr_non_fatal_count.attr,
+	&dev_attr_gsm_log.attr,
+	&dev_attr_max_out_io.attr,
+	&dev_attr_max_devices.attr,
+	&dev_attr_max_sg_list.attr,
+	&dev_attr_sas_spec_support.attr,
+	&dev_attr_logging_level.attr,
+	&dev_attr_event_log_size.attr,
+	&dev_attr_host_sas_address.attr,
+	&dev_attr_bios_version.attr,
+	&dev_attr_ib_log.attr,
+	&dev_attr_ob_log.attr,
+	&dev_attr_ila_version.attr,
+	&dev_attr_inc_fw_ver.attr,
+	&dev_attr_ctl_mpi_state.attr,
+	&dev_attr_ctl_hmi_error.attr,
+	&dev_attr_ctl_raae_count.attr,
+	&dev_attr_ctl_iop0_count.attr,
+	&dev_attr_ctl_iop1_count.attr,
 	NULL,
 };
 
+static const struct attribute_group pm8001_host_attr_group = {
+	.attrs = pm8001_host_attrs
+};
+
+const struct attribute_group *pm8001_host_groups[] = {
+	&pm8001_host_attr_group,
+	NULL
+};
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index 7082fecf7ce8..bed8cc125544 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -107,7 +107,7 @@ static struct scsi_host_template pm8001_sht = {
 #ifdef CONFIG_COMPAT
 	.compat_ioctl		= sas_ioctl,
 #endif
-	.shost_attrs		= pm8001_host_attrs,
+	.shost_groups		= pm8001_host_groups,
 	.track_queue_depth	= 1,
 };
 
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
index 7e999768bfd2..83eec16d021d 100644
--- a/drivers/scsi/pm8001/pm8001_sas.h
+++ b/drivers/scsi/pm8001/pm8001_sas.h
@@ -733,7 +733,7 @@ ssize_t pm8001_get_gsm_dump(struct device *cdev, u32, char *buf);
 int pm80xx_fatal_errors(struct pm8001_hba_info *pm8001_ha);
 void pm8001_free_dev(struct pm8001_device *pm8001_dev);
 /* ctl shared API */
-extern struct device_attribute *pm8001_host_attrs[];
+extern const struct attribute_group *pm8001_host_groups[];
 
 static inline void
 pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha,

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 36/46] scsi: pmcraid: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (34 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 35/46] scsi: pm8001: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 37/46] scsi: qedf: " Bart Van Assche
                   ` (9 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen; +Cc: linux-scsi, Bart Van Assche, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/pmcraid.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index bffd9a9349e7..ce08bd34f205 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -4097,13 +4097,14 @@ static struct device_attribute pmcraid_adapter_id_attr = {
 	.show = pmcraid_show_adapter_id,
 };
 
-static struct device_attribute *pmcraid_host_attrs[] = {
-	&pmcraid_log_level_attr,
-	&pmcraid_driver_version_attr,
-	&pmcraid_adapter_id_attr,
+static struct attribute *pmcraid_host_attrs[] = {
+	&pmcraid_log_level_attr.attr,
+	&pmcraid_driver_version_attr.attr,
+	&pmcraid_adapter_id_attr.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(pmcraid_host);
 
 /* host template structure for pmcraid driver */
 static struct scsi_host_template pmcraid_host_template = {
@@ -4126,7 +4127,7 @@ static struct scsi_host_template pmcraid_host_template = {
 	.max_sectors = PMCRAID_IOA_MAX_SECTORS,
 	.no_write_same = 1,
 	.cmd_per_lun = PMCRAID_MAX_CMD_PER_LUN,
-	.shost_attrs = pmcraid_host_attrs,
+	.shost_groups = pmcraid_host_groups,
 	.proc_name = PMCRAID_DRIVER_NAME,
 };
 

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 37/46] scsi: qedf: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (35 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 36/46] scsi: pmcraid: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 38/46] scsi: qedi: " Bart Van Assche
                   ` (8 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Saurav Kashyap, Javed Hasan,
	GR-QLogic-Storage-Upstream, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qedf/qedf.h      |  2 +-
 drivers/scsi/qedf/qedf_attr.c | 15 ++++++++++++---
 drivers/scsi/qedf/qedf_main.c |  2 +-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index ba94413fe2ea..4caddd6442f7 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -498,7 +498,7 @@ extern void qedf_process_abts_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
 extern struct qedf_ioreq *qedf_alloc_cmd(struct qedf_rport *fcport,
 	u8 cmd_type);
 
-extern struct device_attribute *qedf_host_attrs[];
+extern const struct attribute_group *qedf_host_groups[];
 extern void qedf_cmd_timer_set(struct qedf_ctx *qedf, struct qedf_ioreq *io_req,
 	unsigned int timer_msec);
 extern int qedf_init_mp_req(struct qedf_ioreq *io_req);
diff --git a/drivers/scsi/qedf/qedf_attr.c b/drivers/scsi/qedf/qedf_attr.c
index 461c0c9180c4..fdc66d294813 100644
--- a/drivers/scsi/qedf/qedf_attr.c
+++ b/drivers/scsi/qedf/qedf_attr.c
@@ -60,12 +60,21 @@ static ssize_t fka_period_show(struct device *dev,
 static DEVICE_ATTR_RO(fcoe_mac);
 static DEVICE_ATTR_RO(fka_period);
 
-struct device_attribute *qedf_host_attrs[] = {
-	&dev_attr_fcoe_mac,
-	&dev_attr_fka_period,
+static struct attribute *qedf_host_attrs[] = {
+	&dev_attr_fcoe_mac.attr,
+	&dev_attr_fka_period.attr,
 	NULL,
 };
 
+static const struct attribute_group qedf_host_attr_group = {
+	.attrs = qedf_host_attrs
+};
+
+const struct attribute_group *qedf_host_groups[] = {
+	&qedf_host_attr_group,
+	NULL
+};
+
 extern const struct qed_fcoe_ops *qed_ops;
 
 void qedf_capture_grc_dump(struct qedf_ctx *qedf)
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 42d0d941dba5..1eed6270e8f2 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -986,7 +986,7 @@ static struct scsi_host_template qedf_host_template = {
 	.cmd_per_lun	= 32,
 	.max_sectors 	= 0xffff,
 	.queuecommand 	= qedf_queuecommand,
-	.shost_attrs	= qedf_host_attrs,
+	.shost_groups	= qedf_host_groups,
 	.eh_abort_handler	= qedf_eh_abort,
 	.eh_device_reset_handler = qedf_eh_device_reset, /* lun reset */
 	.eh_target_reset_handler = qedf_eh_target_reset, /* target reset */

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 38/46] scsi: qedi: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (36 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 37/46] scsi: qedf: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 39/46] scsi: qla2xxx: Remove a declaration Bart Van Assche
                   ` (7 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Nilesh Javali, Manish Rangankar,
	GR-QLogic-Storage-Upstream, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qedi/qedi_gbl.h   |  2 +-
 drivers/scsi/qedi/qedi_iscsi.c |  2 +-
 drivers/scsi/qedi/qedi_sysfs.c | 15 ++++++++++++---
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qedi/qedi_gbl.h b/drivers/scsi/qedi/qedi_gbl.h
index 9f8e8ef405a1..72942772b198 100644
--- a/drivers/scsi/qedi/qedi_gbl.h
+++ b/drivers/scsi/qedi/qedi_gbl.h
@@ -22,7 +22,7 @@ extern struct iscsi_transport qedi_iscsi_transport;
 extern const struct qed_iscsi_ops *qedi_ops;
 extern const struct qedi_debugfs_ops qedi_debugfs_ops[];
 extern const struct file_operations qedi_dbg_fops[];
-extern struct device_attribute *qedi_shost_attrs[];
+extern const struct attribute_group *qedi_shost_groups[];
 
 int qedi_alloc_sq(struct qedi_ctx *qedi, struct qedi_endpoint *ep);
 void qedi_free_sq(struct qedi_ctx *qedi, struct qedi_endpoint *ep);
diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c
index c5260429c637..88aa7d8b11c9 100644
--- a/drivers/scsi/qedi/qedi_iscsi.c
+++ b/drivers/scsi/qedi/qedi_iscsi.c
@@ -58,7 +58,7 @@ struct scsi_host_template qedi_host_template = {
 	.max_sectors = 0xffff,
 	.dma_boundary = QEDI_HW_DMA_BOUNDARY,
 	.cmd_per_lun = 128,
-	.shost_attrs = qedi_shost_attrs,
+	.shost_groups = qedi_shost_groups,
 };
 
 static void qedi_conn_free_login_resources(struct qedi_ctx *qedi,
diff --git a/drivers/scsi/qedi/qedi_sysfs.c b/drivers/scsi/qedi/qedi_sysfs.c
index be174d30eb7c..b00a7e08ef53 100644
--- a/drivers/scsi/qedi/qedi_sysfs.c
+++ b/drivers/scsi/qedi/qedi_sysfs.c
@@ -42,8 +42,17 @@ static ssize_t speed_show(struct device *dev,
 static DEVICE_ATTR_RO(port_state);
 static DEVICE_ATTR_RO(speed);
 
-struct device_attribute *qedi_shost_attrs[] = {
-	&dev_attr_port_state,
-	&dev_attr_speed,
+static struct attribute *qedi_shost_attrs[] = {
+	&dev_attr_port_state.attr,
+	&dev_attr_speed.attr,
+	NULL
+};
+
+static const struct attribute_group qedi_shost_attr_group = {
+	.attrs = qedi_shost_attrs
+};
+
+const struct attribute_group *qedi_shost_groups[] = {
+	&qedi_shost_attr_group,
 	NULL
 };

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 39/46] scsi: qla2xxx: Remove a declaration
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (37 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 38/46] scsi: qedi: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 40/46] scsi: qla2xxx: Switch to attribute groups Bart Van Assche
                   ` (6 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Nilesh Javali,
	GR-QLogic-Storage-Upstream, James E.J. Bottomley

Since there is no definition for the qla2x00_host_attrs_dm array, remove
its declaration.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla2xxx/qla_gbl.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 8aadcdeca6cb..5ff974e98783 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -743,7 +743,6 @@ uint qla25xx_fdmi_port_speed_currently(struct qla_hw_data *);
  */
 struct device_attribute;
 extern struct device_attribute *qla2x00_host_attrs[];
-extern struct device_attribute *qla2x00_host_attrs_dm[];
 struct fc_function_template;
 extern struct fc_function_template qla2xxx_transport_functions;
 extern struct fc_function_template qla2xxx_transport_vport_functions;

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 40/46] scsi: qla2xxx: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (38 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 39/46] scsi: qla2xxx: Remove a declaration Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 41/46] scsi: qla4xxx: " Bart Van Assche
                   ` (5 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Nilesh Javali,
	GR-QLogic-Storage-Upstream, James E.J. Bottomley

struct device supports attribute groups directly but does not support
struct device_attribute directly. Hence switch to attribute groups.
Additionally, remove qla_insert_tgt_attrs() and replace it with
qla_host_attr_is_visible().

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla2xxx/qla_attr.c | 118 +++++++++++++++++---------------
 drivers/scsi/qla2xxx/qla_gbl.h  |   3 +-
 drivers/scsi/qla2xxx/qla_os.c   |   5 +-
 3 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index cb5f2ecb652d..cc271d744547 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -2481,72 +2481,76 @@ static DEVICE_ATTR(port_no, 0444, qla2x00_port_no_show, NULL);
 static DEVICE_ATTR(fw_attr, 0444, qla2x00_fw_attr_show, NULL);
 static DEVICE_ATTR_RO(edif_doorbell);
 
-
-struct device_attribute *qla2x00_host_attrs[] = {
-	&dev_attr_driver_version,
-	&dev_attr_fw_version,
-	&dev_attr_serial_num,
-	&dev_attr_isp_name,
-	&dev_attr_isp_id,
-	&dev_attr_model_name,
-	&dev_attr_model_desc,
-	&dev_attr_pci_info,
-	&dev_attr_link_state,
-	&dev_attr_zio,
-	&dev_attr_zio_timer,
-	&dev_attr_beacon,
-	&dev_attr_beacon_config,
-	&dev_attr_optrom_bios_version,
-	&dev_attr_optrom_efi_version,
-	&dev_attr_optrom_fcode_version,
-	&dev_attr_optrom_fw_version,
-	&dev_attr_84xx_fw_version,
-	&dev_attr_total_isp_aborts,
-	&dev_attr_serdes_version,
-	&dev_attr_mpi_version,
-	&dev_attr_phy_version,
-	&dev_attr_flash_block_size,
-	&dev_attr_vlan_id,
-	&dev_attr_vn_port_mac_address,
-	&dev_attr_fabric_param,
-	&dev_attr_fw_state,
-	&dev_attr_optrom_gold_fw_version,
-	&dev_attr_thermal_temp,
-	&dev_attr_diag_requests,
-	&dev_attr_diag_megabytes,
-	&dev_attr_fw_dump_size,
-	&dev_attr_allow_cna_fw_dump,
-	&dev_attr_pep_version,
-	&dev_attr_min_supported_speed,
-	&dev_attr_max_supported_speed,
-	&dev_attr_zio_threshold,
-	&dev_attr_dif_bundle_statistics,
-	&dev_attr_port_speed,
-	&dev_attr_port_no,
-	&dev_attr_fw_attr,
-	&dev_attr_dport_diagnostics,
-	&dev_attr_edif_doorbell,
-	&dev_attr_mpi_pause,
+static struct attribute *qla2x00_host_attrs[] = {
+	&dev_attr_driver_version.attr,
+	&dev_attr_fw_version.attr,
+	&dev_attr_serial_num.attr,
+	&dev_attr_isp_name.attr,
+	&dev_attr_isp_id.attr,
+	&dev_attr_model_name.attr,
+	&dev_attr_model_desc.attr,
+	&dev_attr_pci_info.attr,
+	&dev_attr_link_state.attr,
+	&dev_attr_zio.attr,
+	&dev_attr_zio_timer.attr,
+	&dev_attr_beacon.attr,
+	&dev_attr_beacon_config.attr,
+	&dev_attr_optrom_bios_version.attr,
+	&dev_attr_optrom_efi_version.attr,
+	&dev_attr_optrom_fcode_version.attr,
+	&dev_attr_optrom_fw_version.attr,
+	&dev_attr_84xx_fw_version.attr,
+	&dev_attr_total_isp_aborts.attr,
+	&dev_attr_serdes_version.attr,
+	&dev_attr_mpi_version.attr,
+	&dev_attr_phy_version.attr,
+	&dev_attr_flash_block_size.attr,
+	&dev_attr_vlan_id.attr,
+	&dev_attr_vn_port_mac_address.attr,
+	&dev_attr_fabric_param.attr,
+	&dev_attr_fw_state.attr,
+	&dev_attr_optrom_gold_fw_version.attr,
+	&dev_attr_thermal_temp.attr,
+	&dev_attr_diag_requests.attr,
+	&dev_attr_diag_megabytes.attr,
+	&dev_attr_fw_dump_size.attr,
+	&dev_attr_allow_cna_fw_dump.attr,
+	&dev_attr_pep_version.attr,
+	&dev_attr_min_supported_speed.attr,
+	&dev_attr_max_supported_speed.attr,
+	&dev_attr_zio_threshold.attr,
+	&dev_attr_dif_bundle_statistics.attr,
+	&dev_attr_port_speed.attr,
+	&dev_attr_port_no.attr,
+	&dev_attr_fw_attr.attr,
+	&dev_attr_dport_diagnostics.attr,
+	&dev_attr_edif_doorbell.attr,
+	&dev_attr_mpi_pause.attr,
 	NULL, /* reserve for qlini_mode */
 	NULL, /* reserve for ql2xiniexchg */
 	NULL, /* reserve for ql2xexchoffld */
 	NULL,
 };
 
-void qla_insert_tgt_attrs(void)
+static umode_t qla_host_attr_is_visible(struct kobject *kobj,
+					struct attribute *attr, int i)
 {
-	struct device_attribute **attr;
+	if (attr == &dev_attr_qlini_mode.attr ||
+	    attr == &dev_attr_ql2xiniexchg.attr ||
+	    attr == &dev_attr_ql2xexchoffld.attr)
+		return ql2x_ini_mode == QLA2XXX_INI_MODE_DUAL ? attr->mode : 0;
+	return attr->mode;
+}
 
-	/* advance to empty slot */
-	for (attr = &qla2x00_host_attrs[0]; *attr; ++attr)
-		continue;
+static const struct attribute_group qla2x00_host_attr_group = {
+	.is_visible = qla_host_attr_is_visible,
+	.attrs = qla2x00_host_attrs
+};
 
-	*attr = &dev_attr_qlini_mode;
-	attr++;
-	*attr = &dev_attr_ql2xiniexchg;
-	attr++;
-	*attr = &dev_attr_ql2xexchoffld;
-}
+const struct attribute_group *qla2x00_host_groups[] = {
+	&qla2x00_host_attr_group,
+	NULL
+};
 
 /* Host attributes. */
 
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 5ff974e98783..3c4fa8bac88d 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -742,7 +742,7 @@ uint qla25xx_fdmi_port_speed_currently(struct qla_hw_data *);
  * Global Function Prototypes in qla_attr.c source file.
  */
 struct device_attribute;
-extern struct device_attribute *qla2x00_host_attrs[];
+extern const struct attribute_group *qla2x00_host_groups[];
 struct fc_function_template;
 extern struct fc_function_template qla2xxx_transport_functions;
 extern struct fc_function_template qla2xxx_transport_vport_functions;
@@ -756,7 +756,6 @@ extern int qla2x00_echo_test(scsi_qla_host_t *,
 extern int qla24xx_update_all_fcp_prio(scsi_qla_host_t *);
 extern int qla24xx_fcp_prio_cfg_valid(scsi_qla_host_t *,
 	struct qla_fcp_prio_cfg *, uint8_t);
-void qla_insert_tgt_attrs(void);
 /*
  * Global Function Prototypes in qla_dfs.c source file.
  */
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 03ff2596715b..4f828ce25b25 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -7943,7 +7943,7 @@ struct scsi_host_template qla2xxx_driver_template = {
 	.sg_tablesize		= SG_ALL,
 
 	.max_sectors		= 0xFFFF,
-	.shost_attrs		= qla2x00_host_attrs,
+	.shost_groups		= qla2x00_host_groups,
 
 	.supported_mode		= MODE_INITIATOR,
 	.track_queue_depth	= 1,
@@ -8131,9 +8131,6 @@ qla2x00_module_init(void)
 	if (ql2xextended_error_logging == 1)
 		ql2xextended_error_logging = QL_DBG_DEFAULT1_MASK;
 
-	if (ql2x_ini_mode == QLA2XXX_INI_MODE_DUAL)
-		qla_insert_tgt_attrs();
-
 	qla2xxx_transport_template =
 	    fc_attach_transport(&qla2xxx_transport_functions);
 	if (!qla2xxx_transport_template) {

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 41/46] scsi: qla4xxx: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (39 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 40/46] scsi: qla2xxx: Switch to attribute groups Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 42/46] scsi: smartpqi: " Bart Van Assche
                   ` (4 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Nilesh Javali, Manish Rangankar,
	GR-QLogic-Storage-Upstream, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla4xxx/ql4_attr.c | 41 ++++++++++++++++++++-------------
 drivers/scsi/qla4xxx/ql4_glbl.h |  3 ++-
 drivers/scsi/qla4xxx/ql4_os.c   |  2 +-
 3 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_attr.c b/drivers/scsi/qla4xxx/ql4_attr.c
index ec4352818fbf..abfa6ef60480 100644
--- a/drivers/scsi/qla4xxx/ql4_attr.c
+++ b/drivers/scsi/qla4xxx/ql4_attr.c
@@ -330,21 +330,30 @@ static DEVICE_ATTR(fw_ext_timestamp, S_IRUGO, qla4xxx_fw_ext_timestamp_show,
 static DEVICE_ATTR(fw_load_src, S_IRUGO, qla4xxx_fw_load_src_show, NULL);
 static DEVICE_ATTR(fw_uptime, S_IRUGO, qla4xxx_fw_uptime_show, NULL);
 
-struct device_attribute *qla4xxx_host_attrs[] = {
-	&dev_attr_fw_version,
-	&dev_attr_serial_num,
-	&dev_attr_iscsi_version,
-	&dev_attr_optrom_version,
-	&dev_attr_board_id,
-	&dev_attr_fw_state,
-	&dev_attr_phy_port_cnt,
-	&dev_attr_phy_port_num,
-	&dev_attr_iscsi_func_cnt,
-	&dev_attr_hba_model,
-	&dev_attr_fw_timestamp,
-	&dev_attr_fw_build_user,
-	&dev_attr_fw_ext_timestamp,
-	&dev_attr_fw_load_src,
-	&dev_attr_fw_uptime,
+static struct attribute *qla4xxx_host_attrs[] = {
+	&dev_attr_fw_version.attr,
+	&dev_attr_serial_num.attr,
+	&dev_attr_iscsi_version.attr,
+	&dev_attr_optrom_version.attr,
+	&dev_attr_board_id.attr,
+	&dev_attr_fw_state.attr,
+	&dev_attr_phy_port_cnt.attr,
+	&dev_attr_phy_port_num.attr,
+	&dev_attr_iscsi_func_cnt.attr,
+	&dev_attr_hba_model.attr,
+	&dev_attr_fw_timestamp.attr,
+	&dev_attr_fw_build_user.attr,
+	&dev_attr_fw_ext_timestamp.attr,
+	&dev_attr_fw_load_src.attr,
+	&dev_attr_fw_uptime.attr,
 	NULL,
 };
+
+static const struct attribute_group qla4xxx_host_attr_group = {
+	.attrs = qla4xxx_host_attrs
+};
+
+const struct attribute_group *qla4xxx_host_groups[] = {
+	&qla4xxx_host_attr_group,
+	NULL
+};
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index ea60057b2e20..c0873381508d 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -286,5 +286,6 @@ extern int ql4xenablemsix;
 extern int ql4xmdcapmask;
 extern int ql4xenablemd;
 
-extern struct device_attribute *qla4xxx_host_attrs[];
+extern const struct attribute_group *qla4xxx_host_groups[];
+
 #endif /* _QLA4x_GBL_H */
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index f1ea65c6e5f5..d0cf7d1a364e 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -241,7 +241,7 @@ static struct scsi_host_template qla4xxx_driver_template = {
 	.sg_tablesize		= SG_ALL,
 
 	.max_sectors		= 0xFFFF,
-	.shost_attrs		= qla4xxx_host_attrs,
+	.shost_groups		= qla4xxx_host_groups,
 	.host_reset		= qla4xxx_host_reset,
 	.vendor_id		= SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC,
 };

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 42/46] scsi: smartpqi: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (40 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 41/46] scsi: qla4xxx: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 43/46] scsi: snic: " Bart Van Assche
                   ` (3 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Don Brace, James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/smartpqi/smartpqi_init.c | 46 +++++++++++++++------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index b966ce3b4385..6a6a83331ef0 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -6847,20 +6847,22 @@ static DEVICE_ATTR(enable_r5_writes, 0644,
 static DEVICE_ATTR(enable_r6_writes, 0644,
 	pqi_host_enable_r6_writes_show, pqi_host_enable_r6_writes_store);
 
-static struct device_attribute *pqi_shost_attrs[] = {
-	&dev_attr_driver_version,
-	&dev_attr_firmware_version,
-	&dev_attr_model,
-	&dev_attr_serial_number,
-	&dev_attr_vendor,
-	&dev_attr_rescan,
-	&dev_attr_lockup_action,
-	&dev_attr_enable_stream_detection,
-	&dev_attr_enable_r5_writes,
-	&dev_attr_enable_r6_writes,
+static struct attribute *pqi_shost_attrs[] = {
+	&dev_attr_driver_version.attr,
+	&dev_attr_firmware_version.attr,
+	&dev_attr_model.attr,
+	&dev_attr_serial_number.attr,
+	&dev_attr_vendor.attr,
+	&dev_attr_rescan.attr,
+	&dev_attr_lockup_action.attr,
+	&dev_attr_enable_stream_detection.attr,
+	&dev_attr_enable_r5_writes.attr,
+	&dev_attr_enable_r6_writes.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(pqi_shost);
+
 static ssize_t pqi_unique_id_show(struct device *dev,
 	struct device_attribute *attr, char *buffer)
 {
@@ -7129,17 +7131,19 @@ static DEVICE_ATTR(ssd_smart_path_enabled, 0444, pqi_ssd_smart_path_enabled_show
 static DEVICE_ATTR(raid_level, 0444, pqi_raid_level_show, NULL);
 static DEVICE_ATTR(raid_bypass_cnt, 0444, pqi_raid_bypass_cnt_show, NULL);
 
-static struct device_attribute *pqi_sdev_attrs[] = {
-	&dev_attr_lunid,
-	&dev_attr_unique_id,
-	&dev_attr_path_info,
-	&dev_attr_sas_address,
-	&dev_attr_ssd_smart_path_enabled,
-	&dev_attr_raid_level,
-	&dev_attr_raid_bypass_cnt,
+static struct attribute *pqi_sdev_attrs[] = {
+	&dev_attr_lunid.attr,
+	&dev_attr_unique_id.attr,
+	&dev_attr_path_info.attr,
+	&dev_attr_sas_address.attr,
+	&dev_attr_ssd_smart_path_enabled.attr,
+	&dev_attr_raid_level.attr,
+	&dev_attr_raid_bypass_cnt.attr,
 	NULL
 };
 
+ATTRIBUTE_GROUPS(pqi_sdev);
+
 static struct scsi_host_template pqi_driver_template = {
 	.module = THIS_MODULE,
 	.name = DRIVER_NAME_SHORT,
@@ -7153,8 +7157,8 @@ static struct scsi_host_template pqi_driver_template = {
 	.slave_alloc = pqi_slave_alloc,
 	.slave_configure = pqi_slave_configure,
 	.map_queues = pqi_map_queues,
-	.sdev_attrs = pqi_sdev_attrs,
-	.shost_attrs = pqi_shost_attrs,
+	.sdev_groups = pqi_sdev_groups,
+	.shost_groups = pqi_shost_groups,
 };
 
 static int pqi_register_scsi(struct pqi_ctrl_info *ctrl_info)

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 43/46] scsi: snic: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (41 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 42/46] scsi: smartpqi: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 44/46] scsi: unisys: Remove the shost_attrs member Bart Van Assche
                   ` (2 subsequent siblings)
  45 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Karan Tilak Kumar, Sesidhar Baddela,
	James E.J. Bottomley

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/snic/snic.h       |  2 +-
 drivers/scsi/snic/snic_attrs.c | 19 ++++++++++++++-----
 drivers/scsi/snic/snic_main.c  |  2 +-
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/snic/snic.h b/drivers/scsi/snic/snic.h
index f4c666285bba..4ec7e30678e1 100644
--- a/drivers/scsi/snic/snic.h
+++ b/drivers/scsi/snic/snic.h
@@ -374,7 +374,7 @@ int snic_glob_init(void);
 void snic_glob_cleanup(void);
 
 extern struct workqueue_struct *snic_event_queue;
-extern struct device_attribute *snic_attrs[];
+extern const struct attribute_group *snic_host_groups[];
 
 int snic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
 int snic_abort_cmd(struct scsi_cmnd *);
diff --git a/drivers/scsi/snic/snic_attrs.c b/drivers/scsi/snic/snic_attrs.c
index 32d5d556b6f8..dc03ce1ec909 100644
--- a/drivers/scsi/snic/snic_attrs.c
+++ b/drivers/scsi/snic/snic_attrs.c
@@ -68,10 +68,19 @@ static DEVICE_ATTR(snic_state, S_IRUGO, snic_show_state, NULL);
 static DEVICE_ATTR(drv_version, S_IRUGO, snic_show_drv_version, NULL);
 static DEVICE_ATTR(link_state, S_IRUGO, snic_show_link_state, NULL);
 
-struct device_attribute *snic_attrs[] = {
-	&dev_attr_snic_sym_name,
-	&dev_attr_snic_state,
-	&dev_attr_drv_version,
-	&dev_attr_link_state,
+static struct attribute *snic_host_attrs[] = {
+	&dev_attr_snic_sym_name.attr,
+	&dev_attr_snic_state.attr,
+	&dev_attr_drv_version.attr,
+	&dev_attr_link_state.attr,
 	NULL,
 };
+
+static const struct attribute_group snic_host_attr_group = {
+	.attrs = snic_host_attrs
+};
+
+const struct attribute_group *snic_host_groups[] = {
+	&snic_host_attr_group,
+	NULL
+};
diff --git a/drivers/scsi/snic/snic_main.c b/drivers/scsi/snic/snic_main.c
index 14f4ce665e58..29d56396058c 100644
--- a/drivers/scsi/snic/snic_main.c
+++ b/drivers/scsi/snic/snic_main.c
@@ -129,7 +129,7 @@ static struct scsi_host_template snic_host_template = {
 	.can_queue = SNIC_MAX_IO_REQ,
 	.sg_tablesize = SNIC_MAX_SG_DESC_CNT,
 	.max_sectors = 0x800,
-	.shost_attrs = snic_attrs,
+	.shost_groups = snic_host_groups,
 	.track_queue_depth = 1,
 	.cmd_size = sizeof(struct snic_internal_io_state),
 	.proc_name = "snic_scsi",

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 44/46] scsi: unisys: Remove the shost_attrs member
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (42 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 43/46] scsi: snic: " Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-09  2:11   ` Kershner, David A
  2021-10-09  5:55   ` Greg Kroah-Hartman
  2021-10-08 20:23 ` [PATCH v3 45/46] scsi: usb: Switch to attribute groups Bart Van Assche
  2021-10-08 20:23 ` [PATCH v3 46/46] scsi: core: Remove two host template members that are no longer used Bart Van Assche
  45 siblings, 2 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, David Kershner, Greg Kroah-Hartman,
	Dan Carpenter, Song Chen, Fabio M. De Francesco

This patch prepares for removal of the shost_attrs member from struct
scsi_host_template.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/staging/unisys/visorhba/visorhba_main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c
index 41f8a72a2a95..f0c647b97354 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -584,7 +584,6 @@ static struct scsi_host_template visorhba_driver_template = {
 	.eh_device_reset_handler = visorhba_device_reset_handler,
 	.eh_bus_reset_handler = visorhba_bus_reset_handler,
 	.eh_host_reset_handler = visorhba_host_reset_handler,
-	.shost_attrs = NULL,
 #define visorhba_MAX_CMNDS 128
 	.can_queue = visorhba_MAX_CMNDS,
 	.sg_tablesize = 64,

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 45/46] scsi: usb: Switch to attribute groups
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (43 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 44/46] scsi: unisys: Remove the shost_attrs member Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-09  5:55   ` Greg Kroah-Hartman
  2021-10-08 20:23 ` [PATCH v3 46/46] scsi: core: Remove two host template members that are no longer used Bart Van Assche
  45 siblings, 1 reply; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Alan Stern, Greg Kroah-Hartman

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

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/usb/storage/scsiglue.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index e5a971b83e3f..4e5a928f0368 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -588,11 +588,13 @@ static ssize_t max_sectors_store(struct device *dev, struct device_attribute *at
 }
 static DEVICE_ATTR_RW(max_sectors);
 
-static struct device_attribute *sysfs_device_attr_list[] = {
-	&dev_attr_max_sectors,
+static struct attribute *usb_sdev_attrs[] = {
+	&dev_attr_max_sectors.attr,
 	NULL,
 };
 
+ATTRIBUTE_GROUPS(usb_sdev);
+
 /*
  * this defines our host template, with which we'll allocate hosts
  */
@@ -653,7 +655,7 @@ static const struct scsi_host_template usb_stor_host_template = {
 	.skip_settle_delay =		1,
 
 	/* sysfs device attributes */
-	.sdev_attrs =			sysfs_device_attr_list,
+	.sdev_groups =			usb_sdev_groups,
 
 	/* module management */
 	.module =			THIS_MODULE

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [PATCH v3 46/46] scsi: core: Remove two host template members that are no longer used
  2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
                   ` (44 preceding siblings ...)
  2021-10-08 20:23 ` [PATCH v3 45/46] scsi: usb: Switch to attribute groups Bart Van Assche
@ 2021-10-08 20:23 ` Bart Van Assche
  2021-10-11 13:38   ` Benjamin Block
  45 siblings, 1 reply; 57+ messages in thread
From: Bart Van Assche @ 2021-10-08 20:23 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, Greg Kroah-Hartman, James E.J. Bottomley

All SCSI drivers have been converted to use shost_groups and sdev_groups
instead of shost_attrs or sdev_attrs. Hence remove shost_attrs and
sdev_attrs.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/hosts.c       |  9 ---------
 drivers/scsi/scsi_priv.h   |  2 --
 drivers/scsi/scsi_sysfs.c  | 28 ----------------------------
 include/scsi/scsi_device.h |  1 -
 include/scsi/scsi_host.h   | 11 -----------
 5 files changed, 51 deletions(-)

diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 3443f009a9e8..b3b7b55a90c6 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -482,15 +482,6 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
 	dev_set_name(&shost->shost_dev, "host%d", shost->host_no);
 	shost->shost_dev.groups = shost->shost_dev_attr_groups;
 	shost->shost_dev_attr_groups[j++] = &scsi_shost_attr_group;
-	if (sht->shost_attrs) {
-		shost->lld_attr_group = (struct attribute_group){
-			.attrs = scsi_convert_dev_attrs(&shost->shost_gendev,
-							sht->shost_attrs)
-		};
-		if (shost->lld_attr_group.attrs)
-			shost->shost_dev_attr_groups[j++] =
-				&shost->lld_attr_group;
-	}
 	if (sht->shost_groups) {
 		for (i = 0; sht->shost_groups[i] &&
 			     j < ARRAY_SIZE(shost->shost_dev_attr_groups);
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index a5a2f18cc734..b7a82c426058 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -137,8 +137,6 @@ extern int scsi_sysfs_add_sdev(struct scsi_device *);
 extern int scsi_sysfs_add_host(struct Scsi_Host *);
 extern int scsi_sysfs_register(void);
 extern void scsi_sysfs_unregister(void);
-struct attribute **scsi_convert_dev_attrs(struct device *dev,
-					  struct device_attribute **dev_attr);
 extern void scsi_sysfs_device_initialize(struct scsi_device *);
 extern int scsi_sysfs_target_initialize(struct scsi_device *);
 extern struct scsi_transport_template blank_transport_template;
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 05b4d69d53d4..2e69fad0dc51 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1563,26 +1563,6 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost)
 	return 0;
 }
 
-/*
- * Convert an array of struct device_attribute pointers into an array of
- * struct attribute pointers.
- */
-struct attribute **scsi_convert_dev_attrs(struct device *dev,
-					  struct device_attribute **dev_attr)
-{
-	struct attribute **attrs;
-	int i;
-
-	for (i = 0; dev_attr[i]; i++)
-		;
-	attrs = devm_kzalloc(dev, (i + 1) * sizeof(*attrs), GFP_KERNEL);
-	if (!attrs)
-		return NULL;
-	for (i = 0; dev_attr[i]; i++)
-		attrs[i] = &dev_attr[i]->attr;
-	return attrs;
-}
-
 static struct device_type scsi_dev_type = {
 	.name =		"scsi_device",
 	.release =	scsi_device_dev_release,
@@ -1603,14 +1583,6 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev)
 	dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%llu",
 		     sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
 	sdev->gendev_attr_groups[j++] = &scsi_sdev_attr_group;
-	if (hostt->sdev_attrs) {
-		sdev->lld_attr_group = (struct attribute_group){
-			.attrs = scsi_convert_dev_attrs(&sdev->sdev_gendev,
-							hostt->sdev_attrs)
-		};
-		if (sdev->lld_attr_group.attrs)
-			sdev->gendev_attr_groups[j++] = &sdev->lld_attr_group;
-	}
 	if (hostt->sdev_groups) {
 		for (i = 0; hostt->sdev_groups[i] &&
 			     j < ARRAY_SIZE(sdev->gendev_attr_groups);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 01732aabd7c3..b1e9b3bd3a60 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -225,7 +225,6 @@ struct scsi_device {
 
 	struct device		sdev_gendev,
 				sdev_dev;
-	struct attribute_group	lld_attr_group;
 	/*
 	 * The array size 6 provides space for one attribute group for the
 	 * SCSI core, four attribute groups defined by SCSI LLDs and one
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index ab8775811e6f..c2b4d6677a76 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -473,16 +473,6 @@ struct scsi_host_template {
 	 */
 #define SCSI_DEFAULT_HOST_BLOCKED	7
 
-	/*
-	 * Pointer to the sysfs class properties for this host, NULL terminated.
-	 */
-	struct device_attribute **shost_attrs;
-
-	/*
-	 * Pointer to the SCSI device properties for this host, NULL terminated.
-	 */
-	struct device_attribute **sdev_attrs;
-
 	/*
 	 * Pointer to the SCSI host sysfs attribute groups, NULL terminated.
 	 */
@@ -700,7 +690,6 @@ struct Scsi_Host {
 
 	/* ldm bits */
 	struct device		shost_gendev, shost_dev;
-	struct attribute_group	lld_attr_group;
 	/*
 	 * The array size 3 provides space for one attribute group defined by
 	 * the SCSI core, one attribute group defined by the SCSI LLD and one

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* RE: [PATCH v3 44/46] scsi: unisys: Remove the shost_attrs member
  2021-10-08 20:23 ` [PATCH v3 44/46] scsi: unisys: Remove the shost_attrs member Bart Van Assche
@ 2021-10-09  2:11   ` Kershner, David A
  2021-10-09  5:55   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 57+ messages in thread
From: Kershner, David A @ 2021-10-09  2:11 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen
  Cc: linux-scsi, Greg Kroah-Hartman, Dan Carpenter, Song Chen,
	Fabio M. De Francesco

[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]



> -----Original Message-----
> From: Bart Van Assche <bvanassche@acm.org>
> Sent: Friday, October 8, 2021 4:24 PM
> To: Martin K . Petersen <martin.petersen@oracle.com>
> Cc: linux-scsi@vger.kernel.org; Bart Van Assche <bvanassche@acm.org>;
> Kershner, David A <David.Kershner@unisys.com>; Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>; Dan Carpenter
> <dan.carpenter@oracle.com>; Song Chen <chensong_2000@189.cn>; Fabio
> M. De Francesco <fmdefrancesco@gmail.com>
> Subject: [PATCH v3 44/46] scsi: unisys: Remove the shost_attrs member
> 
> This patch prepares for removal of the shost_attrs member from struct
> scsi_host_template.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Acked-by: David Kershner <david.kershner@unisys.com>

> ---
>  drivers/staging/unisys/visorhba/visorhba_main.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c
> b/drivers/staging/unisys/visorhba/visorhba_main.c
> index 41f8a72a2a95..f0c647b97354 100644
> --- a/drivers/staging/unisys/visorhba/visorhba_main.c
> +++ b/drivers/staging/unisys/visorhba/visorhba_main.c
> @@ -584,7 +584,6 @@ static struct scsi_host_template
> visorhba_driver_template = {
>         .eh_device_reset_handler = visorhba_device_reset_handler,
>         .eh_bus_reset_handler = visorhba_bus_reset_handler,
>         .eh_host_reset_handler = visorhba_host_reset_handler,
> -       .shost_attrs = NULL,
>  #define visorhba_MAX_CMNDS 128
>         .can_queue = visorhba_MAX_CMNDS,
>         .sg_tablesize = 64,

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 7864 bytes --]

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH v3 45/46] scsi: usb: Switch to attribute groups
  2021-10-08 20:23 ` [PATCH v3 45/46] scsi: usb: Switch to attribute groups Bart Van Assche
@ 2021-10-09  5:55   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-09  5:55 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Martin K . Petersen, linux-scsi, Alan Stern

On Fri, Oct 08, 2021 at 01:23:52PM -0700, Bart Van Assche wrote:
> struct device supports attribute groups directly but does not support
> struct device_attribute directly. Hence switch to attribute groups.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/usb/storage/scsiglue.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
> index e5a971b83e3f..4e5a928f0368 100644
> --- a/drivers/usb/storage/scsiglue.c
> +++ b/drivers/usb/storage/scsiglue.c
> @@ -588,11 +588,13 @@ static ssize_t max_sectors_store(struct device *dev, struct device_attribute *at
>  }
>  static DEVICE_ATTR_RW(max_sectors);
>  
> -static struct device_attribute *sysfs_device_attr_list[] = {
> -	&dev_attr_max_sectors,
> +static struct attribute *usb_sdev_attrs[] = {
> +	&dev_attr_max_sectors.attr,
>  	NULL,
>  };
>  
> +ATTRIBUTE_GROUPS(usb_sdev);
> +
>  /*
>   * this defines our host template, with which we'll allocate hosts
>   */
> @@ -653,7 +655,7 @@ static const struct scsi_host_template usb_stor_host_template = {
>  	.skip_settle_delay =		1,
>  
>  	/* sysfs device attributes */
> -	.sdev_attrs =			sysfs_device_attr_list,
> +	.sdev_groups =			usb_sdev_groups,
>  
>  	/* module management */
>  	.module =			THIS_MODULE


Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH v3 44/46] scsi: unisys: Remove the shost_attrs member
  2021-10-08 20:23 ` [PATCH v3 44/46] scsi: unisys: Remove the shost_attrs member Bart Van Assche
  2021-10-09  2:11   ` Kershner, David A
@ 2021-10-09  5:55   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-09  5:55 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, linux-scsi, David Kershner, Dan Carpenter,
	Song Chen, Fabio M. De Francesco

On Fri, Oct 08, 2021 at 01:23:51PM -0700, Bart Van Assche wrote:
> This patch prepares for removal of the shost_attrs member from struct
> scsi_host_template.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/staging/unisys/visorhba/visorhba_main.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c
> index 41f8a72a2a95..f0c647b97354 100644
> --- a/drivers/staging/unisys/visorhba/visorhba_main.c
> +++ b/drivers/staging/unisys/visorhba/visorhba_main.c
> @@ -584,7 +584,6 @@ static struct scsi_host_template visorhba_driver_template = {
>  	.eh_device_reset_handler = visorhba_device_reset_handler,
>  	.eh_bus_reset_handler = visorhba_bus_reset_handler,
>  	.eh_host_reset_handler = visorhba_host_reset_handler,
> -	.shost_attrs = NULL,
>  #define visorhba_MAX_CMNDS 128
>  	.can_queue = visorhba_MAX_CMNDS,
>  	.sg_tablesize = 64,


Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH v3 35/46] scsi: pm8001: Switch to attribute groups
  2021-10-08 20:23 ` [PATCH v3 35/46] scsi: pm8001: " Bart Van Assche
@ 2021-10-11  4:54   ` Jinpu Wang
  0 siblings, 0 replies; 57+ messages in thread
From: Jinpu Wang @ 2021-10-11  4:54 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, Linux SCSI Mailinglist, Jack Wang,
	James E.J. Bottomley

On Fri, Oct 8, 2021 at 10:25 PM Bart Van Assche <bvanassche@acm.org> wrote:
>
> struct device supports attribute groups directly but does not support
> struct device_attribute directly. Hence switch to attribute groups.
>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
lgtm.
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Thanks!
> ---
>  drivers/scsi/pm8001/pm8001_ctl.c  | 64 +++++++++++++++++--------------
>  drivers/scsi/pm8001/pm8001_init.c |  2 +-
>  drivers/scsi/pm8001/pm8001_sas.h  |  2 +-
>  3 files changed, 38 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
> index b25e447aa3bd..397eb9f6a1dd 100644
> --- a/drivers/scsi/pm8001/pm8001_ctl.c
> +++ b/drivers/scsi/pm8001/pm8001_ctl.c
> @@ -1002,34 +1002,42 @@ static ssize_t ctl_iop1_count_show(struct device *cdev,
>  }
>  static DEVICE_ATTR_RO(ctl_iop1_count);
>
> -struct device_attribute *pm8001_host_attrs[] = {
> -       &dev_attr_interface_rev,
> -       &dev_attr_controller_fatal_error,
> -       &dev_attr_fw_version,
> -       &dev_attr_update_fw,
> -       &dev_attr_aap_log,
> -       &dev_attr_iop_log,
> -       &dev_attr_fatal_log,
> -       &dev_attr_non_fatal_log,
> -       &dev_attr_non_fatal_count,
> -       &dev_attr_gsm_log,
> -       &dev_attr_max_out_io,
> -       &dev_attr_max_devices,
> -       &dev_attr_max_sg_list,
> -       &dev_attr_sas_spec_support,
> -       &dev_attr_logging_level,
> -       &dev_attr_event_log_size,
> -       &dev_attr_host_sas_address,
> -       &dev_attr_bios_version,
> -       &dev_attr_ib_log,
> -       &dev_attr_ob_log,
> -       &dev_attr_ila_version,
> -       &dev_attr_inc_fw_ver,
> -       &dev_attr_ctl_mpi_state,
> -       &dev_attr_ctl_hmi_error,
> -       &dev_attr_ctl_raae_count,
> -       &dev_attr_ctl_iop0_count,
> -       &dev_attr_ctl_iop1_count,
> +static struct attribute *pm8001_host_attrs[] = {
> +       &dev_attr_interface_rev.attr,
> +       &dev_attr_controller_fatal_error.attr,
> +       &dev_attr_fw_version.attr,
> +       &dev_attr_update_fw.attr,
> +       &dev_attr_aap_log.attr,
> +       &dev_attr_iop_log.attr,
> +       &dev_attr_fatal_log.attr,
> +       &dev_attr_non_fatal_log.attr,
> +       &dev_attr_non_fatal_count.attr,
> +       &dev_attr_gsm_log.attr,
> +       &dev_attr_max_out_io.attr,
> +       &dev_attr_max_devices.attr,
> +       &dev_attr_max_sg_list.attr,
> +       &dev_attr_sas_spec_support.attr,
> +       &dev_attr_logging_level.attr,
> +       &dev_attr_event_log_size.attr,
> +       &dev_attr_host_sas_address.attr,
> +       &dev_attr_bios_version.attr,
> +       &dev_attr_ib_log.attr,
> +       &dev_attr_ob_log.attr,
> +       &dev_attr_ila_version.attr,
> +       &dev_attr_inc_fw_ver.attr,
> +       &dev_attr_ctl_mpi_state.attr,
> +       &dev_attr_ctl_hmi_error.attr,
> +       &dev_attr_ctl_raae_count.attr,
> +       &dev_attr_ctl_iop0_count.attr,
> +       &dev_attr_ctl_iop1_count.attr,
>         NULL,
>  };
>
> +static const struct attribute_group pm8001_host_attr_group = {
> +       .attrs = pm8001_host_attrs
> +};
> +
> +const struct attribute_group *pm8001_host_groups[] = {
> +       &pm8001_host_attr_group,
> +       NULL
> +};
> diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
> index 7082fecf7ce8..bed8cc125544 100644
> --- a/drivers/scsi/pm8001/pm8001_init.c
> +++ b/drivers/scsi/pm8001/pm8001_init.c
> @@ -107,7 +107,7 @@ static struct scsi_host_template pm8001_sht = {
>  #ifdef CONFIG_COMPAT
>         .compat_ioctl           = sas_ioctl,
>  #endif
> -       .shost_attrs            = pm8001_host_attrs,
> +       .shost_groups           = pm8001_host_groups,
>         .track_queue_depth      = 1,
>  };
>
> diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
> index 7e999768bfd2..83eec16d021d 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.h
> +++ b/drivers/scsi/pm8001/pm8001_sas.h
> @@ -733,7 +733,7 @@ ssize_t pm8001_get_gsm_dump(struct device *cdev, u32, char *buf);
>  int pm80xx_fatal_errors(struct pm8001_hba_info *pm8001_ha);
>  void pm8001_free_dev(struct pm8001_device *pm8001_dev);
>  /* ctl shared API */
> -extern struct device_attribute *pm8001_host_attrs[];
> +extern const struct attribute_group *pm8001_host_groups[];
>
>  static inline void
>  pm8001_ccb_task_free_done(struct pm8001_hba_info *pm8001_ha,

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH v3 01/46] scsi: core: Register sysfs attributes earlier
       [not found]   ` <YWQ3mHOZ+881X+j1@t480-pf1aa2c2.linux.ibm.com>
@ 2021-10-11 13:18     ` Benjamin Block
  0 siblings, 0 replies; 57+ messages in thread
From: Benjamin Block @ 2021-10-11 13:18 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K. Petersen, Greg Kroah-Hartman, James E.J. Bottomley,
	Steffen Maier, linux-scsi

On Mon, Oct 11, 2021 at 03:09:44PM +0200, Benjamin Block wrote:
> > diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> > index 86793259e541..05b4d69d53d4 100644
> > --- a/drivers/scsi/scsi_sysfs.c
> > +++ b/drivers/scsi/scsi_sysfs.c
> > @@ -1609,8 +1591,10 @@ static struct device_type scsi_dev_type = {
> >  
> >  void scsi_sysfs_device_initialize(struct scsi_device *sdev)
> >  {
> > +	int i, j = 0;
> >  	unsigned long flags;
> >  	struct Scsi_Host *shost = sdev->host;
> > +	struct scsi_host_template *hostt = shost->hostt;
> >  	struct scsi_target  *starget = sdev->sdev_target;
> >  
> >  	device_initialize(&sdev->sdev_gendev);
> > @@ -1618,6 +1602,23 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev)
> >  	sdev->sdev_gendev.type = &scsi_dev_type;
> >  	dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%llu",
> >  		     sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
> > +	sdev->gendev_attr_groups[j++] = &scsi_sdev_attr_group;
> > +	if (hostt->sdev_attrs) {
> > +		sdev->lld_attr_group = (struct attribute_group){
> > +			.attrs = scsi_convert_dev_attrs(&sdev->sdev_gendev,
> > +							hostt->sdev_attrs)
> 
> Hmm, not sure, can this fail in practice? I mean the allocation in
> `scsi_convert_dev_attrs()`. Maybe we should warn at least once if this
> fails? It might render some userspace applications unusable (even some
> plumbing called with udev and such), with no clear signal from the
> kernel why the attributes are missing.
> 
> Previously we would return an error to the caller in
> `scsi_sysfs_add_sdev()` when some addition failed. But I'm not certain
> whether this new allocation falls under the "too small to fail" rule of
> thumb.

Ah.. nevermind you remove that part again in a later patch. Reading the
series I didn't realize. So probably just ignore the comment.

-- 
Best Regards, Benjamin Block  / Linux on IBM Z Kernel Development / IBM Systems
IBM Deutschland Research & Development GmbH    /    https://www.ibm.com/privacy
Vorsitz. AufsR.: Gregor Pillen         /        Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH v3 06/46] scsi: zfcp: Switch to attribute groups
  2021-10-08 20:23 ` [PATCH v3 06/46] scsi: zfcp: " Bart Van Assche
@ 2021-10-11 13:26   ` Benjamin Block
  2021-10-12 20:39     ` Bart Van Assche
  0 siblings, 1 reply; 57+ messages in thread
From: Benjamin Block @ 2021-10-11 13:26 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, linux-scsi, Steffen Maier, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger

Hey Bart,

just a small nitpick here.

On Fri, Oct 08, 2021 at 01:23:13PM -0700, Bart Van Assche wrote:
> struct device supports attribute groups directly but does not support
> struct device_attribute directly. Hence switch to attribute groups.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/s390/scsi/zfcp_ext.h   |  4 +--
>  drivers/s390/scsi/zfcp_scsi.c  |  4 +--
>  drivers/s390/scsi/zfcp_sysfs.c | 52 +++++++++++++++++++++++-----------
>  3 files changed, 39 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
> index 6bc96d70254d..7b7b567186d6 100644
> --- a/drivers/s390/scsi/zfcp_ext.h
> +++ b/drivers/s390/scsi/zfcp_ext.h
> @@ -184,8 +184,8 @@ extern const struct attribute_group *zfcp_sysfs_adapter_attr_groups[];
>  extern const struct attribute_group *zfcp_unit_attr_groups[];
>  extern const struct attribute_group *zfcp_port_attr_groups[];
>  extern struct mutex zfcp_sysfs_port_units_mutex;
> -extern struct device_attribute *zfcp_sysfs_sdev_attrs[];
> -extern struct device_attribute *zfcp_sysfs_shost_attrs[];
> +extern const struct attribute_group *zfcp_sdev_attr_groups[];
> +extern const struct attribute_group *zfcp_shost_attr_groups[];

I'd prefer it, if you leave the `zfcp_sysfs_` intact; while not
universally used in the whole driver, its a convention we've been trying
to follow regarding the symbols declared by the driver in the recent
time (`zfcp_sysfs.o` is the compilation unit).

-- 
Best Regards, Benjamin Block  / Linux on IBM Z Kernel Development / IBM Systems
IBM Deutschland Research & Development GmbH    /    https://www.ibm.com/privacy
Vorsitz. AufsR.: Gregor Pillen         /        Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH v3 01/46] scsi: core: Register sysfs attributes earlier
  2021-10-08 20:23 ` [PATCH v3 01/46] scsi: core: Register " Bart Van Assche
       [not found]   ` <YWQ3mHOZ+881X+j1@t480-pf1aa2c2.linux.ibm.com>
@ 2021-10-11 13:37   ` Benjamin Block
  1 sibling, 0 replies; 57+ messages in thread
From: Benjamin Block @ 2021-10-11 13:37 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, linux-scsi, Greg Kroah-Hartman,
	James E.J. Bottomley

On Fri, Oct 08, 2021 at 01:23:08PM -0700, Bart Van Assche wrote:
> A quote from Documentation/driver-api/driver-model/device.rst:
> "Word of warning:  While the kernel allows device_create_file() and
> device_remove_file() to be called on a device at any time, userspace has
> strict expectations on when attributes get created.  When a new device is
> registered in the kernel, a uevent is generated to notify userspace (like
> udev) that a new device is available.  If attributes are added after the
> device is registered, then userspace won't get notified and userspace will
> not know about the new attributes."
> 
> Hence register SCSI host sysfs attributes before the SCSI host shost_dev
> uevent is emitted instead of after that event has been emitted.
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/hosts.c       | 23 ++++++++++-
>  drivers/scsi/scsi_priv.h   |  4 +-
>  drivers/scsi/scsi_sysfs.c  | 81 +++++++++++++++++++-------------------
>  include/scsi/scsi_device.h |  7 ++++
>  include/scsi/scsi_host.h   | 12 ++++++
>  5 files changed, 84 insertions(+), 43 deletions(-)
> 

Reviewed-by: Benjamin Block <bblock@linux.ibm.com>

-- 
Best Regards, Benjamin Block  / Linux on IBM Z Kernel Development / IBM Systems
IBM Deutschland Research & Development GmbH    /    https://www.ibm.com/privacy
Vorsitz. AufsR.: Gregor Pillen         /        Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH v3 46/46] scsi: core: Remove two host template members that are no longer used
  2021-10-08 20:23 ` [PATCH v3 46/46] scsi: core: Remove two host template members that are no longer used Bart Van Assche
@ 2021-10-11 13:38   ` Benjamin Block
  0 siblings, 0 replies; 57+ messages in thread
From: Benjamin Block @ 2021-10-11 13:38 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, linux-scsi, Greg Kroah-Hartman,
	James E.J. Bottomley

On Fri, Oct 08, 2021 at 01:23:53PM -0700, Bart Van Assche wrote:
> All SCSI drivers have been converted to use shost_groups and sdev_groups
> instead of shost_attrs or sdev_attrs. Hence remove shost_attrs and
> sdev_attrs.
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/hosts.c       |  9 ---------
>  drivers/scsi/scsi_priv.h   |  2 --
>  drivers/scsi/scsi_sysfs.c  | 28 ----------------------------
>  include/scsi/scsi_device.h |  1 -
>  include/scsi/scsi_host.h   | 11 -----------
>  5 files changed, 51 deletions(-)
> 

Reviewed-by: Benjamin Block <bblock@linux.ibm.com>

-- 
Best Regards, Benjamin Block  / Linux on IBM Z Kernel Development / IBM Systems
IBM Deutschland Research & Development GmbH    /    https://www.ibm.com/privacy
Vorsitz. AufsR.: Gregor Pillen         /        Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: AmtsG Stuttgart, HRB 243294

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH v3 02/46] ata: Switch to attribute groups
  2021-10-08 20:23 ` [PATCH v3 02/46] ata: Switch to attribute groups Bart Van Assche
@ 2021-10-12  0:59   ` Damien Le Moal
  0 siblings, 0 replies; 57+ messages in thread
From: Damien Le Moal @ 2021-10-12  0:59 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen; +Cc: linux-scsi

On 10/9/21 05:23, Bart Van Assche wrote:
> struct device supports attribute groups directly but does not support
> struct device_attribute directly. Hence switch to attribute groups.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

> ---
>  drivers/ata/ahci.h        |  8 +++---
>  drivers/ata/ata_piix.c    |  8 +++---
>  drivers/ata/libahci.c     | 52 ++++++++++++++++++++++++++-------------
>  drivers/ata/libata-sata.c | 19 ++++++++++----
>  drivers/ata/libata-scsi.c | 15 ++++++++---
>  drivers/ata/pata_macio.c  |  2 +-
>  drivers/ata/sata_mv.c     |  2 +-
>  drivers/ata/sata_nv.c     |  4 +--
>  drivers/ata/sata_sil24.c  |  2 +-
>  include/linux/libata.h    |  8 +++---
>  10 files changed, 79 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
> index 2e89499bd9c3..eeac5482f1d1 100644
> --- a/drivers/ata/ahci.h
> +++ b/drivers/ata/ahci.h
> @@ -376,8 +376,8 @@ struct ahci_host_priv {
>  
>  extern int ahci_ignore_sss;
>  
> -extern struct device_attribute *ahci_shost_attrs[];
> -extern struct device_attribute *ahci_sdev_attrs[];
> +extern const struct attribute_group *ahci_shost_groups[];
> +extern const struct attribute_group *ahci_sdev_groups[];
>  
>  /*
>   * This must be instantiated by the edge drivers.  Read the comments
> @@ -388,8 +388,8 @@ extern struct device_attribute *ahci_sdev_attrs[];
>  	.can_queue		= AHCI_MAX_CMDS,			\
>  	.sg_tablesize		= AHCI_MAX_SG,				\
>  	.dma_boundary		= AHCI_DMA_BOUNDARY,			\
> -	.shost_attrs		= ahci_shost_attrs,			\
> -	.sdev_attrs		= ahci_sdev_attrs,			\
> +	.shost_groups		= ahci_shost_groups,			\
> +	.sdev_groups		= ahci_sdev_groups,			\
>  	.change_queue_depth     = ata_scsi_change_queue_depth,		\
>  	.tag_alloc_policy       = BLK_TAG_ALLOC_RR,             	\
>  	.slave_configure        = ata_scsi_slave_config
> diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
> index 3ca7720e7d8f..0b2fcf0d1d6c 100644
> --- a/drivers/ata/ata_piix.c
> +++ b/drivers/ata/ata_piix.c
> @@ -1085,14 +1085,16 @@ static struct ata_port_operations ich_pata_ops = {
>  	.set_dmamode		= ich_set_dmamode,
>  };
>  
> -static struct device_attribute *piix_sidpr_shost_attrs[] = {
> -	&dev_attr_link_power_management_policy,
> +static struct attribute *piix_sidpr_shost_attrs[] = {
> +	&dev_attr_link_power_management_policy.attr,
>  	NULL
>  };
>  
> +ATTRIBUTE_GROUPS(piix_sidpr_shost);
> +
>  static struct scsi_host_template piix_sidpr_sht = {
>  	ATA_BMDMA_SHT(DRV_NAME),
> -	.shost_attrs		= piix_sidpr_shost_attrs,
> +	.shost_groups		= piix_sidpr_shost_groups,
>  };
>  
>  static struct ata_port_operations piix_sidpr_sata_ops = {
> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> index 5b3fa2cbe722..28430c093a7f 100644
> --- a/drivers/ata/libahci.c
> +++ b/drivers/ata/libahci.c
> @@ -108,28 +108,46 @@ static DEVICE_ATTR(em_buffer, S_IWUSR | S_IRUGO,
>  		   ahci_read_em_buffer, ahci_store_em_buffer);
>  static DEVICE_ATTR(em_message_supported, S_IRUGO, ahci_show_em_supported, NULL);
>  
> -struct device_attribute *ahci_shost_attrs[] = {
> -	&dev_attr_link_power_management_policy,
> -	&dev_attr_em_message_type,
> -	&dev_attr_em_message,
> -	&dev_attr_ahci_host_caps,
> -	&dev_attr_ahci_host_cap2,
> -	&dev_attr_ahci_host_version,
> -	&dev_attr_ahci_port_cmd,
> -	&dev_attr_em_buffer,
> -	&dev_attr_em_message_supported,
> +static struct attribute *ahci_shost_attrs[] = {
> +	&dev_attr_link_power_management_policy.attr,
> +	&dev_attr_em_message_type.attr,
> +	&dev_attr_em_message.attr,
> +	&dev_attr_ahci_host_caps.attr,
> +	&dev_attr_ahci_host_cap2.attr,
> +	&dev_attr_ahci_host_version.attr,
> +	&dev_attr_ahci_port_cmd.attr,
> +	&dev_attr_em_buffer.attr,
> +	&dev_attr_em_message_supported.attr,
>  	NULL
>  };
> -EXPORT_SYMBOL_GPL(ahci_shost_attrs);
>  
> -struct device_attribute *ahci_sdev_attrs[] = {
> -	&dev_attr_sw_activity,
> -	&dev_attr_unload_heads,
> -	&dev_attr_ncq_prio_supported,
> -	&dev_attr_ncq_prio_enable,
> +static const struct attribute_group ahci_shost_attr_group = {
> +	.attrs = ahci_shost_attrs
> +};
> +
> +const struct attribute_group *ahci_shost_groups[] = {
> +	&ahci_shost_attr_group,
> +	NULL
> +};
> +EXPORT_SYMBOL_GPL(ahci_shost_groups);
> +
> +struct attribute *ahci_sdev_attrs[] = {
> +	&dev_attr_sw_activity.attr,
> +	&dev_attr_unload_heads.attr,
> +	&dev_attr_ncq_prio_supported.attr,
> +	&dev_attr_ncq_prio_enable.attr,
> +	NULL
> +};
> +
> +static const struct attribute_group ahci_sdev_attr_group = {
> +	.attrs = ahci_sdev_attrs
> +};
> +
> +const struct attribute_group *ahci_sdev_groups[] = {
> +	&ahci_sdev_attr_group,
>  	NULL
>  };
> -EXPORT_SYMBOL_GPL(ahci_sdev_attrs);
> +EXPORT_SYMBOL_GPL(ahci_sdev_groups);
>  
>  struct ata_port_operations ahci_ops = {
>  	.inherits		= &sata_pmp_port_ops,
> diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
> index 8f3ff830ab0c..79e0f86aa3ae 100644
> --- a/drivers/ata/libata-sata.c
> +++ b/drivers/ata/libata-sata.c
> @@ -922,13 +922,22 @@ DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
>  	    ata_ncq_prio_enable_show, ata_ncq_prio_enable_store);
>  EXPORT_SYMBOL_GPL(dev_attr_ncq_prio_enable);
>  
> -struct device_attribute *ata_ncq_sdev_attrs[] = {
> -	&dev_attr_unload_heads,
> -	&dev_attr_ncq_prio_enable,
> -	&dev_attr_ncq_prio_supported,
> +struct attribute *ata_ncq_sdev_attrs[] = {
> +	&dev_attr_unload_heads.attr,
> +	&dev_attr_ncq_prio_enable.attr,
> +	&dev_attr_ncq_prio_supported.attr,
>  	NULL
>  };
> -EXPORT_SYMBOL_GPL(ata_ncq_sdev_attrs);
> +
> +static const struct attribute_group ata_ncq_sdev_attr_group = {
> +	.attrs = ata_ncq_sdev_attrs
> +};
> +
> +const struct attribute_group *ata_ncq_sdev_groups[] = {
> +	&ata_ncq_sdev_attr_group,
> +	NULL
> +};
> +EXPORT_SYMBOL_GPL(ata_ncq_sdev_groups);
>  
>  static ssize_t
>  ata_scsi_em_message_store(struct device *dev, struct device_attribute *attr,
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 1fb4611f7eeb..75c54b2761bf 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -234,11 +234,20 @@ static void ata_scsi_set_invalid_parameter(struct ata_device *dev,
>  				     field, 0xff, 0);
>  }
>  
> -struct device_attribute *ata_common_sdev_attrs[] = {
> -	&dev_attr_unload_heads,
> +static struct attribute *ata_common_sdev_attrs[] = {
> +	&dev_attr_unload_heads.attr,
>  	NULL
>  };
> -EXPORT_SYMBOL_GPL(ata_common_sdev_attrs);
> +
> +static const struct attribute_group ata_common_sdev_attr_group = {
> +	.attrs = ata_common_sdev_attrs
> +};
> +
> +const struct attribute_group *ata_common_sdev_groups[] = {
> +	&ata_common_sdev_attr_group,
> +	NULL
> +};
> +EXPORT_SYMBOL_GPL(ata_common_sdev_groups);
>  
>  /**
>   *	ata_std_bios_param - generic bios head/sector/cylinder calculator used by sd.
> diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c
> index be0ca8d5b345..16e8aa184a75 100644
> --- a/drivers/ata/pata_macio.c
> +++ b/drivers/ata/pata_macio.c
> @@ -923,7 +923,7 @@ static struct scsi_host_template pata_macio_sht = {
>  	 */
>  	.max_segment_size	= MAX_DBDMA_SEG,
>  	.slave_configure	= pata_macio_slave_config,
> -	.sdev_attrs		= ata_common_sdev_attrs,
> +	.sdev_groups		= ata_common_sdev_groups,
>  	.can_queue		= ATA_DEF_QUEUE,
>  	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,
>  };
> diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
> index 9d86203e1e7a..24130e551b26 100644
> --- a/drivers/ata/sata_mv.c
> +++ b/drivers/ata/sata_mv.c
> @@ -670,7 +670,7 @@ static struct scsi_host_template mv6_sht = {
>  	.can_queue		= MV_MAX_Q_DEPTH - 1,
>  	.sg_tablesize		= MV_MAX_SG_CT / 2,
>  	.dma_boundary		= MV_DMA_BOUNDARY,
> -	.sdev_attrs             = ata_ncq_sdev_attrs,
> +	.sdev_groups		= ata_ncq_sdev_groups,
>  	.change_queue_depth	= ata_scsi_change_queue_depth,
>  	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,
>  	.slave_configure	= ata_scsi_slave_config
> diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
> index c385d18ce87b..16272c111208 100644
> --- a/drivers/ata/sata_nv.c
> +++ b/drivers/ata/sata_nv.c
> @@ -380,7 +380,7 @@ static struct scsi_host_template nv_adma_sht = {
>  	.sg_tablesize		= NV_ADMA_SGTBL_TOTAL_LEN,
>  	.dma_boundary		= NV_ADMA_DMA_BOUNDARY,
>  	.slave_configure	= nv_adma_slave_config,
> -	.sdev_attrs             = ata_ncq_sdev_attrs,
> +	.sdev_groups		= ata_ncq_sdev_groups,
>  	.change_queue_depth     = ata_scsi_change_queue_depth,
>  	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,
>  };
> @@ -391,7 +391,7 @@ static struct scsi_host_template nv_swncq_sht = {
>  	.sg_tablesize		= LIBATA_MAX_PRD,
>  	.dma_boundary		= ATA_DMA_BOUNDARY,
>  	.slave_configure	= nv_swncq_slave_config,
> -	.sdev_attrs             = ata_ncq_sdev_attrs,
> +	.sdev_groups		= ata_ncq_sdev_groups,
>  	.change_queue_depth     = ata_scsi_change_queue_depth,
>  	.tag_alloc_policy	= BLK_TAG_ALLOC_RR,
>  };
> diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
> index 06a1e27c4f84..f99ec6f7d7c0 100644
> --- a/drivers/ata/sata_sil24.c
> +++ b/drivers/ata/sata_sil24.c
> @@ -379,7 +379,7 @@ static struct scsi_host_template sil24_sht = {
>  	.sg_tablesize		= SIL24_MAX_SGE,
>  	.dma_boundary		= ATA_DMA_BOUNDARY,
>  	.tag_alloc_policy	= BLK_TAG_ALLOC_FIFO,
> -	.sdev_attrs		= ata_ncq_sdev_attrs,
> +	.sdev_groups		= ata_ncq_sdev_groups,
>  	.change_queue_depth	= ata_scsi_change_queue_depth,
>  	.slave_configure	= ata_scsi_slave_config
>  };
> diff --git a/include/linux/libata.h b/include/linux/libata.h
> index c0c64f03e107..bd1b782d1bbf 100644
> --- a/include/linux/libata.h
> +++ b/include/linux/libata.h
> @@ -1388,7 +1388,7 @@ 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 const struct attribute_group *ata_common_sdev_groups[];
>  
>  /*
>   * All sht initializers (BASE, PIO, BMDMA, NCQ) must be instantiated
> @@ -1418,14 +1418,14 @@ extern struct device_attribute *ata_common_sdev_attrs[];
>  
>  #define ATA_BASE_SHT(drv_name)					\
>  	ATA_SUBBASE_SHT(drv_name),				\
> -	.sdev_attrs		= ata_common_sdev_attrs
> +	.sdev_groups		= ata_common_sdev_groups
>  
>  #ifdef CONFIG_SATA_HOST
> -extern struct device_attribute *ata_ncq_sdev_attrs[];
> +extern const struct attribute_group *ata_ncq_sdev_groups[];
>  
>  #define ATA_NCQ_SHT(drv_name)					\
>  	ATA_SUBBASE_SHT(drv_name),				\
> -	.sdev_attrs		= ata_ncq_sdev_attrs,		\
> +	.sdev_groups		= ata_ncq_sdev_groups,		\
>  	.change_queue_depth	= ata_scsi_change_queue_depth
>  #endif
>  
> 


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 57+ messages in thread

* Re: [PATCH v3 06/46] scsi: zfcp: Switch to attribute groups
  2021-10-11 13:26   ` Benjamin Block
@ 2021-10-12 20:39     ` Bart Van Assche
  0 siblings, 0 replies; 57+ messages in thread
From: Bart Van Assche @ 2021-10-12 20:39 UTC (permalink / raw)
  To: Benjamin Block
  Cc: Martin K . Petersen, linux-scsi, Steffen Maier, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger

On 10/11/21 6:26 AM, Benjamin Block wrote:
> On Fri, Oct 08, 2021 at 01:23:13PM -0700, Bart Van Assche wrote:
>> -extern struct device_attribute *zfcp_sysfs_sdev_attrs[];
>> -extern struct device_attribute *zfcp_sysfs_shost_attrs[];
>> +extern const struct attribute_group *zfcp_sdev_attr_groups[];
>> +extern const struct attribute_group *zfcp_shost_attr_groups[];
> 
> I'd prefer it, if you leave the `zfcp_sysfs_` intact; while not
> universally used in the whole driver, its a convention we've been trying
> to follow regarding the symbols declared by the driver in the recent
> time (`zfcp_sysfs.o` is the compilation unit).

Hi Benjamin,

I will restore these prefixes and post a fourth version of this patch 
series.

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 57+ messages in thread

end of thread, other threads:[~2021-10-12 20:39 UTC | newest]

Thread overview: 57+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08 20:23 [PATCH v3 00/46] Register SCSI sysfs attributes earlier Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 01/46] scsi: core: Register " Bart Van Assche
     [not found]   ` <YWQ3mHOZ+881X+j1@t480-pf1aa2c2.linux.ibm.com>
2021-10-11 13:18     ` Benjamin Block
2021-10-11 13:37   ` Benjamin Block
2021-10-08 20:23 ` [PATCH v3 02/46] ata: Switch to attribute groups Bart Van Assche
2021-10-12  0:59   ` Damien Le Moal
2021-10-08 20:23 ` [PATCH v3 03/46] firewire: sbp2: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 04/46] RDMA/srp: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 05/46] scsi: message: fusion: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 06/46] scsi: zfcp: " Bart Van Assche
2021-10-11 13:26   ` Benjamin Block
2021-10-12 20:39     ` Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 07/46] scsi: 3w-9xxx: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 08/46] scsi: 3w-sas: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 09/46] scsi: 3w-xxxx: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 10/46] scsi: 53c700: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 11/46] scsi: aacraid: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 12/46] scsi: arcmsr: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 13/46] scsi: be2iscsi: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 14/46] scsi: bfa: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 15/46] scsi: bnx2fc: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 16/46] scsi: bnx2i: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 17/46] scsi: csiostor: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 18/46] scsi: cxlflash: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 19/46] scsi: fnic: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 20/46] scsi: hisi_sas: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 21/46] scsi: hpsa: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 22/46] scsi: hptiop: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 23/46] scsi: ibmvscsi: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 24/46] scsi: ibmvfc: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 25/46] scsi: ipr: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 26/46] scsi: isci: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 27/46] scsi: lpfc: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 28/46] scsi: megaraid: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 29/46] scsi: mpt3sas: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 30/46] scsi: mvsas: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 31/46] scsi: myrb: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 32/46] scsi: myrs: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 33/46] scsi: ncr53c8xx: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 34/46] scsi: sym53c500_cs: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 35/46] scsi: pm8001: " Bart Van Assche
2021-10-11  4:54   ` Jinpu Wang
2021-10-08 20:23 ` [PATCH v3 36/46] scsi: pmcraid: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 37/46] scsi: qedf: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 38/46] scsi: qedi: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 39/46] scsi: qla2xxx: Remove a declaration Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 40/46] scsi: qla2xxx: Switch to attribute groups Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 41/46] scsi: qla4xxx: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 42/46] scsi: smartpqi: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 43/46] scsi: snic: " Bart Van Assche
2021-10-08 20:23 ` [PATCH v3 44/46] scsi: unisys: Remove the shost_attrs member Bart Van Assche
2021-10-09  2:11   ` Kershner, David A
2021-10-09  5:55   ` Greg Kroah-Hartman
2021-10-08 20:23 ` [PATCH v3 45/46] scsi: usb: Switch to attribute groups Bart Van Assche
2021-10-09  5:55   ` Greg Kroah-Hartman
2021-10-08 20:23 ` [PATCH v3 46/46] scsi: core: Remove two host template members that are no longer used Bart Van Assche
2021-10-11 13:38   ` Benjamin Block

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.