From patchwork Wed Dec 7 07:53:55 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: 30690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp43085wrr; Tue, 6 Dec 2022 23:57:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf5hvF3OrlA+J0Zxbc3/MMYqGLpGjGThYLx/S6igEFRZD3xKuReIf0KYxkZe6NFrUAVADrAI X-Received: by 2002:a05:6402:25c5:b0:46c:211:f9b8 with SMTP id x5-20020a05640225c500b0046c0211f9b8mr15833829edb.199.1670399855132; Tue, 06 Dec 2022 23:57:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670399855; cv=none; d=google.com; s=arc-20160816; b=HBZg+EWd05hvTnSOGTQz/EFJTF3slS1L7Pg2pETyF/qKokGeUmHS264Uptb+rZbdsP vZX0VHPbrRkWb+v5zZymiNnBTM4KfmX6zT+spoI8ADcvc0BxnrBGyEbSPCVm3CXAchhD OKvxullh74m7Yxhg+k8pyf9mzw3tAFZvyNRwqkVxQzuqxfvbU95Ebz0P5Hxo5z3LafcQ hOPhM9ObNqmsg7eYhaqw5MHgzX0aNCr9t8MHuCec1XR+vpBLhlitdcNa9q88YDMSxG// iNh5AenMuj4P0btfkOJrTC5v4y/I4v6HEMJrUhscJvwJ5KCHn81Ygmq8tZFbAeYaiYuB XWlA== 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=R0RvBKDtfhUShDxrrnPNTsZtgMuADvX8N8aewEsZsks=; b=dE3dzlj/m5pQj84msMBNAhvMhZyAq/IiIEScsbDHJYvHRePkVdJN4lNATaH5MRu6w3 DZOCJNGJs9DzY1VUT3idvNh9Uzl4L2NdmI81srbNwcmh4ycIdZPWaYMV3EYXCAL8Kh14 BTPxYsnV0b4/g+keuzPc8zkUJVcfhhJXPhvVCYLwPfUnwqwdof2B+efINXdo+XU579bR sEd0crULO5DgHGR9APdf74sPLpPkAroHhu/vCouyK7FnNI+7yZ7KZxENy9VHBoza/J1f 02v6bWpQeYGdJOmvkbhu0wXoHbvhIfRHUC7IaoYPywrBhL6mJSv1D+k0G6SD1E/sqJ6R IShA== 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 sg34-20020a170907a42200b0077156c9124esi11941337ejc.1001.2022.12.06.23.57.12; Tue, 06 Dec 2022 23:57: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 S229717AbiLGHyK (ORCPT + 99 others); Wed, 7 Dec 2022 02:54:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229592AbiLGHyJ (ORCPT ); Wed, 7 Dec 2022 02:54:09 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CA792EF79; Tue, 6 Dec 2022 23:54:08 -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 4NRqL56ytjz4y0v3; Wed, 7 Dec 2022 15:54:05 +0800 (CST) Received: from xaxapp03.zte.com.cn ([10.88.40.52]) by mse-fl2.zte.com.cn with SMTP id 2B77rrUm078208; Wed, 7 Dec 2022 15:53:53 +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 15:53:55 +0800 (CST) Date: Wed, 7 Dec 2022 15:53:55 +0800 (CST) X-Zmail-TransId: 2af96390469377a9d449 X-Mailer: Zmail v1.0 Message-ID: <202212071553556022992@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , Subject: =?utf-8?q?=5BPATCH=5D_iio=3A_st=5Fsensors=3A_Convert_to_use_sysfs?= =?utf-8?q?=5Femit=5Fat=28=29_API?= X-MAIL: mse-fl2.zte.com.cn 2B77rrUm078208 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 6390469D.001 by FangMail milter! X-FangMail-Envelope: 1670399645/4NRqL56ytjz4y0v3/6390469D.001/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6390469D.001/4NRqL56ytjz4y0v3 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?1751541198781879303?= X-GMAIL-MSGID: =?utf-8?q?1751541198781879303?= 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/common/st_sensors/st_sensors_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index c77d7bdcc121..44e374f84197 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -628,8 +628,7 @@ ssize_t st_sensors_sysfs_sampling_frequency_avail(struct device *dev, if (sdata->sensor_settings->odr.odr_avl[i].hz == 0) break; - len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", - sdata->sensor_settings->odr.odr_avl[i].hz); + len += sysfs_emit_at(buf, len, "%d ", sdata->sensor_settings->odr.odr_avl[i].hz); } buf[len - 1] = '\n'; @@ -651,7 +650,7 @@ ssize_t st_sensors_sysfs_scale_avail(struct device *dev, q = sdata->sensor_settings->fs.fs_avl[i].gain / 1000000; r = sdata->sensor_settings->fs.fs_avl[i].gain % 1000000; - len += scnprintf(buf + len, PAGE_SIZE - len, "%u.%06u ", q, r); + len += sysfs_emit_at(buf, len, "%u.%06u ", q, r); } buf[len - 1] = '\n';