From patchwork Thu Mar 14 08:46:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 1930898 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=JJNBY2fz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VVrBF6kdDz1ymc for ; Fri, 3 May 2024 09:44:21 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=JJNBY2fz; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4VVrBF5KPRz3bbW for ; Fri, 3 May 2024 09:44:21 +1000 (AEST) X-Original-To: linux-fsi@lists.ozlabs.org Delivered-To: linux-fsi@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fujitsu.com header.i=@fujitsu.com header.a=rsa-sha256 header.s=fj2 header.b=JJNBY2fz; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=fujitsu.com (client-ip=207.54.90.49; helo=esa3.hc1455-7.c3s2.iphmx.com; envelope-from=lizhijian@fujitsu.com; receiver=lists.ozlabs.org) X-Greylist: delayed 65 seconds by postgrey-1.37 at boromir; Thu, 14 Mar 2024 19:48:20 AEDT 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 lists.ozlabs.org (Postfix) with ESMTPS id 4TwLd03k40z3vZP for ; Thu, 14 Mar 2024 19:48:20 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1710406102; x=1741942102; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=MMdcS9PHTtB1A8gshHcCMqjx6OfA/c8Jji6swSg/N6A=; b=JJNBY2fzrPkIqY3Cy01eD7/4rz+FEZxHbebNyT5xCuj315//KjWhMODv 4/GmLQw5P0il+mdKZy7L/CruZPpojlfHpy8LcO/n/xscTGoKBqoADZ1X6 RqxexA5VuOJn852YJqNNhMHr55DJgLrLGqrCHHv631NlAh24CcT7MpEu3 zpmqbgo3E7JtZ5CrNYqs3IV7qiscZ2e8RlLTCUl8CSANNOUVhJEhT/Xv6 7CLe+WKzi58Ibp4dLyizULTeK7LukkuGKaqmBsouqMgLu7pVJkAWj/dB9 Xa7WMKhKQiH9BnwHqtVPw12jzSvUnzN8wXIjuoWYIGUP9192PfY5wZHmB w==; X-IronPort-AV: E=McAfee;i="6600,9927,11012"; a="152234699" X-IronPort-AV: E=Sophos;i="6.07,124,1708354800"; d="scan'208";a="152234699" Received: from unknown (HELO yto-r3.gw.nic.fujitsu.com) ([218.44.52.219]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 17:47:10 +0900 Received: from yto-m1.gw.nic.fujitsu.com (yto-nat-yto-m1.gw.nic.fujitsu.com [192.168.83.64]) by yto-r3.gw.nic.fujitsu.com (Postfix) with ESMTP id EC09AE95FA for ; Thu, 14 Mar 2024 17:47:06 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 3476142617 for ; Thu, 14 Mar 2024 17:47:06 +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 A925B6B4C1 for ; Thu, 14 Mar 2024 17:47:05 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id BDBAC1A006B; Thu, 14 Mar 2024 16:47:04 +0800 (CST) From: Li Zhijian To: linux-kernel@vger.kernel.org Subject: [PATCH v2] fsi: Convert sprintf/snprintf to sysfs_emit Date: Thu, 14 Mar 2024 16:46:56 +0800 Message-Id: <20240314084656.1322057-1-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28250.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28250.006 X-TMASE-Result: 10--4.735400-10.000000 X-TMASE-MatchedRID: st9CF01730Y4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfDqO6/8R69QE8U roFNOGp7a6aAZTOwtJmRloiW1Kgftd2ZdKe8BPbS7pujb8urdzZBHuVYxc8DW3hh5KUdlgWiKqF q1hn3Eb3d+/nM3Koh0iaTw03n/wYO38rWKQkiws65x7uAXGEprcE5XPQnBzGXq8KsbROd9VSArq oIZrVn15fzUkBpc072hKK/bK+QypCR9GF2J2xqMxRFJJyf5BJe3QfwsVk0UbvqwGfCk7KUs2S0w 8rP2t3p6smvKwXUmDz24c33NcG6BmA5T/19m4CaVsKKNygcOcFJrCNy7ijKN7mf1qldocYB+Opf yvCj64ILkzL/P/0IKyHJp2UYVccqxOB8J0pRLhyJxKSZiwBX6QtRTXOqKmFVftwZ3X11IV0= X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Mailman-Approved-At: Fri, 03 May 2024 09:44:12 +1000 X-BeenThere: linux-fsi@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistar Popple , Li Zhijian , linux-fsi@lists.ozlabs.org Errors-To: linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "linux-fsi" 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(). sprintf() will be converted as weel if they have. Generally, this patch is generated by make coccicheck M= MODE=patch \ COCCI=scripts/coccinelle/api/device_attr_show.cocci No functional change intended CC: Jeremy Kerr CC: Joel Stanley CC: Alistar Popple CC: Eddie James CC: linux-fsi@lists.ozlabs.org Reviewed-by: Eddie James Signed-off-by: Li Zhijian --- This is a part of the work "Fix coccicheck device_attr_show warnings"[1] Split them per subsystem so that the maintainer can review it easily [1] https://lore.kernel.org/lkml/20240116041129.3937800-1-lizhijian@fujitsu.com/ --- drivers/fsi/fsi-master-ast-cf.c | 4 ++-- drivers/fsi/fsi-master-gpio.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c index 812dfa9a9140..c6a5c38c206f 100644 --- a/drivers/fsi/fsi-master-ast-cf.c +++ b/drivers/fsi/fsi-master-ast-cf.c @@ -1083,8 +1083,8 @@ static ssize_t external_mode_show(struct device *dev, { struct fsi_master_acf *master = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE - 1, "%u\n", - master->external_mode ? 1 : 0); + return sysfs_emit(buf, "%u\n", + master->external_mode ? 1 : 0); } static ssize_t external_mode_store(struct device *dev, diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c index ed03da4f2447..13710b4f2f86 100644 --- a/drivers/fsi/fsi-master-gpio.c +++ b/drivers/fsi/fsi-master-gpio.c @@ -718,8 +718,8 @@ static ssize_t external_mode_show(struct device *dev, { struct fsi_master_gpio *master = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE - 1, "%u\n", - master->external_mode ? 1 : 0); + return sysfs_emit(buf, "%u\n", + master->external_mode ? 1 : 0); } static ssize_t external_mode_store(struct device *dev,