From patchwork Tue Dec 6 11:53:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ye.xingchen@zte.com.cn X-Patchwork-Id: 30248 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2774277wrr; Tue, 6 Dec 2022 03:57:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf5qws0HEQhNGuD0jNFcFRp0nn2nzi+4cnSLAfyr9g72ETTENMT0YJoccp/NjN3eJy3hCTYG X-Received: by 2002:a17:90a:2fc8:b0:219:462c:66d2 with SMTP id n8-20020a17090a2fc800b00219462c66d2mr41158652pjm.119.1670327877311; Tue, 06 Dec 2022 03:57:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670327877; cv=none; d=google.com; s=arc-20160816; b=hLuWG1sUOIWLbnTuW1QZEJgVOPv1Jf5b1uYuFME/Mq9+0FJaJ9789xzN739HInez/M NREE2t5o4glgwweoupxG1W5We1ph2mgsugbkCpD5UI2rp1Vt3WbuEgKCDmdGYs2buQgo agZHW+XanqElgezsHl1JrLPzqOd3257GroXvV8wUv0Sbtrpdl/5u391h0jDHS2c5Zhyi QrE3Zu9ohCjvjSsWMJwTgKdKZYrfVwIPc0F2wEXS8CX4KAKvJsgFkZ9MyGB9WPlB90Ha TQWk7yHGZmfJe6Ws0mkhvZgS7DdVJgS1OZOGAcTjJmKQwZbIDlDsKMz076kH9Kpj9tew Fjww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=WtqComdYgarJIGy7bmZZRdmZnXaRM5shfgaNTUPOIoA=; b=sZny+r9TryFeNhDXOlvvSpWYqYKGGDpPGh72DU3vSq3R0IP/6oHwDgi3V9PJsMNAJO m76C2JQnM+x1bNJa+JPKYMWDeGsoQ05DDu67QrPBJs8HKIfUL68pwDSAHdLG5uZJ7ZSh gc6hzIMZJI1AsDzdFNeD1mAq+HZoG+Io+ToEn06u8xaTMKFiZQFrEObDRLPRsePErdUE YqpxTldrqNM2fuq0OrG2G1vu/Z3IQsFJjeUmM2voRhCue4hspJH+08KuTeEftSqY76WM aOokSbM1kn1IDkIVGwXqm7/IgVcLO6ZhH+pPxuyLuKt7CqwPs4q1Qt9SOtZsCwksp2h9 dCyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm9-20020a056a00338900b005752602f950si16169527pfb.208.2022.12.06.03.57.43; Tue, 06 Dec 2022 03:57:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235096AbiLFLxf (ORCPT + 99 others); Tue, 6 Dec 2022 06:53:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233811AbiLFLxc (ORCPT ); Tue, 6 Dec 2022 06:53:32 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4961B21C; Tue, 6 Dec 2022 03:53:31 -0800 (PST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4NRJhn3r8Xz4y0vM; Tue, 6 Dec 2022 19:53:29 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl2.zte.com.cn with SMTP id 2B6BrHVh085625; Tue, 6 Dec 2022 19:53:17 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Tue, 6 Dec 2022 19:53:20 +0800 (CST) Date: Tue, 6 Dec 2022 19:53:20 +0800 (CST) X-Zmail-TransId: 2af9638f2d301b4bd45d X-Mailer: Zmail v1.0 Message-ID: <202212061953201070549@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , , Subject: =?utf-8?q?=5BPATCH=5D_iio=3A_accel=3A_Convert_to_use_sysfs=5Femit?= =?utf-8?q?=5Fat=28=29_API?= X-MAIL: mse-fl2.zte.com.cn 2B6BrHVh085625 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 638F2D39.002 by FangMail milter! X-FangMail-Envelope: 1670327609/4NRJhn3r8Xz4y0vM/638F2D39.002/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638F2D39.002/4NRJhn3r8Xz4y0vM X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751465724171159660?= X-GMAIL-MSGID: =?utf-8?q?1751465724171159660?= From: ye xingchen Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: ye xingchen --- drivers/iio/accel/adxl372.c | 3 +-- drivers/iio/accel/bma180.c | 3 +-- drivers/iio/accel/mma8452.c | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c index c4193286eb05..15bcb0d75b8f 100644 --- a/drivers/iio/accel/adxl372.c +++ b/drivers/iio/accel/adxl372.c @@ -970,8 +970,7 @@ static ssize_t adxl372_show_filter_freq_avail(struct device *dev, size_t len = 0; for (i = 0; i <= st->odr; i++) - len += scnprintf(buf + len, PAGE_SIZE - len, - "%d ", adxl372_bw_freq_tbl[i]); + len += sysfs_emit_at(buf, len, "%d ", adxl372_bw_freq_tbl[i]); buf[len - 1] = '\n'; diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index eb697eeb4301..9e3e5dfdded7 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -488,8 +488,7 @@ static ssize_t bma180_show_avail(char *buf, const int *vals, unsigned int n, for (i = 0; i < n; i++) { if (!vals[i]) continue; - len += scnprintf(buf + len, PAGE_SIZE - len, - micros ? "0.%06d " : "%d ", vals[i]); + len += sysfs_emit_at(buf, len, micros ? "0.%06d " : "%d ", vals[i]); } buf[len - 1] = '\n'; diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index f97fb68e3a71..7ba3c743e6f6 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -266,8 +266,7 @@ static ssize_t mma8452_show_int_plus_micros(char *buf, const int (*vals)[2], size_t len = 0; while (n-- > 0) - len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%06d ", - vals[n][0], vals[n][1]); + len += sysfs_emit_at(buf, len, "%d.%06d ", vals[n][0], vals[n][1]); /* replace trailing space by newline */ buf[len - 1] = '\n'; @@ -423,7 +422,7 @@ static ssize_t mma8452_show_os_ratio_avail(struct device *dev, val = mma8452_os_ratio[j][i]; - len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", val); + len += sysfs_emit_at(buf, len, "%d ", val); } buf[len - 1] = '\n';