diff mbox

scsi-sysfs: correct errno for host_reset

Message ID 20170810175212.GA19528@localhost.didichuxing.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

weiping zhang Aug. 10, 2017, 5:52 p.m. UTC
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.

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
 drivers/scsi/scsi_sysfs.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

weiping zhang Aug. 14, 2017, 12:30 p.m. UTC | #1
On Fri, Aug 11, 2017 at 01:52:17AM +0800, weiping zhang wrote:
> 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.
> 
> Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
> ---
>  drivers/scsi/scsi_sysfs.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index dff8faf..3e664f4 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -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
Martin K. Petersen Aug. 17, 2017, 1:11 a.m. UTC | #2
weiping,

> 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.

Applied to 4.14/scsi-queue. Thank you!
diff mbox

Patch

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index dff8faf..3e664f4 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -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)