From patchwork Fri Dec 2 09:21:54 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: 28814 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp732747wrr; Fri, 2 Dec 2022 01:26:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Qd58CO8BZXinpf0sitk22y1qzyXqFOE5LPosEfV5ky0j7jg+f4G0ZuN2TowwPZ5kDW4YQ X-Received: by 2002:a17:90a:788b:b0:218:24fc:c6b6 with SMTP id x11-20020a17090a788b00b0021824fcc6b6mr76069904pjk.127.1669973203032; Fri, 02 Dec 2022 01:26:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669973203; cv=none; d=google.com; s=arc-20160816; b=hNX8q8O7SRlwSX5OhReboAvz/WlkYfnV/EeCy9Hbnh1/r9JN5j0z+4RARuvOuEOxtV PLy0PzWKg+I2ihRU7pmI0sXOElhZR5wNIn6ue9b+9AnGs5xpL4cCcTU+xK7OHFoB/inV ON0ykdkfD44o3rXdEr5NmpLiHU6dW1sVzcYOWIzrY+23huAP5uJXgSLz6DLQhk4X9qy4 qwri5P8GBPecAi7TonTemKWqssUQE8OXwf6Xufvmqj7bsEUDUkwUM5JrvsD8OR48A4LO OiRC591fMsU/GdP7HGW6nHZQwiW9pGb3Kkt6P5cY34aHpLgp3Voko/u/ltbXyDGep/8m yL3Q== 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=ldaXH5KhbWN/jxJK/2k0xoTW5VlmBhD0YCc0PKWzbsc=; b=TvK0oyBeU71OndCkSwdF8DXP4AFVSSbOf8/o5bmikOHb7hi9ElYEPi8hhcHK4NgZrU XdKpdP9dcZyQPrn7a2+9Fj/OHyp2cUQD5O6+iSLhBfPdM1/NC0bc0A3jjpe5CYA2Sy3/ 1KNMYgKamWHSL0btIpn2aE/EQteesv0DC3/d8GVhloQ8MK2PrhfstEOGxGBjtBQNOXL3 8sRwwiCLRrGmUiG6ORyGPz7p5y0F7c9yXXbIMORqeTVnXlPeZ6N+pzlfPCI4yqtjT32N 1iWNH8a7VfI42hrqFr07n5HLpT9C/Mvh8IJy57jjlNmBiJM4JUmCIgf1zZ9fax0L59He gNrQ== 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 x18-20020a17090a8a9200b00218906bfbcbsi7138491pjn.172.2022.12.02.01.26.29; Fri, 02 Dec 2022 01:26: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 S232769AbiLBJXn (ORCPT + 99 others); Fri, 2 Dec 2022 04:23:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233054AbiLBJXV (ORCPT ); Fri, 2 Dec 2022 04:23:21 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70E57C7D29; Fri, 2 Dec 2022 01:22:09 -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 4NNnWz5v70z8RTZL; Fri, 2 Dec 2022 17:22:07 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl2.zte.com.cn with SMTP id 2B29LqdK063118; Fri, 2 Dec 2022 17:21:52 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Fri, 2 Dec 2022 17:21:54 +0800 (CST) Date: Fri, 2 Dec 2022 17:21:54 +0800 (CST) X-Zmail-TransId: 2af96389c3b25295ad21 X-Mailer: Zmail v1.0 Message-ID: <202212021721543696124@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , Subject: =?utf-8?q?=5BPATCH=5D_platform/x86=3A_dell=3A_use_sysfs=5Femit=28?= =?utf-8?q?=29_to_instead_of=C2=A0scnprintf=28=29?= X-MAIL: mse-fl2.zte.com.cn 2B29LqdK063118 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 6389C3BF.002 by FangMail milter! X-FangMail-Envelope: 1669972927/4NNnWz5v70z8RTZL/6389C3BF.002/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6389C3BF.002/4NNnWz5v70z8RTZL 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?1751093821603131135?= X-GMAIL-MSGID: =?utf-8?q?1751093821603131135?= 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/dell/alienware-wmi.c | 41 +++++++++-------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c index a34e07ef2c79..a9477e5432e4 100644 --- a/drivers/platform/x86/dell/alienware-wmi.c +++ b/drivers/platform/x86/dell/alienware-wmi.c @@ -398,10 +398,10 @@ static ssize_t show_control_state(struct device *dev, struct device_attribute *attr, char *buf) { if (lighting_control_state == LEGACY_BOOTING) - return scnprintf(buf, PAGE_SIZE, "[booting] running suspend\n"); + return sysfs_emit(buf, "[booting] running suspend\n"); else if (lighting_control_state == LEGACY_SUSPEND) - return scnprintf(buf, PAGE_SIZE, "booting running [suspend]\n"); - return scnprintf(buf, PAGE_SIZE, "booting [running] suspend\n"); + return sysfs_emit(buf, "booting running [suspend]\n"); + return sysfs_emit(buf, "booting [running] suspend\n"); } static ssize_t store_control_state(struct device *dev, @@ -547,14 +547,12 @@ static ssize_t show_hdmi_cable(struct device *dev, (u32 *) &out_data); if (ACPI_SUCCESS(status)) { if (out_data == 0) - return scnprintf(buf, PAGE_SIZE, - "[unconnected] connected unknown\n"); + return sysfs_emit(buf, "[unconnected] connected unknown\n"); else if (out_data == 1) - return scnprintf(buf, PAGE_SIZE, - "unconnected [connected] unknown\n"); + return sysfs_emit(buf, "unconnected [connected] unknown\n"); } pr_err("alienware-wmi: unknown HDMI cable status: %d\n", status); - return scnprintf(buf, PAGE_SIZE, "unconnected connected [unknown]\n"); + return sysfs_emit(buf, "unconnected connected [unknown]\n"); } static ssize_t show_hdmi_source(struct device *dev, @@ -571,14 +569,12 @@ static ssize_t show_hdmi_source(struct device *dev, if (ACPI_SUCCESS(status)) { if (out_data == 1) - return scnprintf(buf, PAGE_SIZE, - "[input] gpu unknown\n"); + return sysfs_emit(buf, "[input] gpu unknown\n"); else if (out_data == 2) - return scnprintf(buf, PAGE_SIZE, - "input [gpu] unknown\n"); + return sysfs_emit(buf, "input [gpu] unknown\n"); } pr_err("alienware-wmi: unknown HDMI source status: %u\n", status); - return scnprintf(buf, PAGE_SIZE, "input gpu [unknown]\n"); + return sysfs_emit(buf, "input gpu [unknown]\n"); } static ssize_t toggle_hdmi_source(struct device *dev, @@ -652,14 +648,12 @@ static ssize_t show_amplifier_status(struct device *dev, (u32 *) &out_data); if (ACPI_SUCCESS(status)) { if (out_data == 0) - return scnprintf(buf, PAGE_SIZE, - "[unconnected] connected unknown\n"); + return sysfs_emit(buf, "[unconnected] connected unknown\n"); else if (out_data == 1) - return scnprintf(buf, PAGE_SIZE, - "unconnected [connected] unknown\n"); + return sysfs_emit(buf, "unconnected [connected] unknown\n"); } pr_err("alienware-wmi: unknown amplifier cable status: %d\n", status); - return scnprintf(buf, PAGE_SIZE, "unconnected connected [unknown]\n"); + return sysfs_emit(buf, "unconnected connected [unknown]\n"); } static DEVICE_ATTR(status, S_IRUGO, show_amplifier_status, NULL); @@ -706,17 +700,14 @@ static ssize_t show_deepsleep_status(struct device *dev, (u32 *) &out_data); if (ACPI_SUCCESS(status)) { if (out_data == 0) - return scnprintf(buf, PAGE_SIZE, - "[disabled] s5 s5_s4\n"); + return sysfs_emit(buf, "[disabled] s5 s5_s4\n"); else if (out_data == 1) - return scnprintf(buf, PAGE_SIZE, - "disabled [s5] s5_s4\n"); + return sysfs_emit(buf, "disabled [s5] s5_s4\n"); else if (out_data == 2) - return scnprintf(buf, PAGE_SIZE, - "disabled s5 [s5_s4]\n"); + return sysfs_emit(buf, "disabled s5 [s5_s4]\n"); } pr_err("alienware-wmi: unknown deep sleep status: %d\n", status); - return scnprintf(buf, PAGE_SIZE, "disabled s5 s5_s4 [unknown]\n"); + return sysfs_emit(buf, "disabled s5 s5_s4 [unknown]\n"); } static ssize_t toggle_deepsleep(struct device *dev,