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: 188397 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp53413dye; Mon, 15 Jan 2024 21:00:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYf3G/QvJazG6JBc0UEuA6ADAb6NtASN89fm4Nhi28AsNB89UkSXrm6qabhYPHcJu/3o1y X-Received: by 2002:a05:6102:244a:b0:466:f492:9deb with SMTP id g10-20020a056102244a00b00466f4929debmr3696172vss.2.1705381251685; Mon, 15 Jan 2024 21:00:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705381251; cv=none; d=google.com; s=arc-20160816; b=gKWspZJd6LH2bvGwws5018ZA+NP5uwCn29LlfG8xIdvYZm4Ej0cj7iPqtnx6XkRBko 1Hn0qAEZdFlCc3AyaqXmASRcVwx8GZ6ncw1pZQH/gwXdz8jit44mIlxllsxivDTPL/f1 uu99t/niy/1EvLjAQxZjyZWOQKb1bGQSoFLBvZTf7508hQd8IiuibvakDPBr0uFhwJV2 f5xLukscewnQotaKobgoXJlOwwkw9d//r0yFT7p/RkF1l3GBG/KFAb3XFaButxoStVpf l1O5ehZawxGekN/c+o0POQjIIxW8m/vO2shV2Uk6T+jFtj2puzITmFnHsBekjSiuYOOI O99w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=zRNFUBb9resdxdueFiEZHygg2k+8N6cukh2aOJPpw0U=; fh=XAZW/vuP9sKIY0ZKo/kXMzolfDbRUc5Ujw0on5BIlmY=; b=DoBwFoq6VSwUP1nXaC9Fc1ghD6XcmnCgY3A3fXRN+A4/b5iqsn4X4BKuVH54akOtk1 IV9KgCIZ2PUAGYUcxbBtfV6mt+UX19KovilF9D3+d2TddBjzkC4hcZRwAndwHr7BARFG SadMZjVurbLIaBLOF7Eb4ZypC9GzASpe1IKoIFKXfA/7P2v+R8O/XYlLVYuDgejBoscz TWDKyDjAJKumAdHSzO8n6eQkjovqwIbc/6uNj6bpZanYu41jKGOuDUszmGmnL9BSMbH/ tr9zQFrObGADQ89umD5f68xfQr5w++NwQ8S/a/XAF6CEWnUjWY9GmSRIxVXWtName5sF I7/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26985-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26985-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o12-20020a0ccb0c000000b0068172335be6si174641qvk.389.2024.01.15.21.00.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 21:00:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26985-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26985-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26985-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 45A0A1C22B17 for ; Tue, 16 Jan 2024 05:00:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD5421CF94; Tue, 16 Jan 2024 04:52:39 +0000 (UTC) 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-kernel@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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788221851700611451 X-GMAIL-MSGID: 1788221851700611451 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,