Blob Blame History Raw
From: weiping zhang <zhangweiping@didichuxing.com>
Date: Fri, 11 Aug 2017 01:52:17 +0800
Subject: [PATCH] scsi: scsi-sysfs: Adjust error returned for adapter reset
 request
References: bsc#1061782
Git-commit: 92227b8d3d7fd0c9a5b78c3967a756e83a43b36d
Patch-Mainline: v4.14-rc1

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>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 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 d6984df..41891db 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -303,6 +303,8 @@ static int check_reset_type(const char *str)
 
 	if (sht->host_reset)
 		ret = sht->host_reset(shost, type);
+	else
+		ret = -EOPNOTSUPP;
 
 exit_store_host_reset:
 	if (ret == 0)
-- 
1.8.5.6