From nobody Thu Sep 18 13:11:00 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E58BC4708E for ; Tue, 6 Dec 2022 11:22:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230220AbiLFLWK (ORCPT ); Tue, 6 Dec 2022 06:22:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234211AbiLFLWA (ORCPT ); Tue, 6 Dec 2022 06:22:00 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEEF8B7FD for ; Tue, 6 Dec 2022 03:21:57 -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 4NRJ0M5Q2xz8RTZG; Tue, 6 Dec 2022 19:21:55 +0800 (CST) Received: from xaxapp03.zte.com.cn ([10.88.40.52]) by mse-fl1.zte.com.cn with SMTP id 2B6BLnp4012360; Tue, 6 Dec 2022 19:21:49 +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 19:21:52 +0800 (CST) Date: Tue, 6 Dec 2022 19:21:52 +0800 (CST) X-Zmail-TransId: 2af9638f25d060b938de X-Mailer: Zmail v1.0 Message-ID: <202212061921524930043@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , Subject: =?UTF-8?B?W1BBVENIXSBjb3Jlc2lnaHQ6IENvbnZlcnQgdG8gdXNlIHN5c2ZzX2VtaXQoKS9zeXNmc19lbWl0X2F0KCkgQVBJcw==?= X-MAIL: mse-fl1.zte.com.cn 2B6BLnp4012360 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 638F25D3.000 by FangMail milter! X-FangMail-Envelope: 1670325715/4NRJ0M5Q2xz8RTZG/638F25D3.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638F25D3.000/4NRJ0M5Q2xz8RTZG Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/hwtracing/coresight/coresight-core.c | 4 +- .../hwtracing/coresight/coresight-etm-perf.c | 4 +- .../coresight/coresight-etm3x-sysfs.c | 2 +- .../coresight/coresight-etm4x-sysfs.c | 114 +++++++++--------- drivers/hwtracing/coresight/coresight-stm.c | 8 +- .../coresight/coresight-syscfg-configfs.c | 25 ++-- 6 files changed, 77 insertions(+), 80 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtraci= ng/coresight/coresight-core.c index f3068175ca9d..d5d5080cce78 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1236,7 +1236,7 @@ static ssize_t enable_sink_show(struct device *dev, { struct coresight_device *csdev =3D to_coresight_device(dev); - return scnprintf(buf, PAGE_SIZE, "%u\n", csdev->activated); + return sysfs_emit(buf, "%u\n", csdev->activated); } static ssize_t enable_sink_store(struct device *dev, @@ -1266,7 +1266,7 @@ static ssize_t enable_source_show(struct device *dev, { struct coresight_device *csdev =3D to_coresight_device(dev); - return scnprintf(buf, PAGE_SIZE, "%u\n", csdev->enable); + return sysfs_emit(buf, "%u\n", csdev->enable); } static ssize_t enable_source_store(struct device *dev, diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwt= racing/coresight/coresight-etm-perf.c index 43bbd5dc3d3b..8bf8dbf4b7c2 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -726,7 +726,7 @@ static ssize_t etm_perf_sink_name_show(struct device *d= ev, struct dev_ext_attribute *ea; ea =3D container_of(dattr, struct dev_ext_attribute, attr); - return scnprintf(buf, PAGE_SIZE, "0x%lx\n", (unsigned long)(ea->var)); + return sysfs_emit(buf, "0x%lx\n", (unsigned long)(ea->var)); } static struct dev_ext_attribute * @@ -818,7 +818,7 @@ static ssize_t etm_perf_cscfg_event_show(struct device = *dev, struct dev_ext_attribute *ea; ea =3D container_of(dattr, struct dev_ext_attribute, attr); - return scnprintf(buf, PAGE_SIZE, "configid=3D0x%lx\n", (unsigned long)(ea= ->var)); + return sysfs_emit(buf, "configid=3D0x%lx\n", (unsigned long)(ea->var)); } int etm_perf_add_symlink_cscfg(struct device *dev, struct cscfg_config_des= c *config_desc) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/= hwtracing/coresight/coresight-etm3x-sysfs.c index fd81eca3ec18..3cb811853d64 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c @@ -1181,7 +1181,7 @@ static ssize_t cpu_show(struct device *dev, struct etm_drvdata *drvdata =3D dev_get_drvdata(dev->parent); val =3D drvdata->cpu; - return scnprintf(buf, PAGE_SIZE, "%d\n", val); + return sysfs_emit(buf, "%d\n", val); } static DEVICE_ATTR_RO(cpu); diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/= hwtracing/coresight/coresight-etm4x-sysfs.c index 9cac848cffaf..46509fb6a373 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c @@ -62,7 +62,7 @@ static ssize_t nr_pe_cmp_show(struct device *dev, struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); val =3D drvdata->nr_pe_cmp; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static DEVICE_ATTR_RO(nr_pe_cmp); @@ -74,7 +74,7 @@ static ssize_t nr_addr_cmp_show(struct device *dev, struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); val =3D drvdata->nr_addr_cmp; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static DEVICE_ATTR_RO(nr_addr_cmp); @@ -86,7 +86,7 @@ static ssize_t nr_cntr_show(struct device *dev, struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); val =3D drvdata->nr_cntr; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static DEVICE_ATTR_RO(nr_cntr); @@ -98,7 +98,7 @@ static ssize_t nr_ext_inp_show(struct device *dev, struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); val =3D drvdata->nr_ext_inp; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static DEVICE_ATTR_RO(nr_ext_inp); @@ -110,7 +110,7 @@ static ssize_t numcidc_show(struct device *dev, struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); val =3D drvdata->numcidc; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static DEVICE_ATTR_RO(numcidc); @@ -122,7 +122,7 @@ static ssize_t numvmidc_show(struct device *dev, struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); val =3D drvdata->numvmidc; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static DEVICE_ATTR_RO(numvmidc); @@ -134,7 +134,7 @@ static ssize_t nrseqstate_show(struct device *dev, struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); val =3D drvdata->nrseqstate; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static DEVICE_ATTR_RO(nrseqstate); @@ -146,7 +146,7 @@ static ssize_t nr_resource_show(struct device *dev, struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); val =3D drvdata->nr_resource; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static DEVICE_ATTR_RO(nr_resource); @@ -158,7 +158,7 @@ static ssize_t nr_ss_cmp_show(struct device *dev, struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); val =3D drvdata->nr_ss_cmp; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static DEVICE_ATTR_RO(nr_ss_cmp); @@ -285,7 +285,7 @@ static ssize_t mode_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->mode; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t mode_store(struct device *dev, @@ -451,7 +451,7 @@ static ssize_t pe_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->pe_sel; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t pe_store(struct device *dev, @@ -486,7 +486,7 @@ static ssize_t event_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->eventctrl0; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t event_store(struct device *dev, @@ -535,7 +535,7 @@ static ssize_t event_instren_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D FIELD_GET(TRCEVENTCTL1R_INSTEN_MASK, config->eventctrl1); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t event_instren_store(struct device *dev, @@ -591,7 +591,7 @@ static ssize_t event_ts_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->ts_ctrl; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t event_ts_store(struct device *dev, @@ -621,7 +621,7 @@ static ssize_t syncfreq_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->syncfreq; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t syncfreq_store(struct device *dev, @@ -651,7 +651,7 @@ static ssize_t cyc_threshold_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->ccctlr; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t cyc_threshold_store(struct device *dev, @@ -684,7 +684,7 @@ static ssize_t bb_ctrl_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->bb_ctrl; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t bb_ctrl_store(struct device *dev, @@ -724,7 +724,7 @@ static ssize_t event_vinst_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D FIELD_GET(TRCVICTLR_EVENT_MASK, config->vinst_ctrl); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t event_vinst_store(struct device *dev, @@ -756,7 +756,7 @@ static ssize_t s_exlevel_vinst_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D FIELD_GET(TRCVICTLR_EXLEVEL_S_MASK, config->vinst_ctrl); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t s_exlevel_vinst_store(struct device *dev, @@ -791,7 +791,7 @@ static ssize_t ns_exlevel_vinst_show(struct device *dev, /* EXLEVEL_NS, bits[23:20] */ val =3D FIELD_GET(TRCVICTLR_EXLEVEL_NS_MASK, config->vinst_ctrl); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t ns_exlevel_vinst_store(struct device *dev, @@ -825,7 +825,7 @@ static ssize_t addr_idx_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->addr_idx; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t addr_idx_store(struct device *dev, @@ -864,7 +864,7 @@ static ssize_t addr_instdatatype_show(struct device *de= v, spin_lock(&drvdata->spinlock); idx =3D config->addr_idx; val =3D FIELD_GET(TRCACATRn_TYPE_MASK, config->addr_acc[idx]); - len =3D scnprintf(buf, PAGE_SIZE, "%s\n", + len =3D sysfs_emit(buf, "%s\n", val =3D=3D TRCACATRn_TYPE_ADDR ? "instr" : (val =3D=3D TRCACATRn_TYPE_DATA_LOAD_ADDR ? "data_load" : (val =3D=3D TRCACATRn_TYPE_DATA_STORE_ADDR ? "data_store" : @@ -916,7 +916,7 @@ static ssize_t addr_single_show(struct device *dev, } val =3D (unsigned long)config->addr_val[idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t addr_single_store(struct device *dev, @@ -972,7 +972,7 @@ static ssize_t addr_range_show(struct device *dev, val1 =3D (unsigned long)config->addr_val[idx]; val2 =3D (unsigned long)config->addr_val[idx + 1]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx %#lx\n", val1, val2); + return sysfs_emit(buf, "%#lx %#lx\n", val1, val2); } static ssize_t addr_range_store(struct device *dev, @@ -1047,7 +1047,7 @@ static ssize_t addr_start_show(struct device *dev, val =3D (unsigned long)config->addr_val[idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t addr_start_store(struct device *dev, @@ -1102,7 +1102,7 @@ static ssize_t addr_stop_show(struct device *dev, val =3D (unsigned long)config->addr_val[idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t addr_stop_store(struct device *dev, @@ -1150,7 +1150,7 @@ static ssize_t addr_ctxtype_show(struct device *dev, idx =3D config->addr_idx; /* CONTEXTTYPE, bits[3:2] */ val =3D FIELD_GET(TRCACATRn_CONTEXTTYPE_MASK, config->addr_acc[idx]); - len =3D scnprintf(buf, PAGE_SIZE, "%s\n", val =3D=3D ETM_CTX_NONE ? "none= " : + len =3D sysfs_emit(buf, "%s\n", val =3D=3D ETM_CTX_NONE ? "none" : (val =3D=3D ETM_CTX_CTXID ? "ctxid" : (val =3D=3D ETM_CTX_VMID ? "vmid" : "all"))); spin_unlock(&drvdata->spinlock); @@ -1217,7 +1217,7 @@ static ssize_t addr_context_show(struct device *dev, /* context ID comparator bits[6:4] */ val =3D FIELD_GET(TRCACATRn_CONTEXT_MASK, config->addr_acc[idx]); spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t addr_context_store(struct device *dev, @@ -1260,7 +1260,7 @@ static ssize_t addr_exlevel_s_ns_show(struct device *= dev, idx =3D config->addr_idx; val =3D FIELD_GET(TRCACATRn_EXLEVEL_MASK, config->addr_acc[idx]); spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t addr_exlevel_s_ns_store(struct device *dev, @@ -1323,17 +1323,16 @@ static ssize_t addr_cmp_view_show(struct device *de= v, } spin_unlock(&drvdata->spinlock); if (addr_type) { - size =3D scnprintf(buf, PAGE_SIZE, "addr_cmp[%i] %s %#lx", idx, + size =3D sysfs_emit(buf, "addr_cmp[%i] %s %#lx", idx, addr_type_names[addr_type], addr_v); if (addr_type =3D=3D ETM_ADDR_TYPE_RANGE) { - size +=3D scnprintf(buf + size, PAGE_SIZE - size, + size +=3D sysfs_emit_at(buf, size, " %#lx %s", addr_v2, exclude ? "exclude" : "include"); } - size +=3D scnprintf(buf + size, PAGE_SIZE - size, - " ctrl(%#lx)\n", addr_ctrl); + size +=3D sysfs_emit_at(buf, size, " ctrl(%#lx)\n", addr_ctrl); } else { - size =3D scnprintf(buf, PAGE_SIZE, "addr_cmp[%i] unused\n", idx); + size =3D sysfs_emit(buf, "addr_cmp[%i] unused\n", idx); } return size; } @@ -1350,7 +1349,7 @@ static ssize_t vinst_pe_cmp_start_stop_show(struct de= vice *dev, if (!drvdata->nr_pe_cmp) return -EINVAL; val =3D config->vipcssctlr; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t vinst_pe_cmp_start_stop_store(struct device *dev, struct device_attribute *attr, @@ -1381,7 +1380,7 @@ static ssize_t seq_idx_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->seq_idx; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t seq_idx_store(struct device *dev, @@ -1417,7 +1416,7 @@ static ssize_t seq_state_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->seq_state; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t seq_state_store(struct device *dev, @@ -1451,7 +1450,7 @@ static ssize_t seq_event_show(struct device *dev, idx =3D config->seq_idx; val =3D config->seq_ctrl[idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t seq_event_store(struct device *dev, @@ -1484,7 +1483,7 @@ static ssize_t seq_reset_event_show(struct device *de= v, struct etmv4_config *config =3D &drvdata->config; val =3D config->seq_rst; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t seq_reset_event_store(struct device *dev, @@ -1514,7 +1513,7 @@ static ssize_t cntr_idx_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->cntr_idx; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t cntr_idx_store(struct device *dev, @@ -1554,7 +1553,7 @@ static ssize_t cntrldvr_show(struct device *dev, idx =3D config->cntr_idx; val =3D config->cntrldvr[idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t cntrldvr_store(struct device *dev, @@ -1592,7 +1591,7 @@ static ssize_t cntr_val_show(struct device *dev, idx =3D config->cntr_idx; val =3D config->cntr_val[idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t cntr_val_store(struct device *dev, @@ -1630,7 +1629,7 @@ static ssize_t cntr_ctrl_show(struct device *dev, idx =3D config->cntr_idx; val =3D config->cntr_ctrl[idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t cntr_ctrl_store(struct device *dev, @@ -1662,7 +1661,7 @@ static ssize_t res_idx_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->res_idx; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t res_idx_store(struct device *dev, @@ -1706,7 +1705,7 @@ static ssize_t res_ctrl_show(struct device *dev, idx =3D config->res_idx; val =3D config->res_ctrl[idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t res_ctrl_store(struct device *dev, @@ -1744,7 +1743,7 @@ static ssize_t sshot_idx_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->ss_idx; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t sshot_idx_store(struct device *dev, @@ -1778,7 +1777,7 @@ static ssize_t sshot_ctrl_show(struct device *dev, spin_lock(&drvdata->spinlock); val =3D config->ss_ctrl[config->ss_idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t sshot_ctrl_store(struct device *dev, @@ -1813,7 +1812,7 @@ static ssize_t sshot_status_show(struct device *dev, spin_lock(&drvdata->spinlock); val =3D config->ss_status[config->ss_idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static DEVICE_ATTR_RO(sshot_status); @@ -1828,7 +1827,7 @@ static ssize_t sshot_pe_ctrl_show(struct device *dev, spin_lock(&drvdata->spinlock); val =3D config->ss_pe_cmp[config->ss_idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t sshot_pe_ctrl_store(struct device *dev, @@ -1862,7 +1861,7 @@ static ssize_t ctxid_idx_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->ctxid_idx; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t ctxid_idx_store(struct device *dev, @@ -1909,7 +1908,7 @@ static ssize_t ctxid_pid_show(struct device *dev, idx =3D config->ctxid_idx; val =3D (unsigned long)config->ctxid_pid[idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t ctxid_pid_store(struct device *dev, @@ -1970,7 +1969,7 @@ static ssize_t ctxid_masks_show(struct device *dev, val1 =3D config->ctxid_mask0; val2 =3D config->ctxid_mask1; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx %#lx\n", val1, val2); + return sysfs_emit(buf, "%#lx %#lx\n", val1, val2); } static ssize_t ctxid_masks_store(struct device *dev, @@ -2088,7 +2087,7 @@ static ssize_t vmid_idx_show(struct device *dev, struct etmv4_config *config =3D &drvdata->config; val =3D config->vmid_idx; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t vmid_idx_store(struct device *dev, @@ -2133,7 +2132,7 @@ static ssize_t vmid_val_show(struct device *dev, spin_lock(&drvdata->spinlock); val =3D (unsigned long)config->vmid_val[config->vmid_idx]; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t vmid_val_store(struct device *dev, @@ -2185,7 +2184,7 @@ static ssize_t vmid_masks_show(struct device *dev, val1 =3D config->vmid_mask0; val2 =3D config->vmid_mask1; spin_unlock(&drvdata->spinlock); - return scnprintf(buf, PAGE_SIZE, "%#lx %#lx\n", val1, val2); + return sysfs_emit(buf, "%#lx %#lx\n", val1, val2); } static ssize_t vmid_masks_store(struct device *dev, @@ -2301,8 +2300,7 @@ static ssize_t cpu_show(struct device *dev, struct etmv4_drvdata *drvdata =3D dev_get_drvdata(dev->parent); val =3D drvdata->cpu; - return scnprintf(buf, PAGE_SIZE, "%d\n", val); - + return sysfs_emit(buf, "%d\n", val); } static DEVICE_ATTR_RO(cpu); @@ -2441,7 +2439,7 @@ static ssize_t coresight_etm4x_reg_show(struct device= *dev, val =3D etmv4_cross_read(drvdata, offset); pm_runtime_put_sync(dev->parent); - return scnprintf(buf, PAGE_SIZE, "0x%x\n", val); + return sysfs_emit(buf, "0x%x\n", val); } static inline bool diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracin= g/coresight/coresight-stm.c index 463f449cfb79..3a1b07217932 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -466,7 +466,7 @@ static ssize_t hwevent_enable_show(struct device *dev, struct stm_drvdata *drvdata =3D dev_get_drvdata(dev->parent); unsigned long val =3D drvdata->stmheer; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t hwevent_enable_store(struct device *dev, @@ -495,7 +495,7 @@ static ssize_t hwevent_select_show(struct device *dev, struct stm_drvdata *drvdata =3D dev_get_drvdata(dev->parent); unsigned long val =3D drvdata->stmhebsr; - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t hwevent_select_store(struct device *dev, @@ -530,7 +530,7 @@ static ssize_t port_select_show(struct device *dev, spin_unlock(&drvdata->spinlock); } - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t port_select_store(struct device *dev, @@ -577,7 +577,7 @@ static ssize_t port_enable_show(struct device *dev, spin_unlock(&drvdata->spinlock); } - return scnprintf(buf, PAGE_SIZE, "%#lx\n", val); + return sysfs_emit(buf, "%#lx\n", val); } static ssize_t port_enable_store(struct device *dev, diff --git a/drivers/hwtracing/coresight/coresight-syscfg-configfs.c b/driv= ers/hwtracing/coresight/coresight-syscfg-configfs.c index 433ede94dd63..20effbd5fb80 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg-configfs.c +++ b/drivers/hwtracing/coresight/coresight-syscfg-configfs.c @@ -29,7 +29,7 @@ static ssize_t cscfg_cfg_description_show(struct config_i= tem *item, char *page) struct cscfg_fs_config *fs_config =3D container_of(to_config_group(item), struct cscfg_fs_config, group); - return scnprintf(page, PAGE_SIZE, "%s", fs_config->config_desc->descripti= on); + return sysfs_emit(page, "%s", fs_config->config_desc->description); } CONFIGFS_ATTR_RO(cscfg_cfg_, description); @@ -42,8 +42,7 @@ static ssize_t cscfg_cfg_feature_refs_show(struct config_= item *item, char *page) int i; for (i =3D 0; i < config_desc->nr_feat_refs; i++) - ch_used +=3D scnprintf(page + ch_used, PAGE_SIZE - ch_used, - "%s\n", config_desc->feat_ref_names[i]); + ch_used +=3D sysfs_emit_at(page, ch_used, "%s\n", config_desc->feat_ref_= names[i]); return ch_used; } CONFIGFS_ATTR_RO(cscfg_cfg_, feature_refs); @@ -75,14 +74,14 @@ static ssize_t cscfg_cfg_values_show(struct config_item= *item, char *page) for (i =3D 0; i < config_desc->nr_feat_refs; i++) { feat_desc =3D cscfg_get_named_feat_desc(config_desc->feat_ref_names[i]); for (j =3D 0; j < feat_desc->nr_params; j++) { - used +=3D scnprintf(page + used, PAGE_SIZE - used, + used +=3D sysfs_emit_at(page, used, "%s.%s =3D 0x%llx ", feat_desc->name, feat_desc->params_desc[j].name, config_desc->presets[val_idx++]); } } - used +=3D scnprintf(page + used, PAGE_SIZE - used, "\n"); + used +=3D sysfs_emit_at(page, used, "\n"); return used; } @@ -93,7 +92,7 @@ static ssize_t cscfg_cfg_enable_show(struct config_item *= item, char *page) struct cscfg_fs_config *fs_config =3D container_of(to_config_group(item), struct cscfg_fs_config, group); - return scnprintf(page, PAGE_SIZE, "%d\n", fs_config->active); + return sysfs_emit(page, "%d\n", fs_config->active); } static ssize_t cscfg_cfg_enable_store(struct config_item *item, @@ -121,7 +120,7 @@ static ssize_t cscfg_cfg_preset_show(struct config_item= *item, char *page) struct cscfg_fs_config *fs_config =3D container_of(to_config_group(item), struct cscfg_fs_config, group); - return scnprintf(page, PAGE_SIZE, "%d\n", fs_config->preset); + return sysfs_emit(page, "%d\n", fs_config->preset); } static ssize_t cscfg_cfg_preset_store(struct config_item *item, @@ -233,7 +232,7 @@ static ssize_t cscfg_feat_description_show(struct confi= g_item *item, char *page) struct cscfg_fs_feature *fs_feat =3D container_of(to_config_group(item), struct cscfg_fs_feature, group); - return scnprintf(page, PAGE_SIZE, "%s", fs_feat->feat_desc->description); + return sysfs_emit(page, "%s", fs_feat->feat_desc->description); } CONFIGFS_ATTR_RO(cscfg_feat_, description); @@ -245,12 +244,12 @@ static ssize_t cscfg_feat_matches_show(struct config_= item *item, char *page) int used =3D 0; if (match_flags & CS_CFG_MATCH_CLASS_SRC_ALL) - used =3D scnprintf(page, PAGE_SIZE, "SRC_ALL "); + used =3D sysfs_emit(page, "SRC_ALL "); if (match_flags & CS_CFG_MATCH_CLASS_SRC_ETM4) - used +=3D scnprintf(page + used, PAGE_SIZE - used, "SRC_ETMV4 "); + used +=3D sysfs_emit_at(page, used, "SRC_ETMV4 "); - used +=3D scnprintf(page + used, PAGE_SIZE - used, "\n"); + used +=3D sysfs_emit_at(page, used, "\n"); return used; } CONFIGFS_ATTR_RO(cscfg_feat_, matches); @@ -260,7 +259,7 @@ static ssize_t cscfg_feat_nr_params_show(struct config_= item *item, char *page) struct cscfg_fs_feature *fs_feat =3D container_of(to_config_group(item), struct cscfg_fs_feature, group); - return scnprintf(page, PAGE_SIZE, "%d\n", fs_feat->feat_desc->nr_params); + return sysfs_emit(page, "%d\n", fs_feat->feat_desc->nr_params); } CONFIGFS_ATTR_RO(cscfg_feat_, nr_params); @@ -283,7 +282,7 @@ static ssize_t cscfg_param_value_show(struct config_ite= m *item, char *page) struct cscfg_fs_param, group); u64 value =3D param_item->feat_desc->params_desc[param_item->param_idx].v= alue; - return scnprintf(page, PAGE_SIZE, "0x%llx\n", value); + return sysfs_emit(page, "0x%llx\n", value); } static ssize_t cscfg_param_value_store(struct config_item *item, --=20 2.25.1