From patchwork Wed Dec 7 02:04:38 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: 30599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3163071wrr; Tue, 6 Dec 2022 18:08:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf6iPzNTZ1s0+3XxjU/Gh2KykJJjaPFygtGcdCNDnjI4kjcBKk0FSS0RO0Knr6AJKeBTbG5z X-Received: by 2002:a05:6402:548a:b0:468:e8e2:31c9 with SMTP id fg10-20020a056402548a00b00468e8e231c9mr13969677edb.310.1670378915570; Tue, 06 Dec 2022 18:08:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670378915; cv=none; d=google.com; s=arc-20160816; b=cwUdVYSyjsV1XhQhTlv7e2xUgNmN4Y/IDwxiLm5Dr7fmXdmHJMmWakP8A4CU31laB8 tjjNyscYHn81hUSX3ET1DY6/pUMIpWflCLMy7Loufk/iGGQa9z0+TtFgbmBalGCZNlcg i+viv5rYUuiOEBon5gs2X88Pl6kVeXqudWtpU5jiVOlP1tjIatOUGesLSL8NSZe0PpdU v/jTVZ0AuZsDRdSaN1sTDZhsUKM/5IFFZbCkaOX2v+gpS6pKWPMlSakshbReNj7bjY2u j9QvWbzjosYVDVd2J+NwcEnISempIGRANXrk4aTTkW2iduq+EoHQFEHp5S9+6UUQEXaz 8Vlg== 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=dbmFHENazTKG+Pi6SJvJGqRrG+OnhjirhRkph1EtFV0=; b=S85aF4Yg0ZXedIF0eSyfNeiro+BmPYPBPUdnJTcwVX02h6isW9HkBVzSQ7oOHDvGWs +3LJsr+FO1w+VX/3gF5udfVSWU1rWhTGoCUF7htgmxxXek1GeC3DZviUSuh1wZqcwO88 Qqew+xvaGbPnapazO++wdvD+mZP/dOvg/Mf2Q46iIiJZVMdBZz/UbzeNtMXfGiAzBv+S MQ+RnXjehz/7Gibs95IiYR805ukQ5CvKvRCLz9MYcEfyknOKPIkJeCgaIJphh8D9XMGZ xrCQtVgZPA9dHx30QGYvatDamCb+Jc28xZeQ9O8gNl34sMFzWl+YbfE2fZUVVwiOH60y AghQ== 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 i26-20020a1709063c5a00b0078cc4a8a956si2642307ejg.881.2022.12.06.18.08.11; Tue, 06 Dec 2022 18:08:35 -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 S229559AbiLGCEx (ORCPT + 99 others); Tue, 6 Dec 2022 21:04:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbiLGCEv (ORCPT ); Tue, 6 Dec 2022 21:04:51 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD30E45EF5; Tue, 6 Dec 2022 18:04:50 -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 mxhk.zte.com.cn (FangMail) with ESMTPS id 4NRgb53wCQz4xVnZ; Wed, 7 Dec 2022 10:04:49 +0800 (CST) Received: from xaxapp03.zte.com.cn ([10.88.40.52]) by mse-fl2.zte.com.cn with SMTP id 2B724bCU036189; Wed, 7 Dec 2022 10:04:37 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Wed, 7 Dec 2022 10:04:38 +0800 (CST) Date: Wed, 7 Dec 2022 10:04:38 +0800 (CST) X-Zmail-TransId: 2af9638ff4b6fffffffffe10df3e X-Mailer: Zmail v1.0 Message-ID: <202212071004382475676@zte.com.cn> Mime-Version: 1.0 From: To: , Cc: , , , , , Subject: =?utf-8?q?=5BPATCH=5D_iio=3A_mma8452=3A_Convert_to_use_sysfs=5Femit?= =?utf-8?q?=5Fat=28=29_API?= X-MAIL: mse-fl2.zte.com.cn 2B724bCU036189 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 638FF4C1.001 by FangMail milter! X-FangMail-Envelope: 1670378689/4NRgb53wCQz4xVnZ/638FF4C1.001/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638FF4C1.001/4NRgb53wCQz4xVnZ 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?1751519241628899934?= X-GMAIL-MSGID: =?utf-8?q?1751519241628899934?= 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/mma8452.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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';