Skip to contentSkip to conversation

scsi-sysfs: correct errno for host_reset

PATCH Applied weiping zhang 2 participants 3 messages Aug 10, 2017 – Aug 17, 2017 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi-sysfs: correct errno for host_reset

if scsi_host_template->host_reset is NULL, when user
"echo adapter > /sys/class/scsi_host/hostx/host_reset",
-EINVAL will return even string compare successfully. It make user confuse.

change to:
-EINVAL if string not match "adapter" / "firmware";
-EOPNOTSUPP if string match but not implement ->host_reset.

---
 drivers/scsi/scsi_sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/scsi_sysfs.c +2 -0
index dff8faf..3e664f4 100644
@@ -272,6 +272,8 @@ store_host_reset(struct device *dev, struct device_attribute *attr,
 
 	if (sht->host_reset)
 		ret = sht->host_reset(shost, type);
+	else
+		ret = -EOPNOTSUPP;
 
 exit_store_host_reset:
 	if (ret == 0)
Signature · 1 line
2.9.4
#1 lore raw
Quoted 19 lines · weiping zhang

if scsi_host_template->host_reset is NULL, when user
"echo adapter > /sys/class/scsi_host/hostx/host_reset",
-EINVAL will return even string compare successfully. It make user confuse.

change to:

(quoted diff) +0 -2
-EINVAL		if string not match "adapter" / "firmware";
-EOPNOTSUPP	if string match but not implement ->host_reset.
---
 drivers/scsi/scsi_sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/scsi_sysfs.c +0 -0
index dff8faf..3e664f4 100644

drivers/scsi/scsi_sysfs.c store_host_reset(struct device *dev, struct device_attribute *attr, · line 279

Quoted 8 lines
drivers/scsi/scsi_sysfs.c +2 -0
@@ -272,6 +272,8 @@ store_host_reset(struct device *dev, struct device_attribute *attr,
 
 	if (sht->host_reset)
 		ret = sht->host_reset(shost, type);
+	else
+		ret = -EOPNOTSUPP;
 
 exit_store_host_reset:
 	if (ret == 0)

Hi Martin,

Could you please take a look at this patch at your convinience.

thanks

#2 lore raw
In reply to weiping zhang

weiping,

Review

Quoted 7 lines

if scsi_host_template->host_reset is NULL, when user "echo adapter > /sys/class/scsi_host/hostx/host_reset", -EINVAL will return even string compare successfully. It make user confuse.

change to:

(quoted diff) +0 -2
-EINVAL		if string not match "adapter" / "firmware";
-EOPNOTSUPP	if string match but not implement ->host_reset.

Applied to 4.14/scsi-queue. Thank you!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering