From patchwork Thu Dec 1 03:14: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: 28175 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp55330wrr; Wed, 30 Nov 2022 19:45:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf7PxziRK8/MJ1mxzKyvHdhHQBpTZYlEm47xuPv948gYuxY3g+/8qR+JE61qM0bb6EHF4l+K X-Received: by 2002:aa7:c94a:0:b0:46b:74e1:872c with SMTP id h10-20020aa7c94a000000b0046b74e1872cmr10496039edt.301.1669866348551; Wed, 30 Nov 2022 19:45:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669866348; cv=none; d=google.com; s=arc-20160816; b=gF8V0VSl8IcAaHNeE7ZtOVvhlnNYPSiAGzsR38jAJPUy55H164CnTvCBEx+ndIWMT6 3kub5947L4QI6bBBee0j9zbciPjndMxXaQhv1Ovpzu3vwNMjIDcyfYuzYbkW57fEiXWC StKaVcITdNG97zQOYAbFn0OcY8ICSMoVrQnkaFslMmWxWHDV6KzUvTG1jkcZsIdZ5NaC kaXqGNk2ImxmdGOA3+hjsaPMJ1GABWvIUeT+O/v0pVd++4TiPIyehIxpCJDWBbTQt0wE kB8WBbIkDtNG7SlVg5sgj7C9ng52xcPuV2RJWa0Q/NGHAhKJkd+qjvNfoQ4DPk5/XAJz 7b3A== 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=wzhqmefwEu7ZlUM1GaJZ1i8MxicGkOjB9jt431w/dUQ=; b=Y6/R9mzmpBwlFaZiz6iDu32Z+ClMXKfYhY6ImbyQBo7Rtvm8GNNHDW+SvGsVsQ9ADM 18lREwQIG/wZ3ov59L99DWes+ob31GGJJeLrAxrDxWHzZ0WmYwhjRU5OA1CNq0yyJyXk 93fZ8gonsb6oqbDKNgfhAy+UteG+Owofe1KpNblOlw8wWrGOBxlpLsAZzvZC06BEB+d+ RUGmwHBNX7w1pfgjZd1qAXavXpVJhMcJFlRpDyImEI2I8+ZiM1Ey9lpmjr5Nl7AXOV32 2dLaWXZo3IMMxzo6vXygO/lqBnufxuNBQF3w8Bj/XNww3l/r1S5cMvhdD8W/QpEgz18d PINg== 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 hp30-20020a1709073e1e00b007ae0e8f59a6si2951494ejc.821.2022.11.30.19.45.25; Wed, 30 Nov 2022 19:45:48 -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 S229700AbiLADOb (ORCPT + 99 others); Wed, 30 Nov 2022 22:14:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiLADOa (ORCPT ); Wed, 30 Nov 2022 22:14:30 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA8885B851; Wed, 30 Nov 2022 19:14:28 -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 4NN1QC2yNbz4xVnf; Thu, 1 Dec 2022 11:14:27 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl2.zte.com.cn with SMTP id 2B13EGCL064526; Thu, 1 Dec 2022 11:14:16 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Thu, 1 Dec 2022 11:14:17 +0800 (CST) Date: Thu, 1 Dec 2022 11:14:17 +0800 (CST) X-Zmail-TransId: 2af963881c094624a661 X-Mailer: Zmail v1.0 Message-ID: <202212011114175709557@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , Subject: =?utf-8?q?=5BPATCH_v2=5D_HID=3A_use_sysfs=5Femit=28=29_to_instead_o?= =?utf-8?q?f_scnprintf=28=29?= X-MAIL: mse-fl2.zte.com.cn 2B13EGCL064526 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 63881C13.000 by FangMail milter! X-FangMail-Envelope: 1669864467/4NN1QC2yNbz4xVnf/63881C13.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63881C13.000/4NN1QC2yNbz4xVnf 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?1750979373907720047?= X-GMAIL-MSGID: =?utf-8?q?1750981775944509016?= From: ye xingchen Replace the open-code with sysfs_emit() to simplify the code. Signed-off-by: ye xingchen --- v1 -> v2 Add the rest in drivers/hid/ with the same changes. drivers/hid/hid-core.c | 2 +- drivers/hid/hid-cp2112.c | 2 +- drivers/hid/hid-ft260.c | 4 ++-- drivers/hid/hid-gt683r.c | 2 +- drivers/hid/hid-lg4ff.c | 6 +++--- drivers/hid/hid-logitech-hidpp.c | 2 +- drivers/hid/wacom_sys.c | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index b973df3b825d..ae1ecb21121a 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2658,7 +2658,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a, { struct hid_device *hdev = container_of(dev, struct hid_device, dev); - return scnprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n", + return sysfs_emit(buf, "hid:b%04Xg%04Xv%08Xp%08X\n", hdev->bus, hdev->group, hdev->vendor, hdev->product); } static DEVICE_ATTR_RO(modalias); diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 1e16b0fa310d..810e3b4b1728 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -895,7 +895,7 @@ static ssize_t name##_show(struct device *kdev, \ int ret = cp2112_get_usb_config(hdev, &cfg); \ if (ret) \ return ret; \ - return scnprintf(buf, PAGE_SIZE, format, ##__VA_ARGS__); \ + return sysfs_emit(buf, format, ##__VA_ARGS__); \ } \ static DEVICE_ATTR_RW(name); diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 333341e80b0e..8677bea46bea 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -826,7 +826,7 @@ static int ft260_byte_show(struct hid_device *hdev, int id, u8 *cfg, int len, if (ret < 0) return ret; - return scnprintf(buf, PAGE_SIZE, "%d\n", *field); + return sysfs_emit(buf, "%d\n", *field); } static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len, @@ -838,7 +838,7 @@ static int ft260_word_show(struct hid_device *hdev, int id, u8 *cfg, int len, if (ret < 0) return ret; - return scnprintf(buf, PAGE_SIZE, "%d\n", le16_to_cpu(*field)); + return sysfs_emit(buf, "%d\n", le16_to_cpu(*field)); } #define FT260_ATTR_SHOW(name, reptype, id, type, func) \ diff --git a/drivers/hid/hid-gt683r.c b/drivers/hid/hid-gt683r.c index 29ccb0accfba..fa453de406b9 100644 --- a/drivers/hid/hid-gt683r.c +++ b/drivers/hid/hid-gt683r.c @@ -90,7 +90,7 @@ static ssize_t mode_show(struct device *dev, else sysfs_mode = 2; - return scnprintf(buf, PAGE_SIZE, "%u\n", sysfs_mode); + return sysfs_emit(buf, "%u\n", sysfs_mode); } static ssize_t mode_store(struct device *dev, diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index e3fcf1353fb3..07f3cf175060 100644 --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c @@ -956,7 +956,7 @@ static ssize_t lg4ff_combine_show(struct device *dev, struct device_attribute *a return 0; } - count = scnprintf(buf, PAGE_SIZE, "%u\n", entry->wdata.combine); + count = sysfs_emit(buf, "%u\n", entry->wdata.combine); return count; } @@ -1009,7 +1009,7 @@ static ssize_t lg4ff_range_show(struct device *dev, struct device_attribute *att return 0; } - count = scnprintf(buf, PAGE_SIZE, "%u\n", entry->wdata.range); + count = sysfs_emit(buf, "%u\n", entry->wdata.range); return count; } @@ -1073,7 +1073,7 @@ static ssize_t lg4ff_real_id_show(struct device *dev, struct device_attribute *a return 0; } - count = scnprintf(buf, PAGE_SIZE, "%s: %s\n", entry->wdata.real_tag, entry->wdata.real_name); + count = sysfs_emit(buf, "%s: %s\n", entry->wdata.real_tag, entry->wdata.real_name); return count; } diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 9afbc68bf063..38ba30f72c8c 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -2506,7 +2506,7 @@ static ssize_t hidpp_ff_range_show(struct device *dev, struct device_attribute * struct input_dev *idev = hidinput->input; struct hidpp_ff_private_data *data = idev->ff->private; - return scnprintf(buf, PAGE_SIZE, "%u\n", data->range); + return sysfs_emit(buf, "%u\n", data->range); } static ssize_t hidpp_ff_range_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 634263e4556b..00556a045e51 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -1058,7 +1058,7 @@ static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \ { \ struct hid_device *hdev = to_hid_device(dev);\ struct wacom *wacom = hid_get_drvdata(hdev); \ - return scnprintf(buf, PAGE_SIZE, "%d\n", \ + return sysfs_emit(buf, "%d\n", \ wacom->led.groups[SET_ID].select); \ } \ static DEVICE_ATTR(status_led##SET_ID##_select, DEV_ATTR_RW_PERM, \ @@ -1102,7 +1102,7 @@ static ssize_t wacom_##name##_luminance_show(struct device *dev, \ struct device_attribute *attr, char *buf) \ { \ struct wacom *wacom = dev_get_drvdata(dev); \ - return scnprintf(buf, PAGE_SIZE, "%d\n", wacom->led.field); \ + return sysfs_emit(buf, "%d\n", wacom->led.field); \ } \ static DEVICE_ATTR(name##_luminance, DEV_ATTR_RW_PERM, \ wacom_##name##_luminance_show, \