From patchwork Tue Dec 6 08:15:22 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: 30127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2693347wrr; Tue, 6 Dec 2022 00:16:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Xk8fMKHXzK7imZoFD1VNCXrn1DoV4W8fpjgA5bRutfst+MolK3W14rtuk1YTO55MvnYis X-Received: by 2002:a17:902:a50a:b0:189:dedd:a4f9 with SMTP id s10-20020a170902a50a00b00189dedda4f9mr6323537plq.99.1670314603742; Tue, 06 Dec 2022 00:16:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670314603; cv=none; d=google.com; s=arc-20160816; b=n2UE+wCTCUl9an7L6gwm51DWqRNLSYuWSYBob+QT5Z3HfXTEfNCJSwY5UpXbrk4xhq HTiDUn9lf9/RIDTDJevXPCPG4z7czCM126KdKE+Vy6IXd49UimGVHIq53/6z947B8CgV 5cIc53mU8MgNni3bOS9m0/h3m7ODiV1URTYXjhPFLo0C2pOEaDmRgf+Hpr9C6BdOY4mp D/0fmc7E1na4SRNzLsuFfXOF30sX0tah+ZBp54CjkXialuh5XQKCZlikCC/OPLONPlXL g7qw45AbwV2D2auwqEs6sllSwaNdAx0iQkIOjY+eoaP5DK4bmMih1JXcFEy6mHfr6ZNZ dTNg== 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=qWpzmvLuA8FYFAlDRgZ2Glz5P1MYwvrEFTCKsG2uoto=; b=d7BomrkwNaj+PmaINs00UjOtec2eBwc+pbnfawtT3qHXuAiuyejZw2hn24pDdKQla9 Uh8GoZx3gRhGqqqmRgOMNMfs4aM7F1dnuoH/Tq3Qtk0J6/HyvBMpfofxeJOx4IFtRWf7 Lxk/DGBX1e2kW/UD8fyX2AzTVQ6F0WyyFJ6cSrrZ4JHokTa0oikZtvv/jXe5KtV38Ggn OMQmvbc3P9CDZ8w2X00uV+sz2gHqw14d2kzzLr9+HGwBk0MfYdmlHjoHL04AMKEf+3ee PctSin8ymeRttggisLByykoMpcsKS4S4uXBbo0MZKIy0KS6fEEW65a+ZVNRmMgzgTwGy 4y7A== 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 w184-20020a6382c1000000b00478a51cbfffsi7715309pgd.27.2022.12.06.00.16.30; Tue, 06 Dec 2022 00:16:43 -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 S232037AbiLFIPn (ORCPT + 99 others); Tue, 6 Dec 2022 03:15:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230363AbiLFIPk (ORCPT ); Tue, 6 Dec 2022 03:15:40 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 448D8DF08; Tue, 6 Dec 2022 00:15:38 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (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 4NRCsM5PYCz8RV7D; Tue, 6 Dec 2022 16:15:35 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl1.zte.com.cn with SMTP id 2B68FKto091781; Tue, 6 Dec 2022 16:15:20 +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 16:15:22 +0800 (CST) Date: Tue, 6 Dec 2022 16:15:22 +0800 (CST) X-Zmail-TransId: 2af9638efa1affffffffe3a57249 X-Mailer: Zmail v1.0 Message-ID: <202212061615227896127@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , Subject: =?utf-8?q?=5BPATCH=5D_cpufreq=3A_stats=3A_Convert_to_use_sysfs=5Fem?= =?utf-8?q?it=5Fat=28=29_API?= X-MAIL: mse-fl1.zte.com.cn 2B68FKto091781 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 638EFA27.001 by FangMail milter! X-FangMail-Envelope: 1670314535/4NRCsM5PYCz8RV7D/638EFA27.001/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638EFA27.001/4NRCsM5PYCz8RV7D 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?1751451805828388985?= X-GMAIL-MSGID: =?utf-8?q?1751451805828388985?= 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 Acked-by: Viresh Kumar --- drivers/cpufreq/cpufreq_stats.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 1570d6f3e75d..55c7ffd37d1c 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -128,25 +128,23 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) ssize_t len = 0; int i, j, count; - len += scnprintf(buf + len, PAGE_SIZE - len, " From : To\n"); - len += scnprintf(buf + len, PAGE_SIZE - len, " : "); + len += sysfs_emit_at(buf, len, " From : To\n"); + len += sysfs_emit_at(buf, len, " : "); for (i = 0; i < stats->state_num; i++) { if (len >= PAGE_SIZE) break; - len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ", - stats->freq_table[i]); + len += sysfs_emit_at(buf, len, "%9u ", stats->freq_table[i]); } if (len >= PAGE_SIZE) return PAGE_SIZE; - len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); + len += sysfs_emit_at(buf, len, "\n"); for (i = 0; i < stats->state_num; i++) { if (len >= PAGE_SIZE) break; - len += scnprintf(buf + len, PAGE_SIZE - len, "%9u: ", - stats->freq_table[i]); + len += sysfs_emit_at(buf, len, "%9u: ", stats->freq_table[i]); for (j = 0; j < stats->state_num; j++) { if (len >= PAGE_SIZE) @@ -157,11 +155,11 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) else count = stats->trans_table[i * stats->max_state + j]; - len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ", count); + len += sysfs_emit_at(buf, len, "%9u ", count); } if (len >= PAGE_SIZE) break; - len += scnprintf(buf + len, PAGE_SIZE - len, "\n"); + len += sysfs_emit_at(buf, len, "\n"); } if (len >= PAGE_SIZE) {