From patchwork Tue Dec 6 03:14:08 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: 30071 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2605853wrr; Mon, 5 Dec 2022 19:20:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf50lkuipPNGiJlESYgJ5Sgd0vlGxv0pn5GBjja/Nv918h6W0vMUgrRmumwhVn9vOMEjLKz+ X-Received: by 2002:a05:6402:1381:b0:468:5b78:6381 with SMTP id b1-20020a056402138100b004685b786381mr64361105edv.373.1670296830961; Mon, 05 Dec 2022 19:20:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670296830; cv=none; d=google.com; s=arc-20160816; b=kyDmTrPPhVAQvD0J7jGfsqO59anAtdUiYUJQ5EebD+4EdSO90oawyOux0XPAEAphd/ kzzcKC+IPQRlIAzlXgrNU6o+eTot3BDvEojKJI2YM/8NV64s0+UaLWE9Xt6HIgOpCeG7 r9Boh22me0LdmK8FSx0qB3tGjTA9pzlvVQX+ZBUxXaP0pPCLeAuRC806kMh9ZPs1ROgA vjLxVMwx6MCKod18ZSXaEvvDHYrhEWge7u4OFl7FDZvs3tR9gABBRlXM/DoQ7ix9AvR4 9gZDDL/YPfWYgLv6+QXCOYLI6nN8dEs+t7zTiaro0wPTHK9DpuoGeYSbTnrVczY2dU4o cxTA== 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=vfF9Ji95UnRhRxvqeQUmpo3HrmIeU0XhrfI2csv8DsQ=; b=hbxzxJk8d4c7+Fa2g1mHPhe3nPW/9C/3VxvPSO27QUUcGweLmy9bwr44ITec5YhiTg imru/bDFnjwq2EGWrRRTjYMlSZKpJ0/2wQORTpXFBk1BlkLHzuJurKe0i7pvn5VeHxJC NMO1vwxf8/MW2BxUK64SmpLEiUO79OIsCyEWEznX5N4MtDPdKAmKyOD/8G4tvGwcpbxt rlMjjVhd30cdz+eEFkUTChRsgTdUyO5+mTfQCYpo8tm4sLC6HjPYoOn7t4kXQbpkbs17 rSr+V24BABoLF7bpgD6AO0r9NA6duyTImRe0RmEJvQHbhdaKOaU53ZMb8FzTzHb/XAGK PubA== 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 i6-20020a1709063c4600b007c0a70496desi7264553ejg.724.2022.12.05.19.20.07; Mon, 05 Dec 2022 19:20:30 -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 S232825AbiLFDOS (ORCPT + 99 others); Mon, 5 Dec 2022 22:14:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231737AbiLFDOR (ORCPT ); Mon, 5 Dec 2022 22:14:17 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AA77220CE; Mon, 5 Dec 2022 19:14:15 -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 4NR59f0sSqz4xVnZ; Tue, 6 Dec 2022 11:14:14 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl2.zte.com.cn with SMTP id 2B63E7hG050650; Tue, 6 Dec 2022 11:14:07 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Tue, 6 Dec 2022 11:14:08 +0800 (CST) Date: Tue, 6 Dec 2022 11:14:08 +0800 (CST) X-Zmail-TransId: 2af9638eb380ffffffff8c971ebb X-Mailer: Zmail v1.0 Message-ID: <202212061114083350005@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , Subject: =?utf-8?q?=5BPATCH_linux-next_v2=5D_power=3A_supply=3A_use_sysfs=5F?= =?utf-8?q?emit=28=29_to_instead_of_scnprintf=28=29?= X-MAIL: mse-fl2.zte.com.cn 2B63E7hG050650 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 638EB386.000 by FangMail milter! X-FangMail-Envelope: 1670296454/4NR59f0sSqz4xVnZ/638EB386.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638EB386.000/4NR59f0sSqz4xVnZ 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?1751433169374580140?= X-GMAIL-MSGID: =?utf-8?q?1751433169374580140?= 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 v1 -> v2 Convert to use sysfs_emit_at() API in power/supply/twl4030_charger.c. --- drivers/power/supply/ab8500_fg.c | 18 +++++++++--------- drivers/power/supply/bq24190_charger.c | 2 +- drivers/power/supply/bq24257_charger.c | 8 +++----- drivers/power/supply/lp8788-charger.c | 7 +++---- drivers/power/supply/max14577_charger.c | 2 +- drivers/power/supply/max77693_charger.c | 6 +++--- drivers/power/supply/twl4030_charger.c | 6 ++---- 7 files changed, 22 insertions(+), 27 deletions(-) diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index c6c9804280db..d989eadaa933 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -2594,7 +2594,7 @@ static ssize_t ab8505_powercut_flagtime_read(struct device *dev, goto fail; } - return scnprintf(buf, PAGE_SIZE, "%d\n", (reg_value & 0x7F)); + return sysfs_emit(buf, "%d\n", (reg_value & 0x7F)); fail: return ret; @@ -2644,7 +2644,7 @@ static ssize_t ab8505_powercut_maxtime_read(struct device *dev, goto fail; } - return scnprintf(buf, PAGE_SIZE, "%d\n", (reg_value & 0x7F)); + return sysfs_emit(buf, "%d\n", (reg_value & 0x7F)); fail: return ret; @@ -2695,7 +2695,7 @@ static ssize_t ab8505_powercut_restart_read(struct device *dev, goto fail; } - return scnprintf(buf, PAGE_SIZE, "%d\n", (reg_value & 0xF)); + return sysfs_emit(buf, "%d\n", (reg_value & 0xF)); fail: return ret; @@ -2746,7 +2746,7 @@ static ssize_t ab8505_powercut_timer_read(struct device *dev, goto fail; } - return scnprintf(buf, PAGE_SIZE, "%d\n", (reg_value & 0x7F)); + return sysfs_emit(buf, "%d\n", (reg_value & 0x7F)); fail: return ret; @@ -2769,7 +2769,7 @@ static ssize_t ab8505_powercut_restart_counter_read(struct device *dev, goto fail; } - return scnprintf(buf, PAGE_SIZE, "%d\n", (reg_value & 0xF0) >> 4); + return sysfs_emit(buf, "%d\n", (reg_value & 0xF0) >> 4); fail: return ret; @@ -2790,7 +2790,7 @@ static ssize_t ab8505_powercut_read(struct device *dev, if (ret < 0) goto fail; - return scnprintf(buf, PAGE_SIZE, "%d\n", (reg_value & 0x1)); + return sysfs_emit(buf, "%d\n", (reg_value & 0x1)); fail: return ret; @@ -2841,7 +2841,7 @@ static ssize_t ab8505_powercut_flag_read(struct device *dev, goto fail; } - return scnprintf(buf, PAGE_SIZE, "%d\n", ((reg_value & 0x10) >> 4)); + return sysfs_emit(buf, "%d\n", ((reg_value & 0x10) >> 4)); fail: return ret; @@ -2864,7 +2864,7 @@ static ssize_t ab8505_powercut_debounce_read(struct device *dev, goto fail; } - return scnprintf(buf, PAGE_SIZE, "%d\n", (reg_value & 0x7)); + return sysfs_emit(buf, "%d\n", (reg_value & 0x7)); fail: return ret; @@ -2914,7 +2914,7 @@ static ssize_t ab8505_powercut_enable_status_read(struct device *dev, goto fail; } - return scnprintf(buf, PAGE_SIZE, "%d\n", ((reg_value & 0x20) >> 5)); + return sysfs_emit(buf, "%d\n", ((reg_value & 0x20) >> 5)); fail: return ret; diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index 2b2c3a4391c1..be34b9848450 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -463,7 +463,7 @@ static ssize_t bq24190_sysfs_show(struct device *dev, if (ret) count = ret; else - count = scnprintf(buf, PAGE_SIZE, "%hhx\n", v); + count = sysfs_emit(buf, "%hhx\n", v); pm_runtime_mark_last_busy(bdi->dev); pm_runtime_put_autosuspend(bdi->dev); diff --git a/drivers/power/supply/bq24257_charger.c b/drivers/power/supply/bq24257_charger.c index ab4c49788c58..103ddc2b3def 100644 --- a/drivers/power/supply/bq24257_charger.c +++ b/drivers/power/supply/bq24257_charger.c @@ -767,8 +767,7 @@ static ssize_t bq24257_show_ovp_voltage(struct device *dev, struct power_supply *psy = dev_get_drvdata(dev); struct bq24257_device *bq = power_supply_get_drvdata(psy); - return scnprintf(buf, PAGE_SIZE, "%u\n", - bq24257_vovp_map[bq->init_data.vovp]); + return sysfs_emit(buf, "%u\n", bq24257_vovp_map[bq->init_data.vovp]); } static ssize_t bq24257_show_in_dpm_voltage(struct device *dev, @@ -778,8 +777,7 @@ static ssize_t bq24257_show_in_dpm_voltage(struct device *dev, struct power_supply *psy = dev_get_drvdata(dev); struct bq24257_device *bq = power_supply_get_drvdata(psy); - return scnprintf(buf, PAGE_SIZE, "%u\n", - bq24257_vindpm_map[bq->init_data.vindpm]); + return sysfs_emit(buf, "%u\n", bq24257_vindpm_map[bq->init_data.vindpm]); } static ssize_t bq24257_sysfs_show_enable(struct device *dev, @@ -800,7 +798,7 @@ static ssize_t bq24257_sysfs_show_enable(struct device *dev, if (ret < 0) return ret; - return scnprintf(buf, PAGE_SIZE, "%d\n", ret); + return sysfs_emit(buf, "%d\n", ret); } static ssize_t bq24257_sysfs_set_enable(struct device *dev, diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c index f5f47a0aa1e3..755b6a4379b8 100644 --- a/drivers/power/supply/lp8788-charger.c +++ b/drivers/power/supply/lp8788-charger.c @@ -602,7 +602,7 @@ static ssize_t lp8788_show_charger_status(struct device *dev, lp8788_read_byte(pchg->lp, LP8788_CHG_STATUS, &data); state = (data & LP8788_CHG_STATE_M) >> LP8788_CHG_STATE_S; - return scnprintf(buf, PAGE_SIZE, "%s\n", desc[state]); + return sysfs_emit(buf, "%s\n", desc[state]); } static ssize_t lp8788_show_eoc_time(struct device *dev, @@ -618,8 +618,7 @@ static ssize_t lp8788_show_eoc_time(struct device *dev, lp8788_read_byte(pchg->lp, LP8788_CHG_EOC, &val); val = (val & LP8788_CHG_EOC_TIME_M) >> LP8788_CHG_EOC_TIME_S; - return scnprintf(buf, PAGE_SIZE, "End Of Charge Time: %s\n", - stime[val]); + return sysfs_emit(buf, "End Of Charge Time: %s\n", stime[val]); } static ssize_t lp8788_show_eoc_level(struct device *dev, @@ -642,7 +641,7 @@ static ssize_t lp8788_show_eoc_level(struct device *dev, val = (val & LP8788_CHG_EOC_LEVEL_M) >> LP8788_CHG_EOC_LEVEL_S; level = mode ? abs_level[val] : relative_level[val]; - return scnprintf(buf, PAGE_SIZE, "End Of Charge Level: %s\n", level); + return sysfs_emit(buf, "End Of Charge Level: %s\n", level); } static DEVICE_ATTR(charger_status, S_IRUSR, lp8788_show_charger_status, NULL); diff --git a/drivers/power/supply/max14577_charger.c b/drivers/power/supply/max14577_charger.c index f244cd902eb9..96f9de775043 100644 --- a/drivers/power/supply/max14577_charger.c +++ b/drivers/power/supply/max14577_charger.c @@ -532,7 +532,7 @@ static ssize_t show_fast_charge_timer(struct device *dev, break; } - return scnprintf(buf, PAGE_SIZE, "%u\n", val); + return sysfs_emit(buf, "%u\n", val); } static ssize_t store_fast_charge_timer(struct device *dev, diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index a2c5c9858639..794c8c054450 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -296,7 +296,7 @@ static ssize_t fast_charge_timer_show(struct device *dev, break; } - return scnprintf(buf, PAGE_SIZE, "%u\n", val); + return sysfs_emit(buf, "%u\n", val); } static int max77693_set_fast_charge_timer(struct max77693_charger *chg, @@ -357,7 +357,7 @@ static ssize_t top_off_threshold_current_show(struct device *dev, else val = data * 50000; - return scnprintf(buf, PAGE_SIZE, "%u\n", val); + return sysfs_emit(buf, "%u\n", val); } static int max77693_set_top_off_threshold_current(struct max77693_charger *chg, @@ -405,7 +405,7 @@ static ssize_t top_off_timer_show(struct device *dev, val = data * 10; - return scnprintf(buf, PAGE_SIZE, "%u\n", val); + return sysfs_emit(buf, "%u\n", val); } static int max77693_set_top_off_timer(struct max77693_charger *chg, diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c index 1bc49b2e12e8..53a0ea5a61da 100644 --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c @@ -726,11 +726,9 @@ twl4030_bci_mode_show(struct device *dev, for (i = 0; i < ARRAY_SIZE(modes); i++) if (mode == i) - len += scnprintf(buf+len, PAGE_SIZE-len, - "[%s] ", modes[i]); + len += sysfs_emit_at(buf, len, "[%s] ", modes[i]); else - len += scnprintf(buf+len, PAGE_SIZE-len, - "%s ", modes[i]); + len += sysfs_emit_at(buf, len, "%s ", modes[i]); buf[len-1] = '\n'; return len; }