From patchwork Tue Jan 16 04:51:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520449 Received: from esa10.hc1455-7.c3s2.iphmx.com (esa10.hc1455-7.c3s2.iphmx.com [139.138.36.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4417125AF; Tue, 16 Jan 2024 04:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="133883812" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="133883812" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa10.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:21 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 857C9D6187; Tue, 16 Jan 2024 13:52:18 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id B8082C5CCD; Tue, 16 Jan 2024 13:52:17 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 5A693200A56C5; Tue, 16 Jan 2024 13:52:17 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id D7F801A015F; Tue, 16 Jan 2024 12:52:16 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org Subject: [PATCH 12/42] drivers/message/fusion: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:21 +0800 Message-Id: <20240116045151.3940401-10-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--13.896000-10.000000 X-TMASE-MatchedRID: st9CF01730Y4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPk0No1mkr2A1hM0AWQBBcXdpRSkbxKeJc4rMZ+BqQt2NrBOVz0Jwcxl6vCrG0TnfVUg9x e4gtUJtptIv0A3hSOW84WYLmQfXYmpoPHQXywp1eXd9LOVu4KPfCrUlDnEXiSuzdiHYg4JjP+tn MvnQl+U2tLgqAV+5PDAPNERLsv2l+XBXaJoB9JZxRFJJyf5BJe3QfwsVk0UbtuRXh7bFKB7tjlq sM06ZRaAhkNqYwTSAYqd+5N1jjBA8gQRSDx83t5xYVzI3UCCaY= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/message/fusion/mptscsih.c:3100:8-16: WARNING: please use sysfs_emit > ./drivers/message/fusion/mptscsih.c:3116:8-16: WARNING: please use sysfs_emit > ./drivers/message/fusion/mptscsih.c:3132:8-16: WARNING: please use sysfs_emit > ./drivers/message/fusion/mptscsih.c:3145:8-16: WARNING: please use sysfs_emit > ./drivers/message/fusion/mptscsih.c:3159:8-16: WARNING: please use sysfs_emit > ./drivers/message/fusion/mptscsih.c:3173:8-16: WARNING: please use sysfs_emit > ./drivers/message/fusion/mptscsih.c:3186:8-16: WARNING: please use sysfs_emit > ./drivers/message/fusion/mptscsih.c:3198:8-16: WARNING: please use sysfs_emit > ./drivers/message/fusion/mptscsih.c:3211:8-16: WARNING: please use sysfs_emit > ./drivers/message/fusion/mptscsih.c:3224:8-16: WARNING: please use sysfs_emit > ./drivers/message/fusion/mptscsih.c:3237:8-16: WARNING: please use sysfs_emit > ./drivers/message/fusion/mptscsih.c:3250:8-16: WARNING: please use sysfs_emit No functional change intended CC: Sathya Prakash CC: Sreekanth Reddy CC: Suganath Prabu Subramani CC: MPT-FusionLinux.pdl@broadcom.com CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/message/fusion/mptscsih.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 9080a73b4ea6..24063b201699 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -3097,7 +3097,7 @@ mptscsih_version_fw_show(struct device *dev, struct device_attribute *attr, MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n", + return sysfs_emit(buf, "%02d.%02d.%02d.%02d\n", (ioc->facts.FWVersion.Word & 0xFF000000) >> 24, (ioc->facts.FWVersion.Word & 0x00FF0000) >> 16, (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8, @@ -3113,7 +3113,7 @@ mptscsih_version_bios_show(struct device *dev, struct device_attribute *attr, MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n", + return sysfs_emit(buf, "%02x.%02x.%02x.%02x\n", (ioc->biosVersion & 0xFF000000) >> 24, (ioc->biosVersion & 0x00FF0000) >> 16, (ioc->biosVersion & 0x0000FF00) >> 8, @@ -3129,7 +3129,7 @@ mptscsih_version_mpi_show(struct device *dev, struct device_attribute *attr, MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion); + return sysfs_emit(buf, "%03x\n", ioc->facts.MsgVersion); } static DEVICE_ATTR(version_mpi, S_IRUGO, mptscsih_version_mpi_show, NULL); @@ -3142,7 +3142,7 @@ char *buf) MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name); + return sysfs_emit(buf, "%s\n", ioc->prod_name); } static DEVICE_ATTR(version_product, S_IRUGO, mptscsih_version_product_show, NULL); @@ -3156,8 +3156,7 @@ mptscsih_version_nvdata_persistent_show(struct device *dev, MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%02xh\n", - ioc->nvdata_version_persistent); + return sysfs_emit(buf, "%02xh\n", ioc->nvdata_version_persistent); } static DEVICE_ATTR(version_nvdata_persistent, S_IRUGO, mptscsih_version_nvdata_persistent_show, NULL); @@ -3170,7 +3169,7 @@ mptscsih_version_nvdata_default_show(struct device *dev, MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default); + return sysfs_emit(buf, "%02xh\n",ioc->nvdata_version_default); } static DEVICE_ATTR(version_nvdata_default, S_IRUGO, mptscsih_version_nvdata_default_show, NULL); @@ -3183,7 +3182,7 @@ mptscsih_board_name_show(struct device *dev, struct device_attribute *attr, MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name); + return sysfs_emit(buf, "%s\n", ioc->board_name); } static DEVICE_ATTR(board_name, S_IRUGO, mptscsih_board_name_show, NULL); @@ -3195,7 +3194,7 @@ mptscsih_board_assembly_show(struct device *dev, MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly); + return sysfs_emit(buf, "%s\n", ioc->board_assembly); } static DEVICE_ATTR(board_assembly, S_IRUGO, mptscsih_board_assembly_show, NULL); @@ -3208,7 +3207,7 @@ mptscsih_board_tracer_show(struct device *dev, struct device_attribute *attr, MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer); + return sysfs_emit(buf, "%s\n", ioc->board_tracer); } static DEVICE_ATTR(board_tracer, S_IRUGO, mptscsih_board_tracer_show, NULL); @@ -3221,7 +3220,7 @@ mptscsih_io_delay_show(struct device *dev, struct device_attribute *attr, MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay); + return sysfs_emit(buf, "%02d\n", ioc->io_missing_delay); } static DEVICE_ATTR(io_delay, S_IRUGO, mptscsih_io_delay_show, NULL); @@ -3234,7 +3233,7 @@ mptscsih_device_delay_show(struct device *dev, struct device_attribute *attr, MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay); + return sysfs_emit(buf, "%02d\n", ioc->device_missing_delay); } static DEVICE_ATTR(device_delay, S_IRUGO, mptscsih_device_delay_show, NULL); @@ -3247,7 +3246,7 @@ mptscsih_debug_level_show(struct device *dev, struct device_attribute *attr, MPT_SCSI_HOST *hd = shost_priv(host); MPT_ADAPTER *ioc = hd->ioc; - return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level); + return sysfs_emit(buf, "%08xh\n", ioc->debug_level); } static ssize_t mptscsih_debug_level_store(struct device *dev, struct device_attribute *attr, From patchwork Tue Jan 16 04:51:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520426 Received: from esa1.hc1455-7.c3s2.iphmx.com (esa1.hc1455-7.c3s2.iphmx.com [207.54.90.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 698A711185; Tue, 16 Jan 2024 04:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="146090994" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="146090994" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa1.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:22 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 02402D7AE4; Tue, 16 Jan 2024 13:52:20 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id ECDD3C1D78; Tue, 16 Jan 2024 13:52:18 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 8FD5C6B4C7; Tue, 16 Jan 2024 13:52:18 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 1CBC11A015F; Tue, 16 Jan 2024 12:52:18 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 16/42] drivers/scsi/53c700: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:25 +0800 Message-Id: <20240116045151.3940401-14-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.005 X-TMASE-Result: 10--8.081000-10.000000 X-TMASE-MatchedRID: CncXHiplHCc4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4dL4Vi2vvkbTrMZ+BqQt2NrBOVz0Jwcxl6vCrG0TnfVUg9x e4gtUJtpqw4mhfH/Cj3QJpsmqtg2cHxPMjOKY7A/+HHE8LDNSg8RB0bsfrpPIfiAqrjYtFiQaiK q3Gb1595xakd0mtD8VYl3SnqFqQXdCWGMoSnhDBX7cGd19dSFd X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/53c700.c:2074:8-16: WARNING: please use sysfs_emit No functional change intended CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/53c700.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 857be0f3ae5b..85439e976143 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -2071,7 +2071,7 @@ NCR_700_show_active_tags(struct device *dev, struct device_attribute *attr, char { struct scsi_device *SDp = to_scsi_device(dev); - return snprintf(buf, 20, "%d\n", NCR_700_get_depth(SDp)); + return sysfs_emit(buf, "%d\n", NCR_700_get_depth(SDp)); } static struct device_attribute NCR_700_active_tags_attr = { From patchwork Tue Jan 16 04:51:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520435 Received: from esa12.hc1455-7.c3s2.iphmx.com (esa12.hc1455-7.c3s2.iphmx.com [139.138.37.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F30D1B807; Tue, 16 Jan 2024 04:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="125556478" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="125556478" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa12.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:22 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 1C695D9D92; Tue, 16 Jan 2024 13:52:20 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 4E772D8AD7; Tue, 16 Jan 2024 13:52:19 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id E598C6B4C6; Tue, 16 Jan 2024 13:52:18 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 701651A0160; Tue, 16 Jan 2024 12:52:18 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Adaptec OEM Raid Solutions , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 17/42] drivers/scsi/aacraid: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:26 +0800 Message-Id: <20240116045151.3940401-15-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.005 X-TMASE-Result: 10--16.275400-10.000000 X-TMASE-MatchedRID: ebEStOsB1eE4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4beNXXhVTPU8LdBFrfY9r2n0swHSFcVJ6MC5DTEMxpeQfiq 1gj2xET8qqtDuUtwyfKD8el0BdzuozYigC8AbwLLfSQNpZkETVAv/9UzFeXIT/GDEtaauvzvT6Z /7gOjQOMgfSosmpqsABlShLAm3Hw5ccQ8eam5EfRRFJJyf5BJeov6oNokdHvT6C0ePs7A07QKmA RN5PTKc X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/aacraid/linit.c:1299:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/aacraid/linit.c:1325:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/aacraid/linit.c:1332:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/aacraid/linit.c:561:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/aacraid/linit.c:588:8-16: WARNING: please use sysfs_emit No functional change intended CC: Adaptec OEM Raid Solutions CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/aacraid/linit.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 68f4dbcfff49..f534f5d985f1 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c @@ -558,11 +558,10 @@ static ssize_t aac_show_raid_level(struct device *dev, struct device_attribute * struct scsi_device *sdev = to_scsi_device(dev); struct aac_dev *aac = (struct aac_dev *)(sdev->host->hostdata); if (sdev_channel(sdev) != CONTAINER_CHANNEL) - return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach - ? "Hidden\n" : + return sysfs_emit(buf, sdev->no_uld_attacha ? "Hidden\n" : ((aac->jbod && (sdev->type == TYPE_DISK)) ? "JBOD\n" : "")); - return snprintf(buf, PAGE_SIZE, "%s\n", - get_container_type(aac->fsa_dev[sdev_id(sdev)].type)); + return sysfs_emit(buf, "%s\n", + get_container_type(aac->fsa_dev[sdev_id(sdev)].type)); } static struct device_attribute aac_raid_level_attr = { @@ -585,7 +584,7 @@ static ssize_t aac_show_unique_id(struct device *dev, if (sdev_channel(sdev) == CONTAINER_CHANNEL) memcpy(sn, aac->fsa_dev[sdev_id(sdev)].identifier, sizeof(sn)); - return snprintf(buf, 16 * 2 + 2, + return sysfs_emit(buf, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X\n", sn[0], sn[1], sn[2], sn[3], sn[4], sn[5], sn[6], sn[7], @@ -1296,7 +1295,7 @@ static ssize_t aac_show_driver_version(struct device *device, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", aac_driver_version); + return sysfs_emit(buf, "%s\n", aac_driver_version); } static ssize_t aac_show_serial_number(struct device *device, @@ -1322,15 +1321,13 @@ static ssize_t aac_show_serial_number(struct device *device, static ssize_t aac_show_max_channel(struct device *device, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", - class_to_shost(device)->max_channel); + return sysfs_emit(buf, "%d\n", class_to_shost(device)->max_channel); } static ssize_t aac_show_max_id(struct device *device, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%d\n", - class_to_shost(device)->max_id); + return sysfs_emit(buf, "%d\n", class_to_shost(device)->max_id); } static ssize_t aac_store_reset_adapter(struct device *device, From patchwork Tue Jan 16 04:51:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520422 Received: from esa4.hc1455-7.c3s2.iphmx.com (esa4.hc1455-7.c3s2.iphmx.com [68.232.139.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09EDA125B6; Tue, 16 Jan 2024 04:52:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="146510848" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="146510848" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa4.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:22 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 51F1DD9DA5; Tue, 16 Jan 2024 13:52:20 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 93B33D3F08; Tue, 16 Jan 2024 13:52:19 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 2DE116B4C8; Tue, 16 Jan 2024 13:52:19 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id C1C471A0070; Tue, 16 Jan 2024 12:52:18 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , "James E.J. Bottomley" , linux-scsi@vger.kernel.org Subject: [PATCH 18/42] drivers/scsi/aic94xx: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:27 +0800 Message-Id: <20240116045151.3940401-16-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.005 X-TMASE-Result: 10--14.280700-10.000000 X-TMASE-MatchedRID: Jy5kObkVr+g4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4TBF7stuNMMxTuctSpiuWyUUi4Ehat05499RlPzeVuQQyL5 QmWOgMfCndn/LfNMv39UVRVsVILlB/tI0Ln2VOhSAwosDBeuPwRDqmKczPoNZEEYpOvie10n4ft 7I4VD5pTqKm/4qdbn8gDLqnrRlXrZ8nn9tnqel2DsAVzN+Ov/sufUwsBq17glF6e34HbuhxCIJj M9P5nz1poVOrOUhhFgu1NHftySvFw== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/aic94xx/aic94xx_init.c:267:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/aic94xx/aic94xx_init.c:276:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/aic94xx/aic94xx_init.c:284:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/aic94xx/aic94xx_init.c:455:8-16: WARNING: please use sysfs_emit No functional change intended CC: "James E.J. Bottomley" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/aic94xx/aic94xx_init.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index 8a3340d8d7ad..b006e852c40c 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c @@ -264,8 +264,7 @@ static ssize_t asd_show_dev_rev(struct device *dev, struct device_attribute *attr, char *buf) { struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); - return snprintf(buf, PAGE_SIZE, "%s\n", - asd_dev_rev[asd_ha->revision_id]); + return sysfs_emit(buf, "%s\n", asd_dev_rev[asd_ha->revision_id]); } static DEVICE_ATTR(aic_revision, S_IRUGO, asd_show_dev_rev, NULL); @@ -273,7 +272,7 @@ static ssize_t asd_show_dev_bios_build(struct device *dev, struct device_attribute *attr,char *buf) { struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); - return snprintf(buf, PAGE_SIZE, "%d\n", asd_ha->hw_prof.bios.bld); + return sysfs_emit(buf, "%d\n", asd_ha->hw_prof.bios.bld); } static DEVICE_ATTR(bios_build, S_IRUGO, asd_show_dev_bios_build, NULL); @@ -281,7 +280,7 @@ static ssize_t asd_show_dev_pcba_sn(struct device *dev, struct device_attribute *attr, char *buf) { struct asd_ha_struct *asd_ha = dev_to_asd_ha(dev); - return snprintf(buf, PAGE_SIZE, "%s\n", asd_ha->hw_prof.pcba_sn); + return sysfs_emit(buf, "%s\n", asd_ha->hw_prof.pcba_sn); } static DEVICE_ATTR(pcba_sn, S_IRUGO, asd_show_dev_pcba_sn, NULL); @@ -452,9 +451,9 @@ static ssize_t asd_show_update_bios(struct device *dev, if (asd_ha->bios_status != FLASH_IN_PROGRESS) asd_ha->bios_status = FLASH_OK; - return snprintf(buf, PAGE_SIZE, "status=%x %s\n", - flash_error_table[i].err_code, - flash_error_table[i].reason); + return sysfs_emit(buf, "status=%x %s\n", + flash_error_table[i].err_code, + flash_error_table[i].reason); } static DEVICE_ATTR(update_bios, S_IRUGO|S_IWUSR, @@ -937,7 +936,7 @@ static int asd_scan_finished(struct Scsi_Host *shost, unsigned long time) static ssize_t version_show(struct device_driver *driver, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", ASD_DRIVER_VERSION); + return sysfs_emit(buf, "%s\n", ASD_DRIVER_VERSION); } static DRIVER_ATTR_RO(version); From patchwork Tue Jan 16 04:51:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520439 Received: from esa12.hc1455-7.c3s2.iphmx.com (esa12.hc1455-7.c3s2.iphmx.com [139.138.37.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E8F21CD01; Tue, 16 Jan 2024 04:52:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="125556479" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="125556479" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa12.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:22 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 9A925CD6C5; Tue, 16 Jan 2024 13:52:20 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id D6779D3F0C; Tue, 16 Jan 2024 13:52:19 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 73DE56B4C7; Tue, 16 Jan 2024 13:52:19 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 0D2B51A015F; Tue, 16 Jan 2024 12:52:19 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 19/42] drivers/scsi/arcmsr: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:28 +0800 Message-Id: <20240116045151.3940401-17-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.005 X-TMASE-Result: 10--13.423200-10.000000 X-TMASE-MatchedRID: st9CF01730Y4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4dL4Vi2vvkbTrMZ+BqQt2NrBOVz0Jwcxl6vCrG0TnfVUg9x e4gtUJtptIv0A3hSOW84WYLmQfXYmpoPHQXywp1ccUAl2qrF9ySUnLzk1+Ixzd3XtjqAaoMKO2Z R/UHJk1ZSE6QsCXaxnIAsIvOHmXuGXBXaJoB9JZxRFJJyf5BJe3QfwsVk0UbtuRXh7bFKB7oIGx JmGmz8hCBt8f7dUWk/wDN9PxHK8r5Rj7je41fFwPpCuffGH9zI= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/arcmsr/arcmsr_attr.c:261:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/arcmsr/arcmsr_attr.c:273:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/arcmsr/arcmsr_attr.c:285:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/arcmsr/arcmsr_attr.c:297:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/arcmsr/arcmsr_attr.c:309:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/arcmsr/arcmsr_attr.c:322:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/arcmsr/arcmsr_attr.c:335:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/arcmsr/arcmsr_attr.c:348:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/arcmsr/arcmsr_attr.c:361:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/arcmsr/arcmsr_attr.c:374:8-16: WARNING: please use sysfs_emit No functional change intended CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/arcmsr/arcmsr_attr.c | 40 ++++++++----------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c index baeb5e795690..0eecd354a3d0 100644 --- a/drivers/scsi/arcmsr/arcmsr_attr.c +++ b/drivers/scsi/arcmsr/arcmsr_attr.c @@ -258,9 +258,7 @@ static ssize_t arcmsr_attr_host_driver_version(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, - "%s\n", - ARCMSR_DRIVER_VERSION); + return sysfs_emit(buf, "%s\n", ARCMSR_DRIVER_VERSION); } static ssize_t @@ -270,9 +268,7 @@ arcmsr_attr_host_driver_posted_cmd(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - atomic_read(&acb->ccboutstandingcount)); + return sysfs_emit(buf, "%4d\n", atomic_read(&acb->ccboutstandingcount)); } static ssize_t @@ -282,9 +278,7 @@ arcmsr_attr_host_driver_reset(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->num_resets); + return sysfs_emit(buf, "%4d\n", acb->num_resets); } static ssize_t @@ -294,9 +288,7 @@ arcmsr_attr_host_driver_abort(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->num_aborts); + return sysfs_emit(buf, "%4d\n", acb->num_aborts); } static ssize_t @@ -306,9 +298,7 @@ arcmsr_attr_host_fw_model(struct device *dev, struct device_attribute *attr, struct Scsi_Host *host = class_to_shost(dev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%s\n", - acb->firm_model); + return sysfs_emit(buf, "%s\n", acb->firm_model); } static ssize_t @@ -319,9 +309,7 @@ arcmsr_attr_host_fw_version(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%s\n", - acb->firm_version); + return sysfs_emit(buf, "%s\n", acb->firm_version); } static ssize_t @@ -332,9 +320,7 @@ arcmsr_attr_host_fw_request_len(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_request_len); + return sysfs_emit(buf, "%4d\n", acb->firm_request_len); } static ssize_t @@ -345,9 +331,7 @@ arcmsr_attr_host_fw_numbers_queue(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_numbers_queue); + return sysfs_emit(buf, "%4d\n", acb->firm_numbers_queue); } static ssize_t @@ -358,9 +342,7 @@ arcmsr_attr_host_fw_sdram_size(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_sdram_size); + return sysfs_emit(buf, "%4d\n", acb->firm_sdram_size); } static ssize_t @@ -371,9 +353,7 @@ arcmsr_attr_host_fw_hd_channels(struct device *dev, struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata; - return snprintf(buf, PAGE_SIZE, - "%4d\n", - acb->firm_hd_channels); + return sysfs_emit(buf, PAGE_SIZE, "%4d\n", acb->firm_hd_channels); } static DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL); From patchwork Tue Jan 16 04:51:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520446 Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB89E1D528; Tue, 16 Jan 2024 04:52:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="146236503" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="146236503" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:23 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 05A73D9D92; Tue, 16 Jan 2024 13:52:21 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 3088AD8AD7; Tue, 16 Jan 2024 13:52:20 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id C2E0A6B4C7; Tue, 16 Jan 2024 13:52:19 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 5408C1A0070; Tue, 16 Jan 2024 12:52:19 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Ketan Mukadam , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 20/42] drivers/scsi/be2iscsi: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:29 +0800 Message-Id: <20240116045151.3940401-18-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.005 X-TMASE-Result: 10--10.024000-10.000000 X-TMASE-MatchedRID: /HyfiRbsgEU4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4dL4Vi2vvkbTrMZ+BqQt2NrBOVz0Jwcxl6vCrG0TnfVUg9x e4gtUJtpqw4mhfH/CjxItqQ/criE6dYlaOEy4HBxkGI+vgRTxMPlSepWcgdLPx8BJ7uScK23tk+ BYDo8lj+LzNWBegCW2wgn7iDBesS0gBwKKRHe+r1wp4zMzUhxAOXrm7p4CV73rYz1qlpCwNGo/2 6nVPTwlraIJ3ojsIQ8= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/be2iscsi/be_mgmt.c:1145:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/be2iscsi/be_mgmt.c:1164:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/be2iscsi/be_mgmt.c:1251:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/be2iscsi/be_mgmt.c:1280:8-16: WARNING: please use sysfs_emit No functional change intended CC: Ketan Mukadam CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/be2iscsi/be_mgmt.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/be2iscsi/be_mgmt.c b/drivers/scsi/be2iscsi/be_mgmt.c index 4e899ec1477d..35e12e13d580 100644 --- a/drivers/scsi/be2iscsi/be_mgmt.c +++ b/drivers/scsi/be2iscsi/be_mgmt.c @@ -1142,7 +1142,7 @@ ssize_t beiscsi_drvr_ver_disp(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, BE_NAME "\n"); + return sysfs_emit(buf, BE_NAME "\n"); } /** @@ -1161,7 +1161,7 @@ beiscsi_fw_ver_disp(struct device *dev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(dev); struct beiscsi_hba *phba = iscsi_host_priv(shost); - return snprintf(buf, PAGE_SIZE, "%s\n", phba->fw_ver_str); + return sysfs_emit(buf, "%s\n", phba->fw_ver_str); } /** @@ -1248,16 +1248,16 @@ beiscsi_adap_family_disp(struct device *dev, struct device_attribute *attr, case BE_DEVICE_ID1: case OC_DEVICE_ID1: case OC_DEVICE_ID2: - return snprintf(buf, PAGE_SIZE, - "Obsolete/Unsupported BE2 Adapter Family\n"); + return sysfs_emit(buf, + "Obsolete/Unsupported BE2 Adapter Family\n"); case BE_DEVICE_ID2: case OC_DEVICE_ID3: - return snprintf(buf, PAGE_SIZE, "BE3-R Adapter Family\n"); + return sysfs_emit(buf, "BE3-R Adapter Family\n"); case OC_SKH_ID1: - return snprintf(buf, PAGE_SIZE, "Skyhawk-R Adapter Family\n"); + return sysfs_emit(buf, "Skyhawk-R Adapter Family\n"); default: - return snprintf(buf, PAGE_SIZE, - "Unknown Adapter Family: 0x%x\n", dev_id); + return sysfs_emit(buf, + "Unknown Adapter Family: 0x%x\n", dev_id); } } @@ -1277,8 +1277,8 @@ beiscsi_phys_port_disp(struct device *dev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(dev); struct beiscsi_hba *phba = iscsi_host_priv(shost); - return snprintf(buf, PAGE_SIZE, "Port Identifier : %u\n", - phba->fw_config.phys_port); + return sysfs_emit(buf, "Port Identifier : %u\n", + phba->fw_config.phys_port); } void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params, From patchwork Tue Jan 16 04:51:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520427 Received: from esa2.hc1455-7.c3s2.iphmx.com (esa2.hc1455-7.c3s2.iphmx.com [207.54.90.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C848F12E72; Tue, 16 Jan 2024 04:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="146236950" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="146236950" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa2.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:29 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 480FAE8BFC; Tue, 16 Jan 2024 13:52:26 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 76700D9492; Tue, 16 Jan 2024 13:52:25 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 17D50200A7687; Tue, 16 Jan 2024 13:52:20 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id A2ABC1A015F; Tue, 16 Jan 2024 12:52:19 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Hannes Reinecke , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 21/42] drivers/scsi/fcoe: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:30 +0800 Message-Id: <20240116045151.3940401-19-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--13.189000-10.000000 X-TMASE-MatchedRID: 1RpOuHOu+mY4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4dL4Vi2vvkbTrMZ+BqQt2NrBOVz0Jwcxl6vCrG0TnfVUg9x e4gtUJtpqw4mhfH/Cj8iWCtuAyviG5RabHzIDOgzNgrlT5Ajc7n0tCKdnhB589yM15V5aWpj6C0 ePs7A07YnxgmBGuBcXu5Zf5rxVJ9Kns619g/0YwHLVeDbDQgLaXb5gFkYvCXU= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/fcoe/fcoe_sysfs.c:253:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/fcoe/fcoe_sysfs.c:268:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/fcoe/fcoe_sysfs.c:376:8-16: WARNING: please use sysfs_emit No functional change intended CC: Hannes Reinecke CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/fcoe/fcoe_sysfs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c index e17957f8085c..9705a579e0d0 100644 --- a/drivers/scsi/fcoe/fcoe_sysfs.c +++ b/drivers/scsi/fcoe/fcoe_sysfs.c @@ -250,7 +250,7 @@ static ssize_t show_fcf_state(struct device *dev, name = get_fcoe_fcf_state_name(fcf->state); if (!name) return -EINVAL; - return snprintf(buf, FCOE_FCF_STATE_MAX_NAMELEN, "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } static FCOE_DEVICE_ATTR(fcf, state, S_IRUGO, show_fcf_state, NULL); @@ -265,8 +265,7 @@ static ssize_t show_ctlr_mode(struct device *dev, name = get_fcoe_ctlr_mode_name(ctlr->mode); if (!name) return -EINVAL; - return snprintf(buf, FCOE_MAX_MODENAME_LEN, - "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } static ssize_t store_ctlr_mode(struct device *dev, @@ -373,8 +372,7 @@ static ssize_t show_ctlr_enabled_state(struct device *dev, name = get_fcoe_ctlr_enabled_state_name(ctlr->enabled); if (!name) return -EINVAL; - return snprintf(buf, FCOE_CTLR_ENABLED_MAX_NAMELEN, - "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } static FCOE_DEVICE_ATTR(ctlr, enabled, S_IRUGO | S_IWUSR, From patchwork Tue Jan 16 04:51:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520434 Received: from esa8.hc1455-7.c3s2.iphmx.com (esa8.hc1455-7.c3s2.iphmx.com [139.138.61.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9E7213AE1; Tue, 16 Jan 2024 04:52:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="134244456" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="134244456" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa8.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:23 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id CB073D502B; Tue, 16 Jan 2024 13:52:21 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 150FDF918; Tue, 16 Jan 2024 13:52:21 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 8F66920098E39; Tue, 16 Jan 2024 13:52:20 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id F077E1A0070; Tue, 16 Jan 2024 12:52:19 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Satish Kharat , Sesidhar Baddela , Karan Tilak Kumar , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 22/42] drivers/scsi/fnic: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:31 +0800 Message-Id: <20240116045151.3940401-20-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--15.843000-10.000000 X-TMASE-MatchedRID: /HyfiRbsgEU4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4QjYlErXRAnoLdBFrfY9r2n0swHSFcVJ6MC5DTEMxpeQfiq 1gj2xET8vYRhsicUjm84WYLmQfXYmFZzhICPDv1zfSQNpZkETVAv/9UzFeXITGxDxAG8HwlajxY yRBa/qJShNCXvA0fw+5MIx11wv+CM7AFczfjr/7KsrV0BIasCnhdH5on/HJCVyYEnCxQUw2a02F M5Ce/LbrkrhobT4pDY= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/fnic/fnic_attrs.c:17:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/fnic/fnic_attrs.c:23:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/fnic/fnic_attrs.c:31:8-16: WARNING: please use sysfs_emit No functional change intended CC: Satish Kharat CC: Sesidhar Baddela CC: Karan Tilak Kumar CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian Reviewed-by: Karan Tilak Kumar --- drivers/scsi/fnic/fnic_attrs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/fnic/fnic_attrs.c b/drivers/scsi/fnic/fnic_attrs.c index a61e0c5e6506..0c5e57c7e322 100644 --- a/drivers/scsi/fnic/fnic_attrs.c +++ b/drivers/scsi/fnic/fnic_attrs.c @@ -14,13 +14,13 @@ static ssize_t fnic_show_state(struct device *dev, struct fc_lport *lp = shost_priv(class_to_shost(dev)); struct fnic *fnic = lport_priv(lp); - return snprintf(buf, PAGE_SIZE, "%s\n", fnic_state_str[fnic->state]); + return sysfs_emit(buf, "%s\n", fnic_state_str[fnic->state]); } static ssize_t fnic_show_drv_version(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION); + return sysfs_emit(buf, "%s\n", DRV_VERSION); } static ssize_t fnic_show_link_state(struct device *dev, @@ -28,8 +28,7 @@ static ssize_t fnic_show_link_state(struct device *dev, { struct fc_lport *lp = shost_priv(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%s\n", (lp->link_up) - ? "Link Up" : "Link Down"); + return sysfs_emit(buf, "%s\n", (lp->link_up) ? "Link Up" : "Link Down"); } static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL); From patchwork Tue Jan 16 04:51:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520424 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08AA38495; Tue, 16 Jan 2024 04:52:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="134631008" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="134631008" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:24 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 1EDC5D9D96; Tue, 16 Jan 2024 13:52:22 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 418CED5405; Tue, 16 Jan 2024 13:52:21 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id D203E6B4C6; Tue, 16 Jan 2024 13:52:20 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 5B6A11A015F; Tue, 16 Jan 2024 12:52:20 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Don Brace , "James E.J. Bottomley" , "Martin K. Petersen" , storagedev@microchip.com, linux-scsi@vger.kernel.org Subject: [PATCH 23/42] drivers/scsi/hpsa: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:32 +0800 Message-Id: <20240116045151.3940401-21-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.005 X-TMASE-Result: 10--10.935000-10.000000 X-TMASE-MatchedRID: APZBv0eB5fI4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4dL4Vi2vvkbTrMZ+BqQt2NrBOVz0Jwcxl6vCrG0TnfVUgK6 qCGa1Z9eMQJrSLBycSUc+YfLo55UjzYigC8AbwLJyF4DyeABv+yUnLzk1+IxzkHPVkBTu31MSkx jSj8Gsp3trTGsCzWwdiEuXwwgKclUFcDs4QDuP/mY+xOrx57jWIQTCbSdwtuIDx6oqiF8ShuK5f hRxt1aAaUkHgTSDEhtCNEei2kg1tJcFdomgH0lnFEUknJ/kEl7dB/CxWTRRu25FeHtsUoHuzcE9 HLgEIHXa4kRhzyZJ025WgtyOGkiRRBN94Mo85kwchXTZ3Wukbw== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/hpsa.c:528:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/hpsa.c:538:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/hpsa.c:549:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/hpsa.c:561:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/hpsa.c:645:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/hpsa.c:724:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/hpsa.c:746:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/hpsa.c:775:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/hpsa.c:799:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/hpsa.c:898:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/hpsa.c:908:8-16: WARNING: please use sysfs_emit No functional change intended CC: Don Brace CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: storagedev@microchip.com CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/hpsa.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index af18d20f3079..5736c0f7a1be 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -525,8 +525,8 @@ static ssize_t host_show_firmware_revision(struct device *dev, if (!h->hba_inquiry_data) return 0; fwrev = &h->hba_inquiry_data[32]; - return snprintf(buf, 20, "%c%c%c%c\n", - fwrev[0], fwrev[1], fwrev[2], fwrev[3]); + return sysfs_emit(buf, "%c%c%c%c\n", + fwrev[0], fwrev[1], fwrev[2], fwrev[3]); } static ssize_t host_show_commands_outstanding(struct device *dev, @@ -535,8 +535,8 @@ static ssize_t host_show_commands_outstanding(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct ctlr_info *h = shost_to_hba(shost); - return snprintf(buf, 20, "%d\n", - atomic_read(&h->commands_outstanding)); + return sysfs_emit(buf, "%d\n", + atomic_read(&h->commands_outstanding)); } static ssize_t host_show_transport_mode(struct device *dev, @@ -546,9 +546,9 @@ static ssize_t host_show_transport_mode(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); h = shost_to_hba(shost); - return snprintf(buf, 20, "%s\n", - h->transMethod & CFGTBL_Trans_Performant ? - "performant" : "simple"); + return sysfs_emit(buf, "%s\n", + h->transMethod & CFGTBL_Trans_Performant ? + "performant" : "simple"); } static ssize_t host_show_hp_ssd_smart_path_status(struct device *dev, @@ -558,8 +558,8 @@ static ssize_t host_show_hp_ssd_smart_path_status(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); h = shost_to_hba(shost); - return snprintf(buf, 30, "HP SSD Smart Path %s\n", - (h->acciopath_status == 1) ? "enabled" : "disabled"); + return sysfs_emit(buf, "HP SSD Smart Path %s\n", + (h->acciopath_status == 1) ? "enabled" : "disabled"); } /* List of controllers which cannot be hard reset on kexec with reset_devices */ @@ -642,7 +642,7 @@ static ssize_t host_show_resettable(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); h = shost_to_hba(shost); - return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id)); + return sysfs_emit(buf, "%d\n", ctlr_is_resettable(h->board_id)); } static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[]) @@ -721,7 +721,7 @@ static ssize_t lunid_show(struct device *dev, } memcpy(lunid, hdev->scsi3addr, sizeof(lunid)); spin_unlock_irqrestore(&h->lock, flags); - return snprintf(buf, 20, "0x%8phN\n", lunid); + return sysfs_emit(buf, "0x%8phN\n", lunid); } static ssize_t unique_id_show(struct device *dev, @@ -743,7 +743,7 @@ static ssize_t unique_id_show(struct device *dev, } memcpy(sn, hdev->device_id, sizeof(sn)); spin_unlock_irqrestore(&h->lock, flags); - return snprintf(buf, 16 * 2 + 2, + return sysfs_emit(buf, "%02X%02X%02X%02X%02X%02X%02X%02X" "%02X%02X%02X%02X%02X%02X%02X%02X\n", sn[0], sn[1], sn[2], sn[3], @@ -772,7 +772,7 @@ static ssize_t sas_address_show(struct device *dev, sas_address = hdev->sas_address; spin_unlock_irqrestore(&h->lock, flags); - return snprintf(buf, PAGE_SIZE, "0x%016llx\n", sas_address); + return sysfs_emit(buf, "0x%016llx\n", sas_address); } static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev, @@ -796,10 +796,10 @@ static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev, spin_unlock_irqrestore(&h->lock, flags); if (hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) - return snprintf(buf, 20, "%d\n", offload_enabled); + return sysfs_emit(buf, "%d\n", offload_enabled); else - return snprintf(buf, 40, "%s\n", - "Not applicable for a controller"); + return sysfs_emit(buf, "%s\n", + "Not applicable for a controller"); } #define MAX_PATHS 8 @@ -895,7 +895,7 @@ static ssize_t host_show_ctlr_num(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); h = shost_to_hba(shost); - return snprintf(buf, 20, "%d\n", h->ctlr); + return sysfs_emit(buf, "%d\n", h->ctlr); } static ssize_t host_show_legacy_board(struct device *dev, @@ -905,7 +905,7 @@ static ssize_t host_show_legacy_board(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); h = shost_to_hba(shost); - return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); + return sysfs_emit(buf, "%d\n", h->legacy_board ? 1 : 0); } static DEVICE_ATTR_RO(raid_level); From patchwork Tue Jan 16 04:51:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520423 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 760B512B9F; Tue, 16 Jan 2024 04:52:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="134631007" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="134631007" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:24 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 5CC72E7520; Tue, 16 Jan 2024 13:52:22 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 8442ED948C; Tue, 16 Jan 2024 13:52:21 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 27BAD6B4CA; Tue, 16 Jan 2024 13:52:21 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id B22941A0160; Tue, 16 Jan 2024 12:52:20 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , HighPoint Linux Team , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 24/42] drivers/scsi/hptiop: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:33 +0800 Message-Id: <20240116045151.3940401-22-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.005 X-TMASE-Result: 10--11.907000-10.000000 X-TMASE-MatchedRID: /HyfiRbsgEU4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4WJleE90a8+1LdBFrfY9r2n0swHSFcVJ6MC5DTEMxpeQfiq 1gj2xET8vYRhsicUjm01kA/urPNIDxG11D4HJ3wQZgmFGHqyx645UafLmrvaGqU5CNByvM6VJXG E2pW97R+LzNWBegCW2wgn7iDBesS0gBwKKRHe+r3Rrqf0GOj13/eUbqiR8ae1kOm2nW3AY4MT4g PlvnxGOV6KEs3hne9Y= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/hptiop.c:1114:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/hptiop.c:1123:8-16: WARNING: please use sysfs_emit No functional change intended CC: HighPoint Linux Team CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/hptiop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c index f5334ccbf2ca..65426df93270 100644 --- a/drivers/scsi/hptiop.c +++ b/drivers/scsi/hptiop.c @@ -1111,7 +1111,7 @@ static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev, static ssize_t hptiop_show_version(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", driver_ver); + return sysfs_emit(buf, "%s\n", driver_ver); } static ssize_t hptiop_show_fw_version(struct device *dev, @@ -1120,7 +1120,7 @@ static ssize_t hptiop_show_fw_version(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata; - return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", + return sysfs_emit(buf, "%d.%d.%d.%d\n", hba->firmware_version >> 24, (hba->firmware_version >> 16) & 0xff, (hba->firmware_version >> 8) & 0xff, From patchwork Tue Jan 16 04:51:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520447 Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 598111DFDD; Tue, 16 Jan 2024 04:52:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="146236508" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="146236508" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:25 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id DE32CE7598; Tue, 16 Jan 2024 13:52:22 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 159A7BF3E1; Tue, 16 Jan 2024 13:52:22 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id AF2C7200A571F; Tue, 16 Jan 2024 13:52:21 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 0CC131A0070; Tue, 16 Jan 2024 12:52:21 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Tyrel Datwyler , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH 25/42] drivers/scsi/ibmvscsi: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:34 +0800 Message-Id: <20240116045151.3940401-23-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--16.426000-10.000000 X-TMASE-MatchedRID: Jy5kObkVr+g4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4TBF7stuNMMxLdBFrfY9r2lSuvtBzlaEqL42hLbi424DvwU evDt+uW5/XjpbSJS7a0NziVKCujClh44pFEtxshLfSQNpZkETVAv/9UzFeXITS4KPPiCB23AokC /iIVpcslHmENCJyDB7gDLqnrRlXrZ8nn9tnqel2JBlLa6MK1y4 X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/ibmvscsi/ibmvfc.c:3483:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/ibmvscsi/ibmvfc.c:3493:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/ibmvscsi/ibmvfc.c:3503:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/ibmvscsi/ibmvfc.c:3513:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/ibmvscsi/ibmvfc.c:3522:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/ibmvscsi/ibmvfc.c:3530:8-16: WARNING: please use sysfs_emit No functional change intended CC: Tyrel Datwyler CC: Michael Ellerman CC: Nicholas Piggin CC: Christophe Leroy CC: "Aneesh Kumar K.V" CC: "Naveen N. Rao" CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org CC: linuxppc-dev@lists.ozlabs.org Signed-off-by: Li Zhijian Acked-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 92c440f2e3a7..4be013976866 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -3480,8 +3480,7 @@ static ssize_t ibmvfc_show_host_partition_name(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct ibmvfc_host *vhost = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%s\n", - vhost->login_buf->resp.partition_name); + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.partition_name); } static ssize_t ibmvfc_show_host_device_name(struct device *dev, @@ -3490,8 +3489,7 @@ static ssize_t ibmvfc_show_host_device_name(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct ibmvfc_host *vhost = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%s\n", - vhost->login_buf->resp.device_name); + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.device_name); } static ssize_t ibmvfc_show_host_loc_code(struct device *dev, @@ -3500,8 +3498,7 @@ static ssize_t ibmvfc_show_host_loc_code(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct ibmvfc_host *vhost = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%s\n", - vhost->login_buf->resp.port_loc_code); + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.port_loc_code); } static ssize_t ibmvfc_show_host_drc_name(struct device *dev, @@ -3510,8 +3507,7 @@ static ssize_t ibmvfc_show_host_drc_name(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct ibmvfc_host *vhost = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%s\n", - vhost->login_buf->resp.drc_name); + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.drc_name); } static ssize_t ibmvfc_show_host_npiv_version(struct device *dev, @@ -3519,7 +3515,8 @@ static ssize_t ibmvfc_show_host_npiv_version(struct device *dev, { struct Scsi_Host *shost = class_to_shost(dev); struct ibmvfc_host *vhost = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%d\n", be32_to_cpu(vhost->login_buf->resp.version)); + return sysfs_emit(buf, "%d\n", + be32_to_cpu(vhost->login_buf->resp.version)); } static ssize_t ibmvfc_show_host_capabilities(struct device *dev, @@ -3527,7 +3524,8 @@ static ssize_t ibmvfc_show_host_capabilities(struct device *dev, { struct Scsi_Host *shost = class_to_shost(dev); struct ibmvfc_host *vhost = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%llx\n", be64_to_cpu(vhost->login_buf->resp.capabilities)); + return sysfs_emit(buf, "%llx\n", + be64_to_cpu(vhost->login_buf->resp.capabilities)); } /** @@ -3548,7 +3546,7 @@ static ssize_t ibmvfc_show_log_level(struct device *dev, int len; spin_lock_irqsave(shost->host_lock, flags); - len = snprintf(buf, PAGE_SIZE, "%d\n", vhost->log_level); + len = sysfs_emit(buf, "%d\n", vhost->log_level); spin_unlock_irqrestore(shost->host_lock, flags); return len; } @@ -3587,7 +3585,7 @@ static ssize_t ibmvfc_show_scsi_channels(struct device *dev, int len; spin_lock_irqsave(shost->host_lock, flags); - len = snprintf(buf, PAGE_SIZE, "%d\n", scsi->desired_queues); + len = sysfs_emit(buf, "%d\n", scsi->desired_queues); spin_unlock_irqrestore(shost->host_lock, flags); return len; } From patchwork Tue Jan 16 04:51:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520425 Received: from esa4.hc1455-7.c3s2.iphmx.com (esa4.hc1455-7.c3s2.iphmx.com [68.232.139.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C0CE10A2D; Tue, 16 Jan 2024 04:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="146510858" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="146510858" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa4.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:25 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 58FD8D9D96; Tue, 16 Jan 2024 13:52:23 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 4E064BF3E1; Tue, 16 Jan 2024 13:52:22 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id E4343200A7693; Tue, 16 Jan 2024 13:52:21 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 89A2D1A015F; Tue, 16 Jan 2024 12:52:21 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Michael Cyr , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH 26/42] drivers/scsi/ibmvscsi_tgt: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:35 +0800 Message-Id: <20240116045151.3940401-24-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--7.569600-10.000000 X-TMASE-MatchedRID: /HyfiRbsgEU4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4dL4Vi2vvkbTrMZ+BqQt2NrBOVz0Jwcxl6vCrG0TnfVUT85 +SH/4Avhevs1eD+lKBH0fuNpVKhqA3H7LcTAG9qsAPmNKDWsW0BSN/rCvqoYAd6kz8j616pyjxY yRBa/qJShNCXvA0fw+5MIx11wv+CM7AFczfjr/7A6F5KeXydnAF/31Msza5bSY7PnyToWaPMvAH ZF2Qi5GQ0Ax55YWhzQ= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3619:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3625:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3633:8-16: WARNING: please use sysfs_emit No functional change intended CC: Michael Cyr CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org CC: target-devel@vger.kernel.org Signed-off-by: Li Zhijian Acked-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c index 4dc411a58107..071dd3c4dcf8 100644 --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c @@ -3616,13 +3616,13 @@ static void ibmvscsis_remove(struct vio_dev *vdev) static ssize_t system_id_show(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", system_id); + return sysfs_emit(buf, "%s\n", system_id); } static ssize_t partition_number_show(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%x\n", partition_number); + return sysfs_emit(buf, "%x\n", partition_number); } static ssize_t unit_address_show(struct device *dev, @@ -3630,7 +3630,7 @@ static ssize_t unit_address_show(struct device *dev, { struct scsi_info *vscsi = container_of(dev, struct scsi_info, dev); - return snprintf(buf, PAGE_SIZE, "%x\n", vscsi->dma_dev->unit_address); + return sysfs_emit(buf, "%x\n", vscsi->dma_dev->unit_address); } static int ibmvscsis_get_system_info(void) From patchwork Tue Jan 16 04:51:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520450 Received: from esa10.hc1455-7.c3s2.iphmx.com (esa10.hc1455-7.c3s2.iphmx.com [139.138.36.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01C38125B8; Tue, 16 Jan 2024 04:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="133883823" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="133883823" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa10.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:26 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id ADC21D9D96; Tue, 16 Jan 2024 13:52:23 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id D9229BF498; Tue, 16 Jan 2024 13:52:22 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 65968200A571F; Tue, 16 Jan 2024 13:52:22 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id DF70F1A0070; Tue, 16 Jan 2024 12:52:21 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Artur Paszkiewicz , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 27/42] drivers/scsi/isci: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:36 +0800 Message-Id: <20240116045151.3940401-25-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--8.691000-10.000000 X-TMASE-MatchedRID: 6SYb29c3rTQ4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4YuJ+QzKcxqTLdBFrfY9r2n0swHSFcVJ6MC5DTEMxpeQfiq 1gj2xET8vYRhsicUjm84WYLmQfXYmpoPHQXywp1dKzjuZtPtIBH0tCKdnhB58I/9UW5M5dRNp7q EhmmPgy46HM5rqDwqtIoT1kA8A17I5ZLFwfHbExp8OJA/0wv/axoNjqIW+oL/stU4J8kSlZQ== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/isci/init.c:140:8-16: WARNING: please use sysfs_emit No functional change intended CC: Artur Paszkiewicz CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian Reviewed-by: Artur Paszkiewicz --- drivers/scsi/isci/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index 6277162a028b..c582a3932cea 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -137,7 +137,7 @@ static ssize_t isci_show_id(struct device *dev, struct device_attribute *attr, c struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(shost); struct isci_host *ihost = container_of(sas_ha, typeof(*ihost), sas_ha); - return snprintf(buf, PAGE_SIZE, "%d\n", ihost->id); + return sysfs_emit(buf, "%d\n", ihost->id); } static DEVICE_ATTR(isci_id, S_IRUGO, isci_show_id, NULL); From patchwork Tue Jan 16 04:51:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520432 Received: from esa7.hc1455-7.c3s2.iphmx.com (esa7.hc1455-7.c3s2.iphmx.com [139.138.61.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E793134D7; Tue, 16 Jan 2024 04:52:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="125018779" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="125018779" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:26 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 6992FD7AC6; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 96BF0BF3E1; Tue, 16 Jan 2024 13:52:23 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 23F11200A571F; Tue, 16 Jan 2024 13:52:23 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 457121A0160; Tue, 16 Jan 2024 12:52:22 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Kashyap Desai , Sumit Saxena , Shivasharan S , Chandrakanth patil , "James E.J. Bottomley" , "Martin K. Petersen" , megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org Subject: [PATCH 28/42] drivers/scsi/megaraid: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:37 +0800 Message-Id: <20240116045151.3940401-26-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--13.640000-10.000000 X-TMASE-MatchedRID: /HyfiRbsgEU4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckMWl hj9iHeVpPG/R1GUal1VM0AWQBBcXdpRSkbxKeJc4LdBFrfY9r2n0swHSFcVJ6MC5DTEMxpeQfiq 1gj2xET/NAIHvYUto2qKy6bttPkB+0FQxfjRHOzgRW4LR41Fi8iUnLzk1+Ixzd3XtjqAaoMJUfP E7He1RweLzNWBegCW2wgn7iDBesS0gBwKKRHe+r2rtiS8aKA00N8teWEVLok9FpoERaMiOMdhR2 K6sbuJw60xzOfqTO38= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/megaraid/megaraid_sas_base.c:3336:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/megaraid/megaraid_sas_base.c:3382:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/megaraid/megaraid_sas_base.c:3389:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/megaraid/megaraid_sas_base.c:3399:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/megaraid/megaraid_sas_base.c:3409:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/megaraid/megaraid_sas_base.c:3419:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/megaraid/megaraid_sas_base.c:3473:8-16: WARNING: please use sysfs_emit No functional change intended CC: Kashyap Desai CC: Sumit Saxena CC: Shivasharan S CC: Chandrakanth patil CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: megaraidlinux.pdl@broadcom.com CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/megaraid/megaraid_sas_base.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 3d4f13da1ae8..4e4414df1935 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -3333,7 +3333,7 @@ fw_crash_buffer_size_show(struct device *cdev, struct megasas_instance *instance = (struct megasas_instance *) shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%ld\n", (unsigned long) + return sysfs_emit(buf, "%ld\n", (unsigned long) ((instance->fw_crash_buffer_size) * 1024 * 1024)/PAGE_SIZE); } @@ -3379,14 +3379,14 @@ fw_crash_state_show(struct device *cdev, struct megasas_instance *instance = (struct megasas_instance *) shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%d\n", instance->fw_crash_state); + return sysfs_emit(buf, "%d\n", instance->fw_crash_state); } static ssize_t page_size_show(struct device *cdev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%ld\n", (unsigned long)PAGE_SIZE - 1); + return sysfs_emit(buf, "%ld\n", (unsigned long)PAGE_SIZE - 1); } static ssize_t @@ -3396,7 +3396,7 @@ ldio_outstanding_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->ldio_outstanding)); + return sysfs_emit(buf, "%d\n", atomic_read(&instance->ldio_outstanding)); } static ssize_t @@ -3406,7 +3406,7 @@ fw_cmds_outstanding_show(struct device *cdev, struct Scsi_Host *shost = class_to_shost(cdev); struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&instance->fw_outstanding)); + return sysfs_emit(buf, "%d\n", atomic_read(&instance->fw_outstanding)); } static ssize_t @@ -3416,7 +3416,7 @@ enable_sdev_max_qd_show(struct device *cdev, struct Scsi_Host *shost = class_to_shost(cdev); struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%d\n", instance->enable_sdev_max_qd); + return sysfs_emit(buf, "%d\n", instance->enable_sdev_max_qd); } static ssize_t @@ -3470,8 +3470,7 @@ raid_map_id_show(struct device *cdev, struct device_attribute *attr, struct megasas_instance *instance = (struct megasas_instance *)shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%ld\n", - (unsigned long)instance->map_id); + return sysfs_emit(buf, "%ld\n", (unsigned long)instance->map_id); } static DEVICE_ATTR_RW(fw_crash_buffer); From patchwork Tue Jan 16 04:51:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520436 Received: from esa6.hc1455-7.c3s2.iphmx.com (esa6.hc1455-7.c3s2.iphmx.com [68.232.139.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F8B11C288; Tue, 16 Jan 2024 04:52:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="147894816" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="147894816" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:26 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 7E38ED6186; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id B776DD3F08; Tue, 16 Jan 2024 13:52:23 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 425CA6B4C6; Tue, 16 Jan 2024 13:52:23 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id B31571A0070; Tue, 16 Jan 2024 12:52:22 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , "James E.J. Bottomley" , "Martin K. Petersen" , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org Subject: [PATCH 29/42] drivers/scsi/mpt3sas: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:38 +0800 Message-Id: <20240116045151.3940401-27-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.005 X-TMASE-Result: 10--23.447300-10.000000 X-TMASE-MatchedRID: APZBv0eB5fI4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4dL4Vi2vvkbTrMZ+BqQt2NrBOVz0Jwcxl6vCrG0TnfVUg9x e4gtUJtptIv0A3hSOW65d/qNNaLIkxrdsXS7GN2SXd9LOVu4KPfCrUlDnEXiSca+Jn8RypgsDdt 9bAWFhkAgrlr7+3X3c1i1obzNdfwPpHzzvfxlA9R1qGr6sYOf/W+HVwTKSJIbB1z1KvCXwaP7yO Wod/KQ1yicbDtMS+S90CabJqrYNnB8TzIzimOwPVnRXm1iHN1bEQdG7H66TyOk/y0w7JiZo X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2825:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2850:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2873:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2893:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2912:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2932:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2952:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2971:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:2990:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3012:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3034:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3055:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3077:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3097:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3133:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3170:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3198:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3320:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3407:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3828:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3848:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:3996:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:4018:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/mpt3sas/mpt3sas_ctl.c:4056:8-16: WARNING: please use sysfs_emit No functional change intended CC: Sathya Prakash CC: Sreekanth Reddy CC: Suganath Prabu Subramani CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: MPT-FusionLinux.pdl@broadcom.com CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 60 +++++++++++++++--------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index efdb8178db32..e7d7408ce773 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -2822,7 +2822,7 @@ version_fw_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n", + return sysfs_emit(buf, "%02d.%02d.%02d.%02d\n", (ioc->facts.FWVersion.Word & 0xFF000000) >> 24, (ioc->facts.FWVersion.Word & 0x00FF0000) >> 16, (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8, @@ -2847,7 +2847,7 @@ version_bios_show(struct device *cdev, struct device_attribute *attr, u32 version = le32_to_cpu(ioc->bios_pg3.BiosVersion); - return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n", + return sysfs_emit(buf, "%02d.%02d.%02d.%02d\n", (version & 0xFF000000) >> 24, (version & 0x00FF0000) >> 16, (version & 0x0000FF00) >> 8, @@ -2870,8 +2870,8 @@ version_mpi_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%03x.%02x\n", - ioc->facts.MsgVersion, ioc->facts.HeaderVersion >> 8); + return sysfs_emit(buf, "%03x.%02x\n", + ioc->facts.MsgVersion, ioc->facts.HeaderVersion >> 8); } static DEVICE_ATTR_RO(version_mpi); @@ -2890,7 +2890,7 @@ version_product_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, 16, "%s\n", ioc->manu_pg0.ChipName); + return sysfs_emit(buf, "%s\n", ioc->manu_pg0.ChipName); } static DEVICE_ATTR_RO(version_product); @@ -2909,7 +2909,7 @@ version_nvdata_persistent_show(struct device *cdev, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%08xh\n", + return sysfs_emit(buf, "%08xh\n", le32_to_cpu(ioc->iounit_pg0.NvdataVersionPersistent.Word)); } static DEVICE_ATTR_RO(version_nvdata_persistent); @@ -2929,7 +2929,7 @@ version_nvdata_default_show(struct device *cdev, struct device_attribute struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%08xh\n", + return sysfs_emit(buf, "%08xh\n", le32_to_cpu(ioc->iounit_pg0.NvdataVersionDefault.Word)); } static DEVICE_ATTR_RO(version_nvdata_default); @@ -2949,7 +2949,7 @@ board_name_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardName); + return sysfs_emit(buf, "%s\n", ioc->manu_pg0.BoardName); } static DEVICE_ATTR_RO(board_name); @@ -2968,7 +2968,7 @@ board_assembly_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardAssembly); + return sysfs_emit(buf, "%s\n", ioc->manu_pg0.BoardAssembly); } static DEVICE_ATTR_RO(board_assembly); @@ -2987,7 +2987,7 @@ board_tracer_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardTracerNumber); + return sysfs_emit(buf, "%s\n", ioc->manu_pg0.BoardTracerNumber); } static DEVICE_ATTR_RO(board_tracer); @@ -3009,7 +3009,7 @@ io_delay_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay); + return sysfs_emit(buf, "%02d\n", ioc->io_missing_delay); } static DEVICE_ATTR_RO(io_delay); @@ -3031,7 +3031,7 @@ device_delay_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay); + return sysfs_emit(buf, "%02d\n", ioc->device_missing_delay); } static DEVICE_ATTR_RO(device_delay); @@ -3052,7 +3052,7 @@ fw_queue_depth_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->facts.RequestCredit); + return sysfs_emit(buf, "%02d\n", ioc->facts.RequestCredit); } static DEVICE_ATTR_RO(fw_queue_depth); @@ -3074,7 +3074,7 @@ host_sas_address_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "0x%016llx\n", + return sysfs_emit(buf, "0x%016llx\n", (unsigned long long)ioc->sas_hba.sas_address); } static DEVICE_ATTR_RO(host_sas_address); @@ -3094,7 +3094,7 @@ logging_level_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->logging_level); + return sysfs_emit(buf, "%08xh\n", ioc->logging_level); } static ssize_t logging_level_store(struct device *cdev, struct device_attribute *attr, @@ -3130,7 +3130,7 @@ fwfault_debug_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%d\n", ioc->fwfault_debug); + return sysfs_emit(buf, "%d\n", ioc->fwfault_debug); } static ssize_t fwfault_debug_store(struct device *cdev, struct device_attribute *attr, @@ -3167,7 +3167,7 @@ ioc_reset_count_show(struct device *cdev, struct device_attribute *attr, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%d\n", ioc->ioc_reset_count); + return sysfs_emit(buf, "%d\n", ioc->ioc_reset_count); } static DEVICE_ATTR_RO(ioc_reset_count); @@ -3195,7 +3195,7 @@ reply_queue_count_show(struct device *cdev, else reply_queue_count = 1; - return snprintf(buf, PAGE_SIZE, "%d\n", reply_queue_count); + return sysfs_emit(buf, "%d\n", reply_queue_count); } static DEVICE_ATTR_RO(reply_queue_count); @@ -3260,7 +3260,7 @@ BRM_status_show(struct device *cdev, struct device_attribute *attr, /* BRM status is in bit zero of GPIOVal[24] */ backup_rail_monitor_status = le16_to_cpu(io_unit_pg3.GPIOVal[24]); - rc = snprintf(buf, PAGE_SIZE, "%d\n", (backup_rail_monitor_status & 1)); + rc = sysfs_emit(buf, "%d\n", (backup_rail_monitor_status & 1)); out: mutex_unlock(&ioc->pci_access_mutex); @@ -3317,7 +3317,7 @@ host_trace_buffer_size_show(struct device *cdev, size = le32_to_cpu(request_data->Size); ioc->ring_buffer_sz = size; - return snprintf(buf, PAGE_SIZE, "%d\n", size); + return sysfs_emit(buf, "%d\n", size); } static DEVICE_ATTR_RO(host_trace_buffer_size); @@ -3404,12 +3404,12 @@ host_trace_buffer_enable_show(struct device *cdev, if ((!ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE]) || ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & MPT3_DIAG_BUFFER_IS_REGISTERED) == 0)) - return snprintf(buf, PAGE_SIZE, "off\n"); + return sysfs_emit(buf, "off\n"); else if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & MPT3_DIAG_BUFFER_IS_RELEASED)) - return snprintf(buf, PAGE_SIZE, "release\n"); + return sysfs_emit(buf, "release\n"); else - return snprintf(buf, PAGE_SIZE, "post\n"); + return sysfs_emit(buf, "post\n"); } static ssize_t @@ -3825,7 +3825,7 @@ drv_support_bitmap_show(struct device *cdev, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "0x%08x\n", ioc->drv_support_bitmap); + return sysfs_emit(buf, "0x%08x\n", ioc->drv_support_bitmap); } static DEVICE_ATTR_RO(drv_support_bitmap); @@ -3845,7 +3845,7 @@ enable_sdev_max_qd_show(struct device *cdev, struct Scsi_Host *shost = class_to_shost(cdev); struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); - return snprintf(buf, PAGE_SIZE, "%d\n", ioc->enable_sdev_max_qd); + return sysfs_emit(buf, "%d\n", ioc->enable_sdev_max_qd); } /** @@ -3993,7 +3993,7 @@ sas_address_show(struct device *dev, struct device_attribute *attr, struct scsi_device *sdev = to_scsi_device(dev); struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata; - return snprintf(buf, PAGE_SIZE, "0x%016llx\n", + return sysfs_emit(buf, "0x%016llx\n", (unsigned long long)sas_device_priv_data->sas_target->sas_address); } static DEVICE_ATTR_RO(sas_address); @@ -4015,8 +4015,8 @@ sas_device_handle_show(struct device *dev, struct device_attribute *attr, struct scsi_device *sdev = to_scsi_device(dev); struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata; - return snprintf(buf, PAGE_SIZE, "0x%04x\n", - sas_device_priv_data->sas_target->handle); + return sysfs_emit(buf, "0x%04x\n", + sas_device_priv_data->sas_target->handle); } static DEVICE_ATTR_RO(sas_device_handle); @@ -4053,8 +4053,8 @@ sas_ncq_prio_enable_show(struct device *dev, struct scsi_device *sdev = to_scsi_device(dev); struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata; - return snprintf(buf, PAGE_SIZE, "%d\n", - sas_device_priv_data->ncq_prio_enable); + return sysfs_emit(buf, "%d\n", + sas_device_priv_data->ncq_prio_enable); } static ssize_t From patchwork Tue Jan 16 04:51:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520440 Received: from esa6.hc1455-7.c3s2.iphmx.com (esa6.hc1455-7.c3s2.iphmx.com [68.232.139.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 701B61CD33; Tue, 16 Jan 2024 04:52:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="147894818" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="147894818" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:26 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id E0355D64B1; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 13430BF3E1; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 9493F200A7693; Tue, 16 Jan 2024 13:52:23 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 26AE11A015F; Tue, 16 Jan 2024 12:52:23 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Hannes Reinecke , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 30/42] drivers/scsi/myrb: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:39 +0800 Message-Id: <20240116045151.3940401-28-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--8.893800-10.000000 X-TMASE-MatchedRID: ebEStOsB1eE4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4TBF7stuNMMxLdBFrfY9r2nBOVz0Jwcxl6vCrG0TnfVUg9x e4gtUJtpqw4mhfH/Cj7xaYlLIzqlbaTkWqXcVprtntEdzQBf3IaEetkTb5Lzr/el+DRyvXwj3MM lWBma+yPZDRpNFX1vsPXZweTH/QGs1rNmBlj28a54CIKY/Hg3AGdQnQSTrKGPEQdG7H66TyH4gK q42LRYkmOeZ/APcnU2x+8bnxF0U7UDKtlSVxUFKwnbA8hGMEzl+3BndfXUhXQ== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/myrb.c:1770:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/myrb.c:1889:10-18: WARNING: please use sysfs_emit > ./drivers/scsi/myrb.c:1906:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/myrb.c:2143:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/myrb.c:2153:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/myrb.c:2163:8-16: WARNING: please use sysfs_emit No functional change intended CC: Hannes Reinecke CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/myrb.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c index ca2e932dd9b7..06a5e6fb9f99 100644 --- a/drivers/scsi/myrb.c +++ b/drivers/scsi/myrb.c @@ -1767,7 +1767,7 @@ static ssize_t raid_state_show(struct device *dev, int ret; if (!sdev->hostdata) - return snprintf(buf, 16, "Unknown\n"); + return sysfs_emit(buf, "Unknown\n"); if (sdev->channel == myrb_logical_channel(sdev->host)) { struct myrb_ldev_info *ldev_info = sdev->hostdata; @@ -1775,10 +1775,10 @@ static ssize_t raid_state_show(struct device *dev, name = myrb_devstate_name(ldev_info->state); if (name) - ret = snprintf(buf, 32, "%s\n", name); + ret = sysfs_emit(buf, "%s\n", name); else - ret = snprintf(buf, 32, "Invalid (%02X)\n", - ldev_info->state); + ret = sysfs_emit(buf, "Invalid (%02X)\n", + ldev_info->state); } else { struct myrb_pdev_state *pdev_info = sdev->hostdata; unsigned short status; @@ -1796,10 +1796,10 @@ static ssize_t raid_state_show(struct device *dev, else name = myrb_devstate_name(pdev_info->state); if (name) - ret = snprintf(buf, 32, "%s\n", name); + ret = sysfs_emit(buf, "%s\n", name); else - ret = snprintf(buf, 32, "Invalid (%02X)\n", - pdev_info->state); + ret = sysfs_emit(buf, "Invalid (%02X)\n", + pdev_info->state); } return ret; } @@ -1886,11 +1886,11 @@ static ssize_t raid_level_show(struct device *dev, name = myrb_raidlevel_name(ldev_info->raid_level); if (!name) - return snprintf(buf, 32, "Invalid (%02X)\n", - ldev_info->state); - return snprintf(buf, 32, "%s\n", name); + return sysfs_emit(buf, "Invalid (%02X)\n", + ldev_info->state); + return sysfs_emit(buf, "%s\n", name); } - return snprintf(buf, 32, "Physical Drive\n"); + return sysfs_emit(buf, "Physical Drive\n"); } static DEVICE_ATTR_RO(raid_level); @@ -1903,17 +1903,17 @@ static ssize_t rebuild_show(struct device *dev, unsigned char status; if (sdev->channel < myrb_logical_channel(sdev->host)) - return snprintf(buf, 32, "physical device - not rebuilding\n"); + return sysfs_emit(buf, "physical device - not rebuilding\n"); status = myrb_get_rbld_progress(cb, &rbld_buf); if (rbld_buf.ldev_num != sdev->id || status != MYRB_STATUS_SUCCESS) - return snprintf(buf, 32, "not rebuilding\n"); + return sysfs_emit(buf, "not rebuilding\n"); - return snprintf(buf, 32, "rebuilding block %u of %u\n", - rbld_buf.ldev_size - rbld_buf.blocks_left, - rbld_buf.ldev_size); + return sysfs_emit(buf, "rebuilding block %u of %u\n", + rbld_buf.ldev_size - rbld_buf.blocks_left, + rbld_buf.ldev_size); } static ssize_t rebuild_store(struct device *dev, @@ -2140,7 +2140,7 @@ static ssize_t ctlr_num_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrb_hba *cb = shost_priv(shost); - return snprintf(buf, 20, "%u\n", cb->ctlr_num); + return sysfs_emit(buf, "%u\n", cb->ctlr_num); } static DEVICE_ATTR_RO(ctlr_num); @@ -2150,7 +2150,7 @@ static ssize_t firmware_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrb_hba *cb = shost_priv(shost); - return snprintf(buf, 16, "%s\n", cb->fw_version); + return sysfs_emit(buf, "%s\n", cb->fw_version); } static DEVICE_ATTR_RO(firmware); @@ -2160,7 +2160,7 @@ static ssize_t model_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrb_hba *cb = shost_priv(shost); - return snprintf(buf, 16, "%s\n", cb->model_name); + return sysfs_emit(buf, "%s\n", cb->model_name); } static DEVICE_ATTR_RO(model); From patchwork Tue Jan 16 04:51:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520430 Received: from esa4.hc1455-7.c3s2.iphmx.com (esa4.hc1455-7.c3s2.iphmx.com [68.232.139.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56BC710A3C; Tue, 16 Jan 2024 04:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="146510864" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="146510864" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa4.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:27 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 3E61CD64B1; Tue, 16 Jan 2024 13:52:25 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 64578BF4C4; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id E561D200A56C5; Tue, 16 Jan 2024 13:52:23 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 743421A0070; Tue, 16 Jan 2024 12:52:23 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Hannes Reinecke , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 31/42] drivers/scsi/myrs: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:40 +0800 Message-Id: <20240116045151.3940401-29-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--8.367900-10.000000 X-TMASE-MatchedRID: 1XqbU0So2KU4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4TBF7stuNMMxLdBFrfY9r2nBOVz0Jwcxl6vCrG0TnfVUg9x e4gtUJtpqw4mhfH/Cj7xaYlLIzqlbaTkWqXcVprtB9I5g6XEpixgff28UuvIT3EZVcUQp7dZ1gn ekL1c23uwlX0g/WxMCp43H9nP9RJd1iVo4TLgcHLqQyAveNtg6Q1Zooh0EhXh7Iyy6sbAxFWRSp +vSaR74xb0e/VUxknqAMuqetGVetnyef22ep6XYOwBXM346/+yhd8PXj9ue1lP2heyqFD+YWmTz uMGeDTdFU4VE3yU+ZDmaRwPzYxiF X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/myrs.c:1061:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/myrs.c:1089:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/myrs.c:1193:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/myrs.c:1306:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/myrs.c:1316:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/myrs.c:1391:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/myrs.c:1401:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/myrs.c:1411:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/myrs.c:1421:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/myrs.c:1491:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/myrs.c:942:9-17: WARNING: please use sysfs_emit No functional change intended CC: Hannes Reinecke CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/myrs.c | 56 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c index a1eec65a9713..deafe5904055 100644 --- a/drivers/scsi/myrs.c +++ b/drivers/scsi/myrs.c @@ -939,7 +939,7 @@ static ssize_t raid_state_show(struct device *dev, int ret; if (!sdev->hostdata) - return snprintf(buf, 16, "Unknown\n"); + return sysfs_emit(buf, "Unknown\n"); if (sdev->channel >= cs->ctlr_info->physchan_present) { struct myrs_ldev_info *ldev_info = sdev->hostdata; @@ -947,10 +947,10 @@ static ssize_t raid_state_show(struct device *dev, name = myrs_devstate_name(ldev_info->dev_state); if (name) - ret = snprintf(buf, 32, "%s\n", name); + ret = sysfs_emit(buf, "%s\n", name); else - ret = snprintf(buf, 32, "Invalid (%02X)\n", - ldev_info->dev_state); + ret = sysfs_emit(buf, "Invalid (%02X)\n", + ldev_info->dev_state); } else { struct myrs_pdev_info *pdev_info; const char *name; @@ -958,10 +958,10 @@ static ssize_t raid_state_show(struct device *dev, pdev_info = sdev->hostdata; name = myrs_devstate_name(pdev_info->dev_state); if (name) - ret = snprintf(buf, 32, "%s\n", name); + ret = sysfs_emit(buf, "%s\n", name); else - ret = snprintf(buf, 32, "Invalid (%02X)\n", - pdev_info->dev_state); + ret = sysfs_emit(buf, "Invalid (%02X)\n", + pdev_info->dev_state); } return ret; } @@ -1058,7 +1058,7 @@ static ssize_t raid_level_show(struct device *dev, const char *name = NULL; if (!sdev->hostdata) - return snprintf(buf, 16, "Unknown\n"); + return sysfs_emit(buf, "Unknown\n"); if (sdev->channel >= cs->ctlr_info->physchan_present) { struct myrs_ldev_info *ldev_info; @@ -1066,13 +1066,13 @@ static ssize_t raid_level_show(struct device *dev, ldev_info = sdev->hostdata; name = myrs_raid_level_name(ldev_info->raid_level); if (!name) - return snprintf(buf, 32, "Invalid (%02X)\n", + return sysfs_emit(buf, "Invalid (%02X)\n", ldev_info->dev_state); } else name = myrs_raid_level_name(MYRS_RAID_PHYSICAL); - return snprintf(buf, 32, "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } static DEVICE_ATTR_RO(raid_level); @@ -1086,7 +1086,7 @@ static ssize_t rebuild_show(struct device *dev, unsigned char status; if (sdev->channel < cs->ctlr_info->physchan_present) - return snprintf(buf, 32, "physical device - not rebuilding\n"); + return sysfs_emit(buf, "physical device - not rebuilding\n"); ldev_info = sdev->hostdata; ldev_num = ldev_info->ldev_num; @@ -1098,11 +1098,11 @@ static ssize_t rebuild_show(struct device *dev, return -EIO; } if (ldev_info->rbld_active) { - return snprintf(buf, 32, "rebuilding block %zu of %zu\n", + return sysfs_emit(buf, "rebuilding block %zu of %zu\n", (size_t)ldev_info->rbld_lba, (size_t)ldev_info->cfg_devsize); } else - return snprintf(buf, 32, "not rebuilding\n"); + return sysfs_emit(buf, "not rebuilding\n"); } static ssize_t rebuild_store(struct device *dev, @@ -1190,7 +1190,7 @@ static ssize_t consistency_check_show(struct device *dev, unsigned short ldev_num; if (sdev->channel < cs->ctlr_info->physchan_present) - return snprintf(buf, 32, "physical device - not checking\n"); + return sysfs_emit(buf, "physical device - not checking\n"); ldev_info = sdev->hostdata; if (!ldev_info) @@ -1198,11 +1198,11 @@ static ssize_t consistency_check_show(struct device *dev, ldev_num = ldev_info->ldev_num; myrs_get_ldev_info(cs, ldev_num, ldev_info); if (ldev_info->cc_active) - return snprintf(buf, 32, "checking block %zu of %zu\n", - (size_t)ldev_info->cc_lba, - (size_t)ldev_info->cfg_devsize); + return sysfs_emit(buf, "checking block %zu of %zu\n", + (size_t)ldev_info->cc_lba, + (size_t)ldev_info->cfg_devsize); else - return snprintf(buf, 32, "not checking\n"); + return sysfs_emit(buf, "not checking\n"); } static ssize_t consistency_check_store(struct device *dev, @@ -1303,7 +1303,7 @@ static ssize_t serial_show(struct device *dev, memcpy(serial, cs->ctlr_info->serial_number, 16); serial[16] = '\0'; - return snprintf(buf, 16, "%s\n", serial); + return sysfs_emit(buf, "%s\n", serial); } static DEVICE_ATTR_RO(serial); @@ -1313,7 +1313,7 @@ static ssize_t ctlr_num_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrs_hba *cs = shost_priv(shost); - return snprintf(buf, 20, "%d\n", cs->host->host_no); + return sysfs_emit(buf, "%d\n", cs->host->host_no); } static DEVICE_ATTR_RO(ctlr_num); @@ -1388,7 +1388,7 @@ static ssize_t model_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrs_hba *cs = shost_priv(shost); - return snprintf(buf, 28, "%s\n", cs->model_name); + return sysfs_emit(buf, "%s\n", cs->model_name); } static DEVICE_ATTR_RO(model); @@ -1398,7 +1398,7 @@ static ssize_t ctlr_type_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrs_hba *cs = shost_priv(shost); - return snprintf(buf, 4, "%d\n", cs->ctlr_info->ctlr_type); + return sysfs_emit(buf, "%d\n", cs->ctlr_info->ctlr_type); } static DEVICE_ATTR_RO(ctlr_type); @@ -1408,7 +1408,7 @@ static ssize_t cache_size_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrs_hba *cs = shost_priv(shost); - return snprintf(buf, 8, "%d MB\n", cs->ctlr_info->cache_size_mb); + return sysfs_emit(buf, "%d MB\n", cs->ctlr_info->cache_size_mb); } static DEVICE_ATTR_RO(cache_size); @@ -1418,10 +1418,10 @@ static ssize_t firmware_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrs_hba *cs = shost_priv(shost); - return snprintf(buf, 16, "%d.%02d-%02d\n", - cs->ctlr_info->fw_major_version, - cs->ctlr_info->fw_minor_version, - cs->ctlr_info->fw_turn_number); + return sysfs_emit(buf, "%d.%02d-%02d\n", + cs->ctlr_info->fw_major_version, + cs->ctlr_info->fw_minor_version, + cs->ctlr_info->fw_turn_number); } static DEVICE_ATTR_RO(firmware); @@ -1488,7 +1488,7 @@ static ssize_t disable_enclosure_messages_show(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); struct myrs_hba *cs = shost_priv(shost); - return snprintf(buf, 3, "%d\n", cs->disable_enc_msg); + return sysfs_emit(buf, "%d\n", cs->disable_enc_msg); } static ssize_t disable_enclosure_messages_store(struct device *dev, From patchwork Tue Jan 16 04:51:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520451 Received: from esa5.hc1455-7.c3s2.iphmx.com (esa5.hc1455-7.c3s2.iphmx.com [68.232.139.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 669A3200BC; Tue, 16 Jan 2024 04:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="145721304" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="145721304" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa5.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:28 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 5F9FBD9D90; Tue, 16 Jan 2024 13:52:25 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 97D1BD9492; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 212C4200A571F; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id C15131A015F; Tue, 16 Jan 2024 12:52:23 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 32/42] drivers/scsi/ncr53c8xx: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:41 +0800 Message-Id: <20240116045151.3940401-30-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--9.120000-10.000000 X-TMASE-MatchedRID: 1RpOuHOu+mY4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4dL4Vi2vvkbTrMZ+BqQt2NrBOVz0Jwcxl6vCrG0TnfVUaUX s6FguVy28ZKYBueeZDc4WYLmQfXYmFZzhICPDv1yeAiCmPx4NwGmRqNBHmBveVDC1CbuJXmMqtq 5d3cxkNY9VbVgm9IO59mE0PeVaHLPK39FaN6Eu6SqFe9kV+KuoBaLd3oQPofY= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/ncr53c8xx.c:8034:8-16: WARNING: please use sysfs_emit No functional change intended CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/ncr53c8xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index 35869b4f9329..2bd74620caf5 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -8031,7 +8031,7 @@ static ssize_t show_ncr53c8xx_revision(struct device *dev, struct Scsi_Host *host = class_to_shost(dev); struct host_data *host_data = (struct host_data *)host->hostdata; - return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id); + return sysfs_emit(buf, "0x%x\n", host_data->ncb->revision_id); } static struct device_attribute ncr53c8xx_revision_attr = { From patchwork Tue Jan 16 04:51:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520428 Received: from esa7.hc1455-7.c3s2.iphmx.com (esa7.hc1455-7.c3s2.iphmx.com [139.138.61.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA5A71947C; Tue, 16 Jan 2024 04:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="125018782" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="125018782" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:27 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id C7512E8BF5; Tue, 16 Jan 2024 13:52:25 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id F346CD948C; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 8870E200A7687; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 1C5441A0070; Tue, 16 Jan 2024 12:52:24 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , "James E.J. Bottomley" , linux-scsi@vger.kernel.org Subject: [PATCH 33/42] drivers/scsi/pcmcia/sym53c500_cs: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:42 +0800 Message-Id: <20240116045151.3940401-31-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--5.340000-10.000000 X-TMASE-MatchedRID: CncXHiplHCc4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4TBF7stuNMMxTuctSpiuWyUUi4Ehat0546MQi364g884JmV 7j1WQqodAYdLFXr37PhAISLmT6dDEHxPMjOKY7A/+HHE8LDNSg8RB0bsfrpPIfiAqrjYtFiQ67M DzwA1xIzCSmoDF4fl0mz1os8fbBNeZBJZQJRLtsX7cGd19dSFd X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/pcmcia/sym53c500_cs.c:627:8-16: WARNING: please use sysfs_emit No functional change intended CC: "James E.J. Bottomley" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/pcmcia/sym53c500_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 278c78d066c4..264eeb24b811 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -624,7 +624,7 @@ SYM53C500_show_pio(struct device *dev, struct device_attribute *attr, struct sym53c500_data *data = (struct sym53c500_data *)SHp->hostdata; - return snprintf(buf, 4, "%d\n", data->fast_pio); + return sysfs_emit(buf, "%d\n", data->fast_pio); } static ssize_t From patchwork Tue Jan 16 04:51:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520441 Received: from esa12.hc1455-7.c3s2.iphmx.com (esa12.hc1455-7.c3s2.iphmx.com [139.138.37.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75D591CFBC; Tue, 16 Jan 2024 04:52:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="125556497" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="125556497" Received: from unknown (HELO oym-r3.gw.nic.fujitsu.com) ([210.162.30.91]) by esa12.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:28 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id 25237D64AA; Tue, 16 Jan 2024 13:52:26 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 460BDBF3FC; Tue, 16 Jan 2024 13:52:25 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id D3095200A7689; Tue, 16 Jan 2024 13:52:24 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 6466F1A0160; Tue, 16 Jan 2024 12:52:24 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Jack Wang , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 34/42] drivers/scsi/pm8001: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:43 +0800 Message-Id: <20240116045151.3940401-32-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--10.666000-10.000000 X-TMASE-MatchedRID: 6SYb29c3rTQ4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4YtkWgmtdunMLdBFrfY9r2n0swHSFcVJ6MC5DTEMxpeQfiq 1gj2xET8vYRhsicUjm796jCH+PpSbpoPHQXywp1fOvXpg7ONnXX0tCKdnhB58I/9UW5M5dRNp7q EhmmPgy46HM5rqDwqtNBJJYdcA4cyfPD3h/iqauXlHsWGeGzKnLiZ8odpWEsdzUPiHs71J0g== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/pm8001/pm8001_ctl.c:883:8-16: WARNING: please use sysfs_emit No functional change intended CC: Jack Wang CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian Acked-by: Jack Wang --- drivers/scsi/pm8001/pm8001_ctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index 5c26a13ffbd2..7b27618fd7b2 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c @@ -880,9 +880,9 @@ static ssize_t pm8001_show_update_fw(struct device *cdev, if (pm8001_ha->fw_status != FLASH_IN_PROGRESS) pm8001_ha->fw_status = FLASH_OK; - return snprintf(buf, PAGE_SIZE, "status=%x %s\n", - flash_error_table[i].err_code, - flash_error_table[i].reason); + return sysfs_emit(buf, "status=%x %s\n", + flash_error_table[i].err_code, + flash_error_table[i].reason); } static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP, pm8001_show_update_fw, pm8001_store_update_fw); From patchwork Tue Jan 16 04:51:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520431 Received: from esa7.hc1455-7.c3s2.iphmx.com (esa7.hc1455-7.c3s2.iphmx.com [139.138.61.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E119E1BDC9; Tue, 16 Jan 2024 04:52:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="125018784" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="125018784" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:28 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 4514CD9D8F; Tue, 16 Jan 2024 13:52:26 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 6D9A8D948C; Tue, 16 Jan 2024 13:52:25 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 091EA20098E39; Tue, 16 Jan 2024 13:52:25 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id B32651A0070; Tue, 16 Jan 2024 12:52:24 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 35/42] drivers/scsi/pmcraid: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:44 +0800 Message-Id: <20240116045151.3940401-33-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--16.750200-10.000000 X-TMASE-MatchedRID: st9CF01730Y4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4dL4Vi2vvkbTrMZ+BqQt2NrBOVz0Jwcxl6vCrG0TnfVU2d8 mtRIRsUOh6RR0CtnXgaI1Q85Nw6wpfDPEC/yQgPTfSQNpZkETVAv/9UzFeXIT0y9hkRwHPXFiY4 PRl594rWe0jURB2B0R42Q73ENE9hUfE8yM4pjsD2odc419PBJCxEHRux+uk8jpP8tMOyYmaA== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/pmcraid.c:3541:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/pmcraid.c:3602:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/pmcraid.c:3635:8-16: WARNING: please use sysfs_emit No functional change intended CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/pmcraid.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index e8bcc3a88732..eb8973ac4cc7 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c @@ -3538,7 +3538,7 @@ static ssize_t pmcraid_show_log_level( struct Scsi_Host *shost = class_to_shost(dev); struct pmcraid_instance *pinstance = (struct pmcraid_instance *)shost->hostdata; - return snprintf(buf, PAGE_SIZE, "%d\n", pinstance->current_log_level); + return sysfs_emit(buf, "%d\n", pinstance->current_log_level); } /** @@ -3599,8 +3599,7 @@ static ssize_t pmcraid_show_drv_version( char *buf ) { - return snprintf(buf, PAGE_SIZE, "version: %s\n", - PMCRAID_DRIVER_VERSION); + return sysfs_emit(buf, "version: %s\n", PMCRAID_DRIVER_VERSION); } static struct device_attribute pmcraid_driver_version_attr = { @@ -3632,9 +3631,9 @@ static ssize_t pmcraid_show_adapter_id( u32 adapter_id = pci_dev_id(pinstance->pdev); u32 aen_group = pmcraid_event_family.id; - return snprintf(buf, PAGE_SIZE, - "adapter id: %d\nminor: %d\naen group: %d\n", - adapter_id, MINOR(pinstance->cdev.dev), aen_group); + return sysfs_emit(buf, + "adapter id: %d\nminor: %d\naen group: %d\n", + adapter_id, MINOR(pinstance->cdev.dev), aen_group); } static struct device_attribute pmcraid_adapter_id_attr = { From patchwork Tue Jan 16 04:51:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520429 Received: from esa4.hc1455-7.c3s2.iphmx.com (esa4.hc1455-7.c3s2.iphmx.com [68.232.139.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 084DC1B7FC; Tue, 16 Jan 2024 04:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="146510869" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="146510869" Received: from unknown (HELO oym-r4.gw.nic.fujitsu.com) ([210.162.30.92]) by esa4.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:28 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id D0DE87FB66; Tue, 16 Jan 2024 13:52:26 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 081F7BF3E1; Tue, 16 Jan 2024 13:52:26 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 7F33B200A56FC; Tue, 16 Jan 2024 13:52:25 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 0530C1A015F; Tue, 16 Jan 2024 12:52:24 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Nilesh Javali , Manish Rangankar , GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 36/42] drivers/scsi/qla4xxx/ql4_attr: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:45 +0800 Message-Id: <20240116045151.3940401-34-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--14.075100-10.000000 X-TMASE-MatchedRID: HXSqh3WYKfsvKBNTYKG+pZiHtCNYjckMjkDrBOJwwnQ8JmmJxjOaQclB Lll1g/6SBNyCmIook0dM0AWQBBcXdpRSkbxKeJc4LdBFrfY9r2n0swHSFcVJ6MC5DTEMxpeQfiq 1gj2xET/gr0WZ6u+ypUc+YfLo55UjzYigC8AbwLKzRPQ8T4oe5VQtFGrTSjaZL4WYASdGqxQWFL 7w0dNaotqe5K9KUB7DmchPT8ZI4U8S3A6nxKn4s1Z85UImhNtaCoPXqoZQJeYbEPEAbwfCVqPFj JEFr+olwXCBO/GKkVqOhzOa6g8KrUBY6QPiLuukXoB1ZdXOXl3vW/J18GqmbRRvN/nhGtPBz8wi CTvoGIg= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/qla4xxx/ql4_attr.c:159:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:173:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:181:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:190:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:200:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:210:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:223:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:235:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:247:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:256:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:264:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:273:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:281:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:303:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/qla4xxx/ql4_attr.c:312:8-16: WARNING: please use sysfs_emit No functional change intended CC: Nilesh Javali CC: Manish Rangankar CC: GR-QLogic-Storage-Upstream@marvell.com CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/qla4xxx/ql4_attr.c | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/qla4xxx/ql4_attr.c b/drivers/scsi/qla4xxx/ql4_attr.c index abfa6ef60480..8d2ff36338c0 100644 --- a/drivers/scsi/qla4xxx/ql4_attr.c +++ b/drivers/scsi/qla4xxx/ql4_attr.c @@ -156,13 +156,13 @@ qla4xxx_fw_version_show(struct device *dev, struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); if (is_qla80XX(ha)) - return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n", - ha->fw_info.fw_major, ha->fw_info.fw_minor, - ha->fw_info.fw_patch, ha->fw_info.fw_build); + return sysfs_emit(buf, "%d.%02d.%02d (%x)\n", + ha->fw_info.fw_major, ha->fw_info.fw_minor, + ha->fw_info.fw_patch, ha->fw_info.fw_build); else - return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n", - ha->fw_info.fw_major, ha->fw_info.fw_minor, - ha->fw_info.fw_patch, ha->fw_info.fw_build); + return sysfs_emit(buf, "%d.%02d.%02d.%02d\n", + ha->fw_info.fw_major, ha->fw_info.fw_minor, + ha->fw_info.fw_patch, ha->fw_info.fw_build); } static ssize_t @@ -170,7 +170,7 @@ qla4xxx_serial_num_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%s\n", ha->serial_number); + return sysfs_emit(buf, "%s\n", ha->serial_number); } static ssize_t @@ -178,8 +178,8 @@ qla4xxx_iscsi_version_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fw_info.iscsi_major, - ha->fw_info.iscsi_minor); + return sysfs_emit(buf, "%d.%02d\n", ha->fw_info.iscsi_major, + ha->fw_info.iscsi_minor); } static ssize_t @@ -187,7 +187,7 @@ qla4xxx_optrom_version_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d.%02d\n", + return sysfs_emit(buf, "%d.%02d.%02d.%02d\n", ha->fw_info.bootload_major, ha->fw_info.bootload_minor, ha->fw_info.bootload_patch, ha->fw_info.bootload_build); } @@ -197,7 +197,7 @@ qla4xxx_board_id_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "0x%08X\n", ha->board_id); + return sysfs_emit(buf, "0x%08X\n", ha->board_id); } static ssize_t @@ -207,8 +207,8 @@ qla4xxx_fw_state_show(struct device *dev, struct device_attribute *attr, struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); qla4xxx_get_firmware_state(ha); - return snprintf(buf, PAGE_SIZE, "0x%08X%8X\n", ha->firmware_state, - ha->addl_fw_state); + return sysfs_emit(buf, "0x%08X%8X\n", ha->firmware_state, + ha->addl_fw_state); } static ssize_t @@ -220,7 +220,7 @@ qla4xxx_phy_port_cnt_show(struct device *dev, struct device_attribute *attr, if (is_qla40XX(ha)) return -ENOSYS; - return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_cnt); + return sysfs_emit(buf, "0x%04X\n", ha->phy_port_cnt); } static ssize_t @@ -232,7 +232,7 @@ qla4xxx_phy_port_num_show(struct device *dev, struct device_attribute *attr, if (is_qla40XX(ha)) return -ENOSYS; - return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_num); + return sysfs_emit(buf, "0x%04X\n", ha->phy_port_num); } static ssize_t @@ -244,7 +244,7 @@ qla4xxx_iscsi_func_cnt_show(struct device *dev, struct device_attribute *attr, if (is_qla40XX(ha)) return -ENOSYS; - return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->iscsi_pci_func_cnt); + return sysfs_emit(buf, "0x%04X\n", ha->iscsi_pci_func_cnt); } static ssize_t @@ -253,7 +253,7 @@ qla4xxx_hba_model_show(struct device *dev, struct device_attribute *attr, { struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_name); + return sysfs_emit(buf, "%s\n", ha->model_name); } static ssize_t @@ -261,8 +261,8 @@ qla4xxx_fw_timestamp_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%s %s\n", ha->fw_info.fw_build_date, - ha->fw_info.fw_build_time); + return sysfs_emit(buf, "%s %s\n", ha->fw_info.fw_build_date, + ha->fw_info.fw_build_time); } static ssize_t @@ -270,7 +270,7 @@ qla4xxx_fw_build_user_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%s\n", ha->fw_info.fw_build_user); + return sysfs_emit(buf, "%s\n", ha->fw_info.fw_build_user); } static ssize_t @@ -278,7 +278,7 @@ qla4xxx_fw_ext_timestamp_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%s\n", ha->fw_info.extended_timestamp); + return sysfs_emit(buf, "%s\n", ha->fw_info.extended_timestamp); } static ssize_t @@ -300,7 +300,7 @@ qla4xxx_fw_load_src_show(struct device *dev, struct device_attribute *attr, break; } - return snprintf(buf, PAGE_SIZE, "%s\n", load_src); + return sysfs_emit(buf, "%s\n", load_src); } static ssize_t @@ -309,8 +309,8 @@ qla4xxx_fw_uptime_show(struct device *dev, struct device_attribute *attr, { struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev)); qla4xxx_about_firmware(ha); - return snprintf(buf, PAGE_SIZE, "%u.%u secs\n", ha->fw_uptime_secs, - ha->fw_uptime_msecs); + return sysfs_emit(buf, "%u.%u secs\n", ha->fw_uptime_secs, + ha->fw_uptime_msecs); } static DEVICE_ATTR(fw_version, S_IRUGO, qla4xxx_fw_version_show, NULL); From patchwork Tue Jan 16 04:51:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520448 Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7BE51E882; Tue, 16 Jan 2024 04:52:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="146236512" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="146236512" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:29 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 07564CD6C9; Tue, 16 Jan 2024 13:52:27 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 3D19CD3F0C; Tue, 16 Jan 2024 13:52:26 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id ADDC920098E39; Tue, 16 Jan 2024 13:52:25 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 6383C1A0070; Tue, 16 Jan 2024 12:52:25 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 37/42] drivers/scsi/scsi_sysfs: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:46 +0800 Message-Id: <20240116045151.3940401-35-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--15.188200-10.000000 X-TMASE-MatchedRID: e6WPXQD7Ri84ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4dL4Vi2vvkbTrMZ+BqQt2NrBOVz0Jwcxl6vCrG0TnfVUg9x e4gtUJtpqw4mhfH/CjyHVzwndHHhl/625ZdmTyUizRPQ8T4oe5Rgff28UuvITd3XtjqAaoMLndM EZZ6ppQ4E14EZ4ciLbm11lBSAav6kfE8yM4pjsDwtuKBGekqUpI/NGWt0UYPCv86Cgtufh8rUcX rQaDbBd7I2Y/HHWTXGIPKgr0MF740Ib4fU9zdME X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/scsi_sysfs.c:1112:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:1202:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:231:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:277:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:327:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:385:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:402:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:680:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:689:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:701:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:722:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:858:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:873:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:953:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_sysfs.c:979:8-16: WARNING: please use sysfs_emit No functional change intended CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/scsi_sysfs.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 24f6eefb6803..e82dc010fea0 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -228,7 +228,7 @@ show_shost_state(struct device *dev, struct device_attribute *attr, char *buf) if (!name) return -EINVAL; - return snprintf(buf, 20, "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } /* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */ @@ -274,7 +274,7 @@ show_shost_active_mode(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); if (shost->active_mode == MODE_UNKNOWN) - return snprintf(buf, 20, "unknown\n"); + return sysfs_emit(buf, "unknown\n"); else return show_shost_mode(shost->active_mode, buf); } @@ -324,7 +324,7 @@ show_shost_eh_deadline(struct device *dev, struct Scsi_Host *shost = class_to_shost(dev); if (shost->eh_deadline == -1) - return snprintf(buf, strlen("off") + 2, "off\n"); + return sysfs_emit(buf, "off\n"); return sprintf(buf, "%u\n", shost->eh_deadline / HZ); } @@ -382,7 +382,7 @@ static ssize_t show_host_busy(struct device *dev, struct device_attribute *attr, char *buf) { struct Scsi_Host *shost = class_to_shost(dev); - return snprintf(buf, 20, "%d\n", scsi_host_busy(shost)); + return sysfs_emit(buf, "%d\n", scsi_host_busy(shost)); } static DEVICE_ATTR(host_busy, S_IRUGO, show_host_busy, NULL); @@ -399,7 +399,7 @@ show_nr_hw_queues(struct device *dev, struct device_attribute *attr, char *buf) struct Scsi_Host *shost = class_to_shost(dev); struct blk_mq_tag_set *tag_set = &shost->tag_set; - return snprintf(buf, 20, "%d\n", tag_set->nr_hw_queues); + return sysfs_emit(buf, "%d\n", tag_set->nr_hw_queues); } static DEVICE_ATTR(nr_hw_queues, S_IRUGO, show_nr_hw_queues, NULL); @@ -677,7 +677,7 @@ sdev_show_device_busy(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_device *sdev = to_scsi_device(dev); - return snprintf(buf, 20, "%d\n", scsi_device_busy(sdev)); + return sysfs_emit(buf, "%d\n", scsi_device_busy(sdev)); } static DEVICE_ATTR(device_busy, S_IRUGO, sdev_show_device_busy, NULL); @@ -686,7 +686,7 @@ sdev_show_device_blocked(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_device *sdev = to_scsi_device(dev); - return snprintf(buf, 20, "%d\n", atomic_read(&sdev->device_blocked)); + return sysfs_emit(buf, "%d\n", atomic_read(&sdev->device_blocked)); } static DEVICE_ATTR(device_blocked, S_IRUGO, sdev_show_device_blocked, NULL); @@ -698,7 +698,7 @@ sdev_show_timeout (struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_device *sdev; sdev = to_scsi_device(dev); - return snprintf(buf, 20, "%d\n", sdev->request_queue->rq_timeout / HZ); + return sysfs_emit(buf, "%d\n", sdev->request_queue->rq_timeout / HZ); } static ssize_t @@ -719,7 +719,7 @@ sdev_show_eh_timeout(struct device *dev, struct device_attribute *attr, char *bu { struct scsi_device *sdev; sdev = to_scsi_device(dev); - return snprintf(buf, 20, "%u\n", sdev->eh_timeout / HZ); + return sysfs_emit(buf, "%u\n", sdev->eh_timeout / HZ); } static ssize_t @@ -855,7 +855,7 @@ show_state_field(struct device *dev, struct device_attribute *attr, char *buf) if (!name) return -EINVAL; - return snprintf(buf, 20, "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field, store_state_field); @@ -870,7 +870,7 @@ show_queue_type_field(struct device *dev, struct device_attribute *attr, if (sdev->simple_tags) name = "simple"; - return snprintf(buf, 20, "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } static ssize_t @@ -950,7 +950,7 @@ static ssize_t show_iostat_counterbits(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8); + return sysfs_emit(buf, "%d\n", (int)sizeof(atomic_t) * 8); } static DEVICE_ATTR(iocounterbits, S_IRUGO, show_iostat_counterbits, NULL); @@ -976,7 +976,7 @@ sdev_show_modalias(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_device *sdev; sdev = to_scsi_device(dev); - return snprintf (buf, 20, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type); + return sysfs_emit(buf, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type); } static DEVICE_ATTR(modalias, S_IRUGO, sdev_show_modalias, NULL); @@ -1109,9 +1109,9 @@ sdev_show_dh_state(struct device *dev, struct device_attribute *attr, struct scsi_device *sdev = to_scsi_device(dev); if (!sdev->handler) - return snprintf(buf, 20, "detached\n"); + return sysfs_emit(buf, "detached\n"); - return snprintf(buf, 20, "%s\n", sdev->handler->name); + return sysfs_emit(buf, "%s\n", sdev->handler->name); } static ssize_t @@ -1199,8 +1199,8 @@ sdev_show_queue_ramp_up_period(struct device *dev, { struct scsi_device *sdev; sdev = to_scsi_device(dev); - return snprintf(buf, 20, "%u\n", - jiffies_to_msecs(sdev->queue_ramp_up_period)); + return sysfs_emit(buf, "%u\n", + jiffies_to_msecs(sdev->queue_ramp_up_period)); } static ssize_t From patchwork Tue Jan 16 04:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520437 Received: from esa8.hc1455-7.c3s2.iphmx.com (esa8.hc1455-7.c3s2.iphmx.com [139.138.61.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 920341BC4C; Tue, 16 Jan 2024 04:52:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="134244467" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="134244467" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa8.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:29 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 506E3E8BF5; Tue, 16 Jan 2024 13:52:27 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 8723CBF3FF; Tue, 16 Jan 2024 13:52:26 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 1C54E200A56FC; Tue, 16 Jan 2024 13:52:26 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id A8FBC1A0160; Tue, 16 Jan 2024 12:52:25 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 38/42] drivers/scsi/scsi_transport_fc: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:47 +0800 Message-Id: <20240116045151.3940401-36-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--14.163000-10.000000 X-TMASE-MatchedRID: st9CF01730Y4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckMWl hj9iHeVpaAKUUskFh7lM0AWQBBcXdpRSkbxKeJc4LdBFrfY9r2n0swHSFcVJ6MC5DTEMxpeQfiq 1gj2xET8vYRhsicUjm84WYLmQfXYmFZzhICPDv1x7wqPa+cm9aflSepWcgdLPx8BJ7uScK205Q+ 5OtQJCFZ4W5X99NcSot+ix2ebieZ2XBXaJoB9JZxRFJJyf5BJe3QfwsVk0UbtuRXh7bFKB7ulHD smna5gFayom1eEUsbjd0Un7L1Xkx+Kqq72Zh9LCPpCuffGH9zI= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/scsi_transport_fc.c:1123:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_transport_fc.c:1218:10-18: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_transport_fc.c:1286:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_transport_fc.c:1304:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_transport_fc.c:1665:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_transport_fc.c:1891:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_transport_fc.c:1915:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_transport_fc.c:1967:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_transport_fc.c:2000:8-16: WARNING: please use sysfs_emit No functional change intended CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/scsi_transport_fc.c | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index b04075f19445..3335c31772e1 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -1120,7 +1120,7 @@ show_fc_rport_supported_classes (struct device *dev, { struct fc_rport *rport = transport_class_to_rport(dev); if (rport->supported_classes == FC_COS_UNSPECIFIED) - return snprintf(buf, 20, "unspecified\n"); + return sysfs_emit(buf, "unspecified\n"); return get_fc_cos_names(rport->supported_classes, buf); } static FC_DEVICE_ATTR(rport, supported_classes, S_IRUGO, @@ -1215,21 +1215,21 @@ show_fc_rport_roles (struct device *dev, struct device_attribute *attr, FC_WELLKNOWN_PORTID_MASK) { switch (rport->port_id & FC_WELLKNOWN_ROLE_MASK) { case FC_FPORT_PORTID: - return snprintf(buf, 30, "Fabric Port\n"); + return sysfs_emit(buf, "Fabric Port\n"); case FC_FABCTLR_PORTID: - return snprintf(buf, 30, "Fabric Controller\n"); + return sysfs_emit(buf, "Fabric Controller\n"); case FC_DIRSRVR_PORTID: - return snprintf(buf, 30, "Directory Server\n"); + return sysfs_emit(buf, "Directory Server\n"); case FC_TIMESRVR_PORTID: - return snprintf(buf, 30, "Time Server\n"); + return sysfs_emit(buf, "Time Server\n"); case FC_MGMTSRVR_PORTID: - return snprintf(buf, 30, "Management Server\n"); + return sysfs_emit(buf, "Management Server\n"); default: - return snprintf(buf, 30, "Unknown Fabric Entity\n"); + return sysfs_emit(buf, "Unknown Fabric Entity\n"); } } else { if (rport->roles == FC_PORT_ROLE_UNKNOWN) - return snprintf(buf, 20, "unknown\n"); + return sysfs_emit(buf, "unknown\n"); return get_fc_port_roles_names(rport->roles, buf); } } @@ -1283,7 +1283,7 @@ show_fc_rport_port_state(struct device *dev, if (!name) return -EINVAL; - return snprintf(buf, 20, "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } static FC_DEVICE_ATTR(rport, port_state, 0444 | 0200, @@ -1301,8 +1301,8 @@ show_fc_rport_fast_io_fail_tmo (struct device *dev, struct fc_rport *rport = transport_class_to_rport(dev); if (rport->fast_io_fail_tmo == -1) - return snprintf(buf, 5, "off\n"); - return snprintf(buf, 20, "%d\n", rport->fast_io_fail_tmo); + return sysfs_emit(buf, "off\n"); + return sysfs_emit(buf, "%d\n", rport->fast_io_fail_tmo); } static ssize_t @@ -1662,7 +1662,7 @@ show_fc_vport_roles (struct device *dev, struct device_attribute *attr, struct fc_vport *vport = transport_class_to_vport(dev); if (vport->roles == FC_PORT_ROLE_UNKNOWN) - return snprintf(buf, 20, "unknown\n"); + return sysfs_emit(buf, "unknown\n"); return get_fc_port_roles_names(vport->roles, buf); } static FC_DEVICE_ATTR(vport, roles, S_IRUGO, show_fc_vport_roles, NULL); @@ -1888,7 +1888,7 @@ show_fc_host_supported_classes (struct device *dev, struct Scsi_Host *shost = transport_class_to_shost(dev); if (fc_host_supported_classes(shost) == FC_COS_UNSPECIFIED) - return snprintf(buf, 20, "unspecified\n"); + return sysfs_emit(buf, "unspecified\n"); return get_fc_cos_names(fc_host_supported_classes(shost), buf); } @@ -1912,7 +1912,7 @@ show_fc_host_supported_speeds (struct device *dev, struct Scsi_Host *shost = transport_class_to_shost(dev); if (fc_host_supported_speeds(shost) == FC_PORTSPEED_UNKNOWN) - return snprintf(buf, 20, "unknown\n"); + return sysfs_emit(buf, "unknown\n"); return get_fc_port_speed_names(fc_host_supported_speeds(shost), buf); } @@ -1964,7 +1964,7 @@ show_fc_host_speed (struct device *dev, i->f->get_host_speed(shost); if (fc_host_speed(shost) == FC_PORTSPEED_UNKNOWN) - return snprintf(buf, 20, "unknown\n"); + return sysfs_emit(buf, "unknown\n"); return get_fc_port_speed_names(fc_host_speed(shost), buf); } @@ -1997,7 +1997,7 @@ show_fc_private_host_tgtid_bind_type(struct device *dev, name = get_fc_tgtid_bind_type_name(fc_host_tgtid_bind_type(shost)); if (!name) return -EINVAL; - return snprintf(buf, FC_BINDTYPE_MAX_NAMELEN, "%s\n", name); + return sysfs_emit(buf, "%s\n", name); } #define get_list_head_entry(pos, head, member) \ @@ -2106,7 +2106,7 @@ fc_stat_show(const struct device *dev, char *buf, unsigned long offset) if (i->f->get_fc_host_stats) { stats = (i->f->get_fc_host_stats)(shost); if (stats) - ret = snprintf(buf, 20, "0x%llx\n", + ret = sysfs_emit(buf, "0x%llx\n", (unsigned long long)*(u64 *)(((u8 *) stats) + offset)); } return ret; From patchwork Tue Jan 16 04:51:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520433 Received: from esa7.hc1455-7.c3s2.iphmx.com (esa7.hc1455-7.c3s2.iphmx.com [139.138.61.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 625AB1BDEC; Tue, 16 Jan 2024 04:52:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="125018789" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="125018789" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:29 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id A7B63CD6C9; Tue, 16 Jan 2024 13:52:27 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id D9AA4E399F; Tue, 16 Jan 2024 13:52:26 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 662DA200A571F; Tue, 16 Jan 2024 13:52:26 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id EFEB91A015F; Tue, 16 Jan 2024 12:52:25 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 39/42] drivers/scsi/scsi_transport_sas: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:48 +0800 Message-Id: <20240116045151.3940401-37-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--13.295400-10.000000 X-TMASE-MatchedRID: i5zBIT546Mc4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckMWl hj9iHeVpaAKUUskFh7lM0AWQBBcXdpRSkbxKeJc4LdBFrfY9r2n0swHSFcVJ6MC5DTEMxpeQfiq 1gj2xET8vYRhsicUjm84WYLmQfXYmFZzhICPDv1zG+nS24MzHeYLsLasl5ROhGxDxAG8HwlajxY yRBa/qJcFwgTvxipFajoczmuoPCq0jBQdKBu5x0pM1psEbuF0oCH/EL7jOrLmY5A5H1uU0A5WO1 L73K6pf X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/scsi_transport_sas.c:1180:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_transport_sas.c:525:9-17: WARNING: please use sysfs_emit > ./drivers/scsi/scsi_transport_sas.c:572:8-16: WARNING: please use sysfs_emit No functional change intended CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/scsi_transport_sas.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index d704c484a251..f679034e1048 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c @@ -427,7 +427,7 @@ show_sas_phy_##name(struct device *dev, \ { \ struct sas_phy *phy = transport_class_to_phy(dev); \ \ - return snprintf(buf, 20, format_string, cast phy->field); \ + return sysfs_emit(buf, format_string, cast phy->field); \ } #define sas_phy_simple_attr(field, name, format_string, type) \ @@ -442,7 +442,7 @@ show_sas_phy_##name(struct device *dev, \ struct sas_phy *phy = transport_class_to_phy(dev); \ \ if (!phy->field) \ - return snprintf(buf, 20, "none\n"); \ + return sysfs_emit(buf, "none\n"); \ return get_sas_protocol_names(phy->field, buf); \ } @@ -507,7 +507,7 @@ show_sas_phy_##field(struct device *dev, \ error = i->f->get_linkerrors ? i->f->get_linkerrors(phy) : 0; \ if (error) \ return error; \ - return snprintf(buf, 20, "%u\n", phy->field); \ + return sysfs_emit(buf, "%u\n", phy->field); \ } #define sas_phy_linkerror_attr(field) \ @@ -522,7 +522,7 @@ show_sas_device_type(struct device *dev, struct sas_phy *phy = transport_class_to_phy(dev); if (!phy->identify.device_type) - return snprintf(buf, 20, "none\n"); + return sysfs_emit(buf, "none\n"); return get_sas_device_type_names(phy->identify.device_type, buf); } static DEVICE_ATTR(device_type, S_IRUGO, show_sas_device_type, NULL); @@ -569,7 +569,7 @@ show_sas_phy_enable(struct device *dev, struct device_attribute *attr, { struct sas_phy *phy = transport_class_to_phy(dev); - return snprintf(buf, 20, "%d\n", phy->enabled); + return sysfs_emit(buf, "%d\n", phy->enabled); } static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, show_sas_phy_enable, @@ -798,7 +798,7 @@ show_sas_port_##name(struct device *dev, \ { \ struct sas_port *port = transport_class_to_sas_port(dev); \ \ - return snprintf(buf, 20, format_string, cast port->field); \ + return sysfs_emit(buf, format_string, cast port->field); \ } #define sas_port_simple_attr(field, name, format_string, type) \ @@ -1145,7 +1145,7 @@ show_sas_rphy_##name(struct device *dev, \ { \ struct sas_rphy *rphy = transport_class_to_rphy(dev); \ \ - return snprintf(buf, 20, format_string, cast rphy->field); \ + return sysfs_emit(buf, format_string, cast rphy->field); \ } #define sas_rphy_simple_attr(field, name, format_string, type) \ @@ -1161,7 +1161,7 @@ show_sas_rphy_##name(struct device *dev, \ struct sas_rphy *rphy = transport_class_to_rphy(dev); \ \ if (!rphy->field) \ - return snprintf(buf, 20, "none\n"); \ + return sysfs_emit(buf, "none\n"); \ return get_sas_protocol_names(rphy->field, buf); \ } @@ -1177,7 +1177,7 @@ show_sas_rphy_device_type(struct device *dev, struct sas_rphy *rphy = transport_class_to_rphy(dev); if (!rphy->identify.device_type) - return snprintf(buf, 20, "none\n"); + return sysfs_emit(buf, "none\n"); return get_sas_device_type_names( rphy->identify.device_type, buf); } @@ -1280,7 +1280,7 @@ show_sas_end_dev_##name(struct device *dev, \ struct sas_rphy *rphy = transport_class_to_rphy(dev); \ struct sas_end_device *rdev = rphy_to_end_device(rphy); \ \ - return snprintf(buf, 20, format_string, cast rdev->field); \ + return sysfs_emit(buf, format_string, cast rdev->field); \ } #define sas_end_dev_simple_attr(field, name, format_string, type) \ @@ -1309,7 +1309,7 @@ show_sas_expander_##name(struct device *dev, \ struct sas_rphy *rphy = transport_class_to_rphy(dev); \ struct sas_expander_device *edev = rphy_to_expander_device(rphy); \ \ - return snprintf(buf, 20, format_string, cast edev->field); \ + return sysfs_emit(buf, format_string, cast edev->field); \ } #define sas_expander_simple_attr(field, name, format_string, type) \ From patchwork Tue Jan 16 04:51:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhijian Li (Fujitsu)" X-Patchwork-Id: 13520438 Received: from esa8.hc1455-7.c3s2.iphmx.com (esa8.hc1455-7.c3s2.iphmx.com [139.138.61.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2DB31C695; Tue, 16 Jan 2024 04:52:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="134244468" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="134244468" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa8.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:30 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id EAB19D5027; Tue, 16 Jan 2024 13:52:27 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 35BDAD3F0C; Tue, 16 Jan 2024 13:52:27 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id B84E0200A7685; Tue, 16 Jan 2024 13:52:26 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 41B171A0070; Tue, 16 Jan 2024 12:52:26 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Cc: Li Zhijian , Karan Tilak Kumar , Sesidhar Baddela , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 40/42] drivers/scsi/snic/snic_attrs: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:49 +0800 Message-Id: <20240116045151.3940401-38-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.004 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.004 X-TMASE-Result: 10--15.843000-10.000000 X-TMASE-MatchedRID: i5zBIT546Mc4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4QjYlErXRAnoLdBFrfY9r2n0swHSFcVJ6MC5DTEMxpeQfiq 1gj2xET8vYRhsicUjm84WYLmQfXYmFZzhICPDv1zfSQNpZkETVAv/9UzFeXITGxDxAG8HwlajxY yRBa/qJcFwgTvxipFajoczmuoPCq3jsutR+QmP0N8aX0oz9KYehB2W+CYlDhFtqNG73mqQ0w521 VKzZ7kU X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/scsi/snic/snic_attrs.c:16:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/snic/snic_attrs.c:26:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/snic/snic_attrs.c:35:8-16: WARNING: please use sysfs_emit > ./drivers/scsi/snic/snic_attrs.c:48:8-16: WARNING: please use sysfs_emit No functional change intended CC: Karan Tilak Kumar CC: Sesidhar Baddela CC: "James E.J. Bottomley" CC: "Martin K. Petersen" CC: linux-scsi@vger.kernel.org Signed-off-by: Li Zhijian --- drivers/scsi/snic/snic_attrs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/snic/snic_attrs.c b/drivers/scsi/snic/snic_attrs.c index 3ddbdbc3ded1..03921618182d 100644 --- a/drivers/scsi/snic/snic_attrs.c +++ b/drivers/scsi/snic/snic_attrs.c @@ -13,7 +13,7 @@ snic_show_sym_name(struct device *dev, { struct snic *snic = shost_priv(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%s\n", snic->name); + return sysfs_emit(buf, "%s\n", snic->name); } static ssize_t @@ -23,7 +23,7 @@ snic_show_state(struct device *dev, { struct snic *snic = shost_priv(class_to_shost(dev)); - return snprintf(buf, PAGE_SIZE, "%s\n", + return sysfs_emit(buf, "%s\n", snic_state_str[snic_get_state(snic)]); } @@ -32,7 +32,7 @@ snic_show_drv_version(struct device *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "%s\n", SNIC_DRV_VERSION); + return sysfs_emit(buf, "%s\n", SNIC_DRV_VERSION); } static ssize_t @@ -45,8 +45,8 @@ snic_show_link_state(struct device *dev, if (snic->config.xpt_type == SNIC_DAS) snic->link_status = svnic_dev_link_status(snic->vdev); - return snprintf(buf, PAGE_SIZE, "%s\n", - (snic->link_status) ? "Link Up" : "Link Down"); + return sysfs_emit(buf, "%s\n", + (snic->link_status) ? "Link Up" : "Link Down"); } static DEVICE_ATTR(snic_sym_name, S_IRUGO, snic_show_sym_name, NULL);