[PATCH v2 1/3] scsi: forbid to set scsi host state by sysfs

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

 



From: Ye Bin <yebin10@xxxxxxxxxx>

Actually, set scsi host state by sysfs may lead to functional issues.
So forbid to set scsi host state.

Signed-off-by: Ye Bin <yebin10@xxxxxxxxxx>
---
 drivers/scsi/scsi_sysfs.c | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index ee28f73af4d4..903aa9de46e5 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -195,30 +195,6 @@ store_scan(struct device *dev, struct device_attribute *attr,
 };
 static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan);
 
-static ssize_t
-store_shost_state(struct device *dev, struct device_attribute *attr,
-		  const char *buf, size_t count)
-{
-	int i;
-	struct Scsi_Host *shost = class_to_shost(dev);
-	enum scsi_host_state state = 0;
-
-	for (i = 0; i < ARRAY_SIZE(shost_states); i++) {
-		const int len = strlen(shost_states[i].name);
-		if (strncmp(shost_states[i].name, buf, len) == 0 &&
-		   buf[len] == '\n') {
-			state = shost_states[i].value;
-			break;
-		}
-	}
-	if (!state)
-		return -EINVAL;
-
-	if (scsi_host_set_state(shost, state))
-		return -EINVAL;
-	return count;
-}
-
 static ssize_t
 show_shost_state(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -233,7 +209,7 @@ show_shost_state(struct device *dev, struct device_attribute *attr, char *buf)
 
 /* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */
 static struct device_attribute dev_attr_hstate =
-	__ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state);
+	__ATTR(state, S_IRUGO, show_shost_state, NULL);
 
 static ssize_t
 show_shost_mode(unsigned int mode, char *buf)
-- 
2.31.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux