From patchwork Fri Dec 2 08:56:04 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: 28797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp724001wrr; Fri, 2 Dec 2022 01:01:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf5cYUjPC7I3itWx9KCkCEgPOYmxAGESGpFlVdVf95klRooZD0kSVQZd/Toa+1WmGQdFmbT+ X-Received: by 2002:a05:6402:1f89:b0:458:caec:8f1e with SMTP id c9-20020a0564021f8900b00458caec8f1emr62442286edc.280.1669971693809; Fri, 02 Dec 2022 01:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669971693; cv=none; d=google.com; s=arc-20160816; b=KgoVpJSVeedUrJ/BkevB77yZ0mX0l7bUY1JiYL6hzlRMd4n3gliOHmcIznJw4SJB0O EliykdB+ya1S5lJU7tYgJEALv/lfyftrLrLofboPD0H79bvptMDQ4NwTyVZvA9jQdhCz +wodjwag7BrAXkG+/VZ8mV3XLBKqAur0PYuOhCCMU2kOm59aZZNccT00+0ruAMaf2E/7 w7/YExc3baEBc2FpvSLvRDrhs6+77dFJXARJ6G8I57o3fkfP9VuAbTObm6v0Nhe/9L2V OTclZ7Wz9bLYR7VYS7FDmH8WSTfa2/6SynGTuAMAPRXt08hMBSyIIYOCUmlHeGrGJKJY Sl5A== 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=y2UA34dUeRKcwRqzsnMUiEZ9aWbacjI3AIVmltTDmW0=; b=NJMYdoKZ402nCun2ZYjb7rm2B9wAuK34GcFK5ew6h68LfSKITgHwntuQxt13Lwt5jk XF6ziSs6W8ZlANErgFFDQBTZqUqBo9mp55E9AtNLi5V33rolJX0gduMJERDek3lhuYmM Zx+1LsvKl8a0iN14IWKO9pWDitK06Tq5AAyAPDWuc1wWhbWPvo/6zXGZNtvplCnUieo0 g82f1clLzjVn6dyUN/It5TCfzX6Q5zCrfMmTPPhfg+TpjhA5v/FHCvz/8KSvwntBdSPf UVVgoKP80ntbhC8P5CxlppLWJT/yi9efjTDUd/ZbVfxAyibHbDFqeWggDA7G5HPVagcq bp9Q== 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 ht17-20020a170907609100b007ae61d89b3esi6504887ejc.356.2022.12.02.01.01.08; Fri, 02 Dec 2022 01:01:33 -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 S232844AbiLBI6a (ORCPT + 99 others); Fri, 2 Dec 2022 03:58:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233030AbiLBI5R (ORCPT ); Fri, 2 Dec 2022 03:57:17 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2E46C4604 for ; Fri, 2 Dec 2022 00:56:16 -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 mxct.zte.com.cn (FangMail) with ESMTPS id 4NNmy71JNcz501Qn; Fri, 2 Dec 2022 16:56:15 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl2.zte.com.cn with SMTP id 2B28u1JC018322; Fri, 2 Dec 2022 16:56:02 +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 16:56:04 +0800 (CST) Date: Fri, 2 Dec 2022 16:56:04 +0800 (CST) X-Zmail-TransId: 2af96389bda4ffffffffd68155a6 X-Mailer: Zmail v1.0 Message-ID: <202212021656040995199@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , Subject: =?utf-8?q?=5BPATCH=5D_platform/chrome=3A_use_sysfs=5Femit=28=29_to_?= =?utf-8?q?instead_of_scnprintf=28=29?= X-MAIL: mse-fl2.zte.com.cn 2B28u1JC018322 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 6389BDAF.000 by FangMail milter! X-FangMail-Envelope: 1669971375/4NNmy71JNcz501Qn/6389BDAF.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6389BDAF.000/4NNmy71JNcz501Qn 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?1751092238956519122?= X-GMAIL-MSGID: =?utf-8?q?1751092238956519122?= 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/chrome/cros_ec_lightbar.c | 14 ++++++-------- drivers/platform/chrome/cros_ec_sysfs.c | 4 ++-- drivers/platform/chrome/wilco_ec/sysfs.c | 3 +-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c index 1674105decfb..376425bbd8ff 100644 --- a/drivers/platform/chrome/cros_ec_lightbar.c +++ b/drivers/platform/chrome/cros_ec_lightbar.c @@ -34,7 +34,7 @@ static ssize_t interval_msec_show(struct device *dev, { unsigned long msec = lb_interval_jiffies * 1000 / HZ; - return scnprintf(buf, PAGE_SIZE, "%lu\n", msec); + return sysfs_emit(buf, "%lu\n", msec); } static ssize_t interval_msec_store(struct device *dev, @@ -169,7 +169,7 @@ static ssize_t version_show(struct device *dev, if (!get_lightbar_version(ec, &version, &flags)) return -EIO; - return scnprintf(buf, PAGE_SIZE, "%d %d\n", version, flags); + return sysfs_emit(buf, "%d %d\n", version, flags); } static ssize_t brightness_store(struct device *dev, @@ -302,17 +302,15 @@ static ssize_t sequence_show(struct device *dev, ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg); if (ret < 0) { - ret = scnprintf(buf, PAGE_SIZE, "XFER / EC ERROR %d / %d\n", - ret, msg->result); + ret = sysfs_emit(buf, "XFER / EC ERROR %d / %d\n", ret, msg->result); goto exit; } resp = (struct ec_response_lightbar *)msg->data; if (resp->get_seq.num >= ARRAY_SIZE(seqname)) - ret = scnprintf(buf, PAGE_SIZE, "%d\n", resp->get_seq.num); + ret = sysfs_emit(buf, "%d\n", resp->get_seq.num); else - ret = scnprintf(buf, PAGE_SIZE, "%s\n", - seqname[resp->get_seq.num]); + ret = sysfs_emit(buf, "%s\n", seqname[resp->get_seq.num]); exit: kfree(msg); @@ -483,7 +481,7 @@ static ssize_t userspace_control_show(struct device *dev, struct device_attribute *attr, char *buf) { - return scnprintf(buf, PAGE_SIZE, "%d\n", userspace_control); + return sysfs_emit(buf, "%d\n", userspace_control); } static ssize_t userspace_control_store(struct device *dev, diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c index f07eabcf9494..e45e57cee3a8 100644 --- a/drivers/platform/chrome/cros_ec_sysfs.c +++ b/drivers/platform/chrome/cros_ec_sysfs.c @@ -227,7 +227,7 @@ static ssize_t flashinfo_show(struct device *dev, resp = (struct ec_response_flash_info *)msg->data; - ret = scnprintf(buf, PAGE_SIZE, + ret = sysfs_emit(buf, "FlashSize %d\nWriteSize %d\n" "EraseSize %d\nProtectSize %d\n", resp->flash_size, resp->write_block_size, @@ -264,7 +264,7 @@ static ssize_t kb_wake_angle_show(struct device *dev, goto exit; resp = (struct ec_response_motion_sense *)msg->data; - ret = scnprintf(buf, PAGE_SIZE, "%d\n", resp->kb_wake_angle.ret); + ret = sysfs_emit(buf, "%d\n", resp->kb_wake_angle.ret); exit: kfree(msg); return ret; diff --git a/drivers/platform/chrome/wilco_ec/sysfs.c b/drivers/platform/chrome/wilco_ec/sysfs.c index 79a5e8fa680f..893c59dde32a 100644 --- a/drivers/platform/chrome/wilco_ec/sysfs.c +++ b/drivers/platform/chrome/wilco_ec/sysfs.c @@ -119,8 +119,7 @@ static ssize_t get_info(struct device *dev, char *buf, enum get_ec_info_op op) if (ret < 0) return ret; - return scnprintf(buf, PAGE_SIZE, "%.*s\n", (int)sizeof(resp.value), - (char *)&resp.value); + return sysfs_emit(buf, "%.*s\n", (int)sizeof(resp.value), (char *)&resp.value); } static ssize_t version_show(struct device *dev, struct device_attribute *attr,