From patchwork Tue Mar 28 14:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 668066 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 998C3C76196 for ; Tue, 28 Mar 2023 14:35:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233128AbjC1Of1 (ORCPT ); Tue, 28 Mar 2023 10:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232278AbjC1OfV (ORCPT ); Tue, 28 Mar 2023 10:35:21 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B57E6CC0D; Tue, 28 Mar 2023 07:35:13 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PmBzd13tZz4f3rNB; Tue, 28 Mar 2023 22:35:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDn4R8X+yJkk4bgFg--.7384S5; Tue, 28 Mar 2023 22:35:10 +0800 (CST) From: Ye Bin To: jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ye Bin Subject: [PATCH v2 1/3] scsi: forbid to set scsi host state by sysfs Date: Tue, 28 Mar 2023 22:34:40 +0800 Message-Id: <20230328143442.2684167-2-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230328143442.2684167-1-yebin@huaweicloud.com> References: <20230328143442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iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxUOWlkDUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Ye Bin Actually, set scsi host state by sysfs may lead to functional issues. So forbid to set scsi host state. Signed-off-by: Ye Bin --- 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)