From patchwork Wed Dec 7 07:48:09 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: 30682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp41369wrr; Tue, 6 Dec 2022 23:51:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf7XwCqPx4hNAFk9Da+kqpEdR2vHtPZvpy0LEVf5anl4x/Ico1Feh5Z78F2JVada7+7wmXrz X-Received: by 2002:a05:6402:4507:b0:467:205b:723d with SMTP id ez7-20020a056402450700b00467205b723dmr964899edb.69.1670399492189; Tue, 06 Dec 2022 23:51:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670399492; cv=none; d=google.com; s=arc-20160816; b=hu2BwcY3o+ymuL1XUXb3DWoa40ZQe+XOednhFjx93S9NveRa0K5Pxm1mzr6wYeEAR9 WM5p2/FF09jvorKh6APGZ6Qmeb1C+4YjjuQO84TENAM4mot01LT8i4gIFd5+E2cFy1ac qw7eE3OgHNLE5ZCMJz2yehDiY4UrfAcrDhJ7OY10fDSgbJ0zKUhF00PMzWsEdnzWW7Wi 6Xfd9NQMDIk4LxIlExETKYNDNruMq87IXPwIjsTshcuOOtA9Ad5JKIus2aAu1+NOGxOf /CfRe1y1Zb1bBhLCChpBp/xczLrSfbmxKPkCNMBEJRG3e70A9aXrllWBjv1Fg2IlkEou trYA== 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=hqivJ/A4d0mWDxbt/Lu5b3nuWi3VfGqlT3XqGnDX2QU=; b=t5UVW62+kWmULkanoob6gytRxtusplbUnAIf5WyxEa+lhmALPRyQ4oymi+Pq7o+PZ6 jQI8M8Z0euz4wMS0v3IfXOWlOzEDpH5ZpUsXpKbbcBs9I0qONGuHhkrK//dUfkAuDN6n eV/E7K0zWK/Y7r18JlyKOQGgi+N7bsd2oBco9vQCCFF0zJdEIbjm1IgUWM75dGyt6nrJ kvoeiaRO1/6yqTfEW8YRV4Cafo8wKmnvELCd6mf8bAq6ZjHmEMzsk4D3Dg5SHw09rHw/ 17quLp70xvcvKTW29xVmYq7ox1UisDx+Tc6WdqQ+GkaumeUbQjxEbYuCdXunPTNvq/8h mvHg== 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 y8-20020a056402358800b0046d52eaa5b1si1783552edc.120.2022.12.06.23.51.03; Tue, 06 Dec 2022 23:51:32 -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 S229804AbiLGHsY (ORCPT + 99 others); Wed, 7 Dec 2022 02:48:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbiLGHsX (ORCPT ); Wed, 7 Dec 2022 02:48:23 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C66F2F392; Tue, 6 Dec 2022 23:48:22 -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 4NRqCS641zz4xVnj; Wed, 7 Dec 2022 15:48:20 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl2.zte.com.cn with SMTP id 2B77m7jG070980; Wed, 7 Dec 2022 15:48:07 +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:48:09 +0800 (CST) Date: Wed, 7 Dec 2022 15:48:09 +0800 (CST) X-Zmail-TransId: 2af963904539ffffffffebb91b96 X-Mailer: Zmail v1.0 Message-ID: <202212071548094732807@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , Subject: =?utf-8?q?=5BPATCH=5D_iio=3A_light=3A_zopt2201=3A_Convert_to_use_sy?= =?utf-8?q?sfs=5Femit=5Fat=28=29_API?= X-MAIL: mse-fl2.zte.com.cn 2B77m7jG070980 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 63904544.000 by FangMail milter! X-FangMail-Envelope: 1670399300/4NRqCS641zz4xVnj/63904544.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63904544.000/4NRqCS641zz4xVnj 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?1751540817978870032?= X-GMAIL-MSGID: =?utf-8?q?1751540817978870032?= 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/light/zopt2201.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/iio/light/zopt2201.c b/drivers/iio/light/zopt2201.c index e3bac8b56380..97e5412d3a4e 100644 --- a/drivers/iio/light/zopt2201.c +++ b/drivers/iio/light/zopt2201.c @@ -438,8 +438,7 @@ static ssize_t zopt2201_show_int_time_available(struct device *dev, int i; for (i = 0; i < ARRAY_SIZE(zopt2201_resolution); i++) - len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06lu ", - zopt2201_resolution[i].us); + len += sysfs_emit_at(buf, len, "0.%06lu ", zopt2201_resolution[i].us); buf[len - 1] = '\n'; return len; @@ -455,9 +454,9 @@ static ssize_t zopt2201_show_als_scale_avail(struct device *dev, int i; for (i = 0; i < ARRAY_SIZE(zopt2201_scale_als); i++) - len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%06u ", - zopt2201_scale_als[i].scale, - zopt2201_scale_als[i].uscale); + len += sysfs_emit_at(buf, len, "%d.%06u ", + zopt2201_scale_als[i].scale, + zopt2201_scale_als[i].uscale); buf[len - 1] = '\n'; return len; @@ -471,9 +470,9 @@ static ssize_t zopt2201_show_uvb_scale_avail(struct device *dev, int i; for (i = 0; i < ARRAY_SIZE(zopt2201_scale_uvb); i++) - len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%06u ", - zopt2201_scale_uvb[i].scale, - zopt2201_scale_uvb[i].uscale); + len += sysfs_emit_at(buf, len, "%d.%06u ", + zopt2201_scale_uvb[i].scale, + zopt2201_scale_uvb[i].uscale); buf[len - 1] = '\n'; return len;