From patchwork Fri Dec 2 06:53:57 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: 28727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp689914wrr; Thu, 1 Dec 2022 23:11:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf4AqIsW/JrPSaVkmv9eoCShxkQJ/ZwaD58WuVMFruRN5GxNEjkPeOm/vnKsD7kVSNy7xaqO X-Received: by 2002:a05:6402:4a:b0:461:aa10:cb0c with SMTP id f10-20020a056402004a00b00461aa10cb0cmr63409438edu.383.1669965102959; Thu, 01 Dec 2022 23:11:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669965102; cv=none; d=google.com; s=arc-20160816; b=yIx+9s58f6CluFLJpxmdhgXm1RlPiS+Sf3cnxpoTYc/xXQXjVYkxAhWiMxJREtnhFd pOOjEJPwHnqoSaEJdeHPftghuBnS1UcW50PiUP+r8vPTdHTTHy60Sz1WoK8vGUWrj4bM q+8K58xD+27fShd/A0EKjUpFkEDlChLsTA2D7cDpBqVjMg8OS2BeL6cUdJWmM1D4A1TK uscalA44cDVTVs//3uDUrFiIlJKHWj3Ivp9rdb2PV557qDugbXAE3a2oRh2NGhEIFLHs DSY/FJNCTr0AfITCVgKW8S9rg25F/DJ8Z2UUUGf1fB5uVRA6VjeeVnMIcMRFLIVJypOG sdlg== 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=YmvE764/w/tcA0zHsjza8vwJfirNkOmQtyVfyaL3MqQ=; b=Q0rxJGzouaeiuRzQJw4kSpNth45POjjUFU341a3XJhltnS78URcCkaow9EnAdH3kcb 1QyGiPLhSxMYzSn7jSxLfm8rYz6alO1IB+rSIt0XXo11pjeZNF1LBhhPpIqcPZ5KOc4k TjTDgyDVnOYIVxihAsiYM8kL49Vqp8lR2KyRK8PKsO85Mekw93BvoLGmPl7zsw+Yb8cA zlCAKYJ5vkf5pStnnQrV5+7RP1FsrW1c6pkAkwzTocsKmILqF3WFSPTx/j/MYpZ89a+Q ZhXzDWla/2TvmvodskSYuYnZhaQHc1jNFte/ZiwfngHb1brz18Cf+1mjgsgFU2qSIbnF 9kVg== 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 b19-20020a056402351300b0046a31967739si5811574edd.96.2022.12.01.23.11.19; Thu, 01 Dec 2022 23:11:42 -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 S232314AbiLBGyN (ORCPT + 99 others); Fri, 2 Dec 2022 01:54:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232394AbiLBGyL (ORCPT ); Fri, 2 Dec 2022 01:54:11 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98D21BC58E; Thu, 1 Dec 2022 22:54:08 -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 4NNkFB1c7xz4xVnH; Fri, 2 Dec 2022 14:54:06 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl1.zte.com.cn with SMTP id 2B26rtMr007050; Fri, 2 Dec 2022 14:53:55 +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 14:53:57 +0800 (CST) Date: Fri, 2 Dec 2022 14:53:57 +0800 (CST) X-Zmail-TransId: 2af96389a105fffffffff3915876 X-Mailer: Zmail v1.0 Message-ID: <202212021453578171100@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , Subject: =?utf-8?q?=5BPATCH_v2=5D_Input=3A_mouse=3A_use_sysfs=5Femit=28=29_t?= =?utf-8?q?o_instead_of_scnprintf=28=29?= X-MAIL: mse-fl1.zte.com.cn 2B26rtMr007050 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 6389A10E.000 by FangMail milter! X-FangMail-Envelope: 1669964046/4NNkFB1c7xz4xVnH/6389A10E.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6389A10E.000/4NNkFB1c7xz4xVnH 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?1751085327612609617?= X-GMAIL-MSGID: =?utf-8?q?1751085327612609617?= From: ye xingchen Replace the open-code with sysfs_emit() to simplify the code. Signed-off-by: ye xingchen --- v1 -> v2 fix the code style. drivers/input/mouse/cyapa.c | 17 ++++++++--------- drivers/input/mouse/cyapa_gen3.c | 2 +- drivers/input/mouse/cyapa_gen5.c | 2 +- drivers/input/mouse/cyapa_gen6.c | 2 +- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c index 77cc653edca2..897f0c2c9a05 100644 --- a/drivers/input/mouse/cyapa.c +++ b/drivers/input/mouse/cyapa.c @@ -756,15 +756,15 @@ static ssize_t cyapa_show_suspend_scanrate(struct device *dev, switch (pwr_cmd) { case PWR_MODE_BTN_ONLY: - len = scnprintf(buf, PAGE_SIZE, "%s\n", BTN_ONLY_MODE_NAME); + len = sysfs_emit(buf, "%s\n", BTN_ONLY_MODE_NAME); break; case PWR_MODE_OFF: - len = scnprintf(buf, PAGE_SIZE, "%s\n", OFF_MODE_NAME); + len = sysfs_emit(buf, "%s\n", OFF_MODE_NAME); break; default: - len = scnprintf(buf, PAGE_SIZE, "%u\n", + len = sysfs_emit(buf, "%u\n", cyapa->gen == CYAPA_GEN3 ? cyapa_pwr_cmd_to_sleep_time(pwr_cmd) : sleep_time); @@ -877,8 +877,8 @@ static ssize_t cyapa_show_rt_suspend_scanrate(struct device *dev, mutex_unlock(&cyapa->state_sync_lock); - return scnprintf(buf, PAGE_SIZE, "%u\n", - cyapa->gen == CYAPA_GEN3 ? + return sysfs_emit(buf, "%u\n", + cyapa->gen == CYAPA_GEN3 ? cyapa_pwr_cmd_to_sleep_time(pwr_cmd) : sleep_time); } @@ -988,8 +988,7 @@ static ssize_t cyapa_show_fm_ver(struct device *dev, error = mutex_lock_interruptible(&cyapa->state_sync_lock); if (error) return error; - error = scnprintf(buf, PAGE_SIZE, "%d.%d\n", cyapa->fw_maj_ver, - cyapa->fw_min_ver); + error = sysfs_emit(buf, "%d.%d\n", cyapa->fw_maj_ver, cyapa->fw_min_ver); mutex_unlock(&cyapa->state_sync_lock); return error; } @@ -1004,7 +1003,7 @@ static ssize_t cyapa_show_product_id(struct device *dev, error = mutex_lock_interruptible(&cyapa->state_sync_lock); if (error) return error; - size = scnprintf(buf, PAGE_SIZE, "%s\n", cyapa->product_id); + size = sysfs_emit(buf, "%s\n", cyapa->product_id); mutex_unlock(&cyapa->state_sync_lock); return size; } @@ -1209,7 +1208,7 @@ static ssize_t cyapa_show_mode(struct device *dev, if (error) return error; - size = scnprintf(buf, PAGE_SIZE, "gen%d %s\n", + size = sysfs_emit(buf, "gen%d %s\n", cyapa->gen, cyapa_state_to_string(cyapa)); mutex_unlock(&cyapa->state_sync_lock); diff --git a/drivers/input/mouse/cyapa_gen3.c b/drivers/input/mouse/cyapa_gen3.c index a97f4acb6452..60c83bc71d84 100644 --- a/drivers/input/mouse/cyapa_gen3.c +++ b/drivers/input/mouse/cyapa_gen3.c @@ -860,7 +860,7 @@ static ssize_t cyapa_gen3_show_baseline(struct device *dev, dev_dbg(dev, "Baseline report successful. Max: %d Min: %d\n", max_baseline, min_baseline); - ret = scnprintf(buf, PAGE_SIZE, "%d %d\n", max_baseline, min_baseline); + ret = sysfs_emit(buf, "%d %d\n", max_baseline, min_baseline); out: return ret; diff --git a/drivers/input/mouse/cyapa_gen5.c b/drivers/input/mouse/cyapa_gen5.c index abf42f77b4c5..4c57036e4281 100644 --- a/drivers/input/mouse/cyapa_gen5.c +++ b/drivers/input/mouse/cyapa_gen5.c @@ -2418,7 +2418,7 @@ static ssize_t cyapa_gen5_show_baseline(struct device *dev, return resume_error ? resume_error : error; /* 12. Output data strings */ - size = scnprintf(buf, PAGE_SIZE, "%d %d %d %d %d %d %d %d %d %d %d ", + size = sysfs_emit(buf, "%d %d %d %d %d %d %d %d %d %d %d ", gidac_mutual_min, gidac_mutual_max, gidac_mutual_ave, lidac_mutual_min, lidac_mutual_max, lidac_mutual_ave, gidac_self_rx, gidac_self_tx, diff --git a/drivers/input/mouse/cyapa_gen6.c b/drivers/input/mouse/cyapa_gen6.c index 0caaf3e64215..b6f7c77c96c2 100644 --- a/drivers/input/mouse/cyapa_gen6.c +++ b/drivers/input/mouse/cyapa_gen6.c @@ -629,7 +629,7 @@ static ssize_t cyapa_gen6_show_baseline(struct device *dev, if (error) goto resume_scanning; - size = scnprintf(buf, PAGE_SIZE, "%d %d %d %d %d %d ", + size = sysfs_emit(buf, "%d %d %d %d %d %d ", data[0], /* RX Attenuator Mutual */ data[1], /* IDAC Mutual */ data[2], /* RX Attenuator Self RX */