From 92c4b58b15c56298b1b225c1d2e533165b3e32af Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 12 Oct 2021 16:35:13 -0700 Subject: scsi: core: Register sysfs attributes earlier 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. Link: https://lore.kernel.org/r/20211012233558.4066756-2-bvanassche@acm.org Cc: Greg Kroah-Hartman Reviewed-by: Benjamin Block Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- include/scsi/scsi_host.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/scsi/scsi_host.h') diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 3bb46b188e1c..bc2fcb72ff59 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 -- cgit v1.2.3