scsi: scsi-sysfs: Adjust error returned for adapter reset request
authorweiping zhang <zhangweiping@didichuxing.com>
Thu, 10 Aug 2017 17:52:17 +0000 (01:52 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 25 Aug 2017 02:29:06 +0000 (22:29 -0400)
If scsi_host_template->host_reset is NULL and the user requests an
adapter reset through

echo adapter > /sys/class/scsi_host/hostx/host_reset

-EINVAL will be returned even though the "adapter" argument is perfectly
valid.

Change this so that we only return -EINVAL if the provided string is
invalid.  If the host does not implement a ->host_reset function we'll
return -EOPNOTSUPP.

[mkp: tweaked patch description]

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_sysfs.c

index d6984df..41891db 100644 (file)
@@ -303,6 +303,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)