From patchwork Thu Dec 8 07:45:17 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: 31194 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp60920wrr; Wed, 7 Dec 2022 23:59:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf6PNOz6Ct56W0m54BvUPtr5VM++3WaNUwpRUESRbOOE7WZx0xwHmUbrR+sj5F+58r2cUHat X-Received: by 2002:a17:906:14d0:b0:7c0:a356:b41b with SMTP id y16-20020a17090614d000b007c0a356b41bmr27669006ejc.158.1670486351850; Wed, 07 Dec 2022 23:59:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670486351; cv=none; d=google.com; s=arc-20160816; b=LMLEUJC7PUTLNjsVTN3wekddtcM57LjZqoddozzCzGqbAjwy2DYZC7Fn/sBlSho70w SocD0wA0hztyQ4+1DjuOvQpBrecqyQ3ScsvEuYUBTXzr87eSMDB2Pq00J5OXE5zkkqOz NAGlJrVMEMT4w6wv7N90EjQfMjc/QSlh7iXenwrLx/JQM2Ykn/Aj/b3VyHIcbycuXEEB QbClsFsvHJaOqn6s71G5XGuQa0W2Ple/EMY59uVKjKQHKOJBl2GT/tkGbAtiFINQFhyh RmFCHX0Lf4YNmA8zkgTo7H8oHpnuUhMN4MNPrm/cQRe4pZzORqNH+JpS1HYHwxVR+PIr sWUg== 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=7yYm77l9kvhUs1gZNrRNgX7kk3tg2lVrG7cX9x2+/a0=; b=gTdNzeNMleZes2em7sQfKSD/ziLNLnBLsOU15dkJt3zv6bPxFmN2AHPaKoVoj8Wzmr ztP1w069qJJILtmrzzdx+fqUWXlz1ey9KHFYIn/GzHEfpWikMYbT/WFqSqG0o3X5onHm gSnWnXRu6h0/l7az9xhWeyGTyG+qx7u51G6xqx1/Av2+v2CFEUo4Fo8no66YV7l/UpyG /rcBOqAFhuy7mRtY8+3+IcpuAgPvEk515Pr6eOpaePLgmG1RlkIvF/PQdMByNOIkpRUU RYhAj9FzPvR+559GdAdw0NoOjd1QEzxSG+OjjV+NNaHGMZlT0jpnGY1hKhCVradlWDme 3rbw== 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 dz11-20020a0564021d4b00b0046c2a42d72asi7426171edb.404.2022.12.07.23.58.42; Wed, 07 Dec 2022 23:59:11 -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 S229746AbiLHHpm (ORCPT + 99 others); Thu, 8 Dec 2022 02:45:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbiLHHpk (ORCPT ); Thu, 8 Dec 2022 02:45:40 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B23EF08; Wed, 7 Dec 2022 23:45:39 -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 4NSR5d2CGCz8R039; Thu, 8 Dec 2022 15:45:25 +0800 (CST) Received: from xaxapp03.zte.com.cn ([10.88.40.52]) by mse-fl1.zte.com.cn with SMTP id 2B87jFIJ078346; Thu, 8 Dec 2022 15:45:15 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Thu, 8 Dec 2022 15:45:17 +0800 (CST) Date: Thu, 8 Dec 2022 15:45:17 +0800 (CST) X-Zmail-TransId: 2af96391960dffffffffc6c081d8 X-Mailer: Zmail v1.0 Message-ID: <202212081545178689771@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , Subject: =?utf-8?q?=5BPATCH=5D_platform/x86=3A_sony-laptop=3A_Convert_to_use?= =?utf-8?q?_sysfs=5Femit=5Fat=28=29_API?= X-MAIL: mse-fl1.zte.com.cn 2B87jFIJ078346 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 63919615.000 by FangMail milter! X-FangMail-Envelope: 1670485525/4NSR5d2CGCz8R039/63919615.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63919615.000/4NSR5d2CGCz8R039 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?1751631896417305684?= X-GMAIL-MSGID: =?utf-8?q?1751631896417305684?= 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/platform/x86/sony-laptop.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index a19aac70252f..7156ae2ad196 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c @@ -820,10 +820,9 @@ static ssize_t sony_nc_handles_show(struct device *dev, int i; for (i = 0; i < ARRAY_SIZE(handles->cap); i++) { - len += scnprintf(buffer + len, PAGE_SIZE - len, "0x%.4x ", - handles->cap[i]); + len += sysfs_emit_at(buffer, len, "0x%.4x ", handles->cap[i]); } - len += scnprintf(buffer + len, PAGE_SIZE - len, "\n"); + len += sysfs_emit_at(buffer, len, "\n"); return len; } @@ -2173,10 +2172,9 @@ static ssize_t sony_nc_thermal_profiles_show(struct device *dev, for (cnt = 0; cnt < THM_PROFILE_MAX; cnt++) { if (!cnt || (th_handle->profiles & cnt)) - idx += scnprintf(buffer + idx, PAGE_SIZE - idx, "%s ", - snc_thermal_profiles[cnt]); + idx += sysfs_emit_at(buffer, idx, "%s ", snc_thermal_profiles[cnt]); } - idx += scnprintf(buffer + idx, PAGE_SIZE - idx, "\n"); + idx += sysfs_emit_at(buffer, idx, "\n"); return idx; }