Re: [PATCH v2] scsi: core: Fix early registration of sysfs attributes for scsi_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/25/21 2:23 AM, Julian Wiedmann wrote:
On 25.10.21 00:16, Steffen Maier wrote:
  void scsi_sysfs_device_initialize(struct scsi_device *sdev)
  {
-	int i, j = 0;
+	int i = 0;
  	unsigned long flags;
  	struct Scsi_Host *shost = sdev->host;
  	struct scsi_host_template *hostt = shost->hostt;
@@ -1583,15 +1583,15 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev)
  	scsi_enable_async_suspend(&sdev->sdev_gendev);
  	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;
+	sdev->sdev_gendev.groups = sdev->gendev_attr_groups;
  	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];
+			     i < ARRAY_SIZE(sdev->gendev_attr_groups);
+		     i++) {
+			sdev->gendev_attr_groups[i] = hostt->sdev_groups[i];
  		}
  	}
-	WARN_ON_ONCE(j >= ARRAY_SIZE(sdev->gendev_attr_groups));
+	WARN_ON_ONCE(i >= ARRAY_SIZE(sdev->gendev_attr_groups));

Can't we simply assign the hostt->sdev_groups now, without the additional
indirection?

sdev->sdev_gendev.groups = hostt->sdev_groups;

Hi Steffen,

Please let me know if you wouldn't have the time to integrate the approach mentioned above in a new version of your patch.

Thanks,

Bart.



[Index of Archives]     [Linux Kernel]     [Linux USB Development]     [Yosemite News]     [Linux SCSI]

  Powered by Linux