From patchwork Wed Dec 7 07:51:01 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: 30686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp42644wrr; Tue, 6 Dec 2022 23:56:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf4IMT4fr1WcQnjxTyxXy1E+hsj7XufOvva5x57BNB3H0T2RORQTN9EE1Pcn4hu0g+OYUzWB X-Received: by 2002:a17:906:1593:b0:7c0:8fde:dffb with SMTP id k19-20020a170906159300b007c08fdedffbmr27364151ejd.493.1670399763007; Tue, 06 Dec 2022 23:56:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670399762; cv=none; d=google.com; s=arc-20160816; b=iAQ7Yi+Jp73Qf/8WaV54kuGiA+nzjEF5rRLifPDyPvmjhcpk+8QEOeP6QGqhHaVMGQ 82At9x9Dr+7V1PiM9Th5K4agb5lFU0SJ6BZiPy+/S40lEs0TWiQRPYp0Pd+2krRVm2om H/a6ehqOxaLfMCqIdxDtL7hdwRga/j0vkRnsKD1GHv3tl7XojsUgFMpu8tDtLvwSxatS EXqxOAxzrViNHhRFGny98W7dE5dyf7rc5q3Z3be8neT4fZTgjUoRYNil//BnBXRQdiJU jFp0CQ3pdxcFi6SWvKgPgMBEOXHEG2R7RTm7XDHeIatlujVBovyt2fu5Tqiw8TtrRXxp TDlw== 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=F3xJvwOYhQ/PBJJlAUCOofb2xGtw66dmwiEOHpHrDvk=; b=HkASaow+IHJF/KQno6gwNGzIKEDHO0F5HfBqb0a9VevQRbgJyJ+f4MRdEaC6R7pdG/ kFwNpuhkS6DsJfSZnCdyYB9zGMp6rTPBJXY4znibkUVZK2OFeq4/SFfNne8L1S3Cz3ce ajSoGCt4TYX1XzwlrhWFZU4MjcBDA4lqUwm63cGvK6D/WykuaJMzenbkEUn6EAL1eSk8 tYL40bvSL2z/lSmsixKcflEWLr0V+caQ1nW8LLjXOYgES3f8AKYQE8FXCm4A4QlOBLU5 xvmbtj6ibQJC9/fLjFpzkS7FRxZ6XZllAwSWJF+1GnaKuzMKAwxw5pMycAVPqolu4sSK GT6Q== 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 d8-20020a170906640800b007882936242fsi4226082ejm.769.2022.12.06.23.55.39; Tue, 06 Dec 2022 23:56:02 -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 S229677AbiLGHvZ (ORCPT + 99 others); Wed, 7 Dec 2022 02:51:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbiLGHvP (ORCPT ); Wed, 7 Dec 2022 02:51:15 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C71230554; Tue, 6 Dec 2022 23:51:14 -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 4NRqGm6Y0Qz8R03d; Wed, 7 Dec 2022 15:51:12 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl2.zte.com.cn with SMTP id 2B77oxMU075141; Wed, 7 Dec 2022 15:50:59 +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:51:01 +0800 (CST) Date: Wed, 7 Dec 2022 15:51:01 +0800 (CST) X-Zmail-TransId: 2af9639045e552c97201 X-Mailer: Zmail v1.0 Message-ID: <202212071551017192888@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , Subject: =?utf-8?q?=5BPATCH=5D_iio=3A_magnetometer=3A_hmc5843=3A_Convert_to_?= =?utf-8?q?use_sysfs=5Femit=5Fat=28=29=C2=A0API?= X-MAIL: mse-fl2.zte.com.cn 2B77oxMU075141 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 639045F0.001 by FangMail milter! X-FangMail-Envelope: 1670399472/4NRqGm6Y0Qz8R03d/639045F0.001/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 639045F0.001/4NRqGm6Y0Qz8R03d X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, 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?1751541102151288812?= X-GMAIL-MSGID: =?utf-8?q?1751541102151288812?= 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 Reviewed-by: Andy Shevchenko --- drivers/iio/magnetometer/hmc5843_core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c index c5521d61da29..134f6045e24a 100644 --- a/drivers/iio/magnetometer/hmc5843_core.c +++ b/drivers/iio/magnetometer/hmc5843_core.c @@ -274,9 +274,9 @@ ssize_t hmc5843_show_samp_freq_avail(struct device *dev, int i; for (i = 0; i < data->variant->n_regval_to_samp_freq; i++) - len += scnprintf(buf + len, PAGE_SIZE - len, - "%d.%d ", data->variant->regval_to_samp_freq[i][0], - data->variant->regval_to_samp_freq[i][1]); + len += sysfs_emit_at(buf, len, "%d.%d ", + data->variant->regval_to_samp_freq[i][0], + data->variant->regval_to_samp_freq[i][1]); /* replace trailing space by newline */ buf[len - 1] = '\n'; @@ -335,8 +335,7 @@ static ssize_t hmc5843_show_scale_avail(struct device *dev, int i; for (i = 0; i < data->variant->n_regval_to_nanoscale; i++) - len += scnprintf(buf + len, PAGE_SIZE - len, - "0.%09d ", data->variant->regval_to_nanoscale[i]); + len += sysfs_emit_at(buf, len, "0.%09d ", data->variant->regval_to_nanoscale[i]); /* replace trailing space by newline */ buf[len - 1] = '\n';