From nobody Sun Feb 8 11:45:03 2026 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 943092475E3 for ; Sat, 20 Dec 2025 22:31:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766269871; cv=none; b=Tj9ooe6G8kvLrqCXuMjn8Syfbz92sU2KxG611pTcL0vtf3uysdLMwaIHIh5krQ4tW0hNMUXOlNA51RmuB3G6wkbC9rMgYYB3vWc8gfyzYoJGLRva3k6s9dEmZzgRTwDd7CZJDLp8cLIrbR7A9zGjpfihPeDtvwvKJzHIypt5Qd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766269871; c=relaxed/simple; bh=kV63Zh38H+VacC8DXVV2Z2Ta6d9kCNbdvI6mFsSmHCc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=m7HfveN9MVXDMgX1Tq/fXSbeaEAmlnTPvQ8ldZk8ts5n0cis9a3ki4Rrxdym3UyTNZZ49Glv32q0XFwh/DEFKk7emMZf7/FnM6sFTI5voWe+W5LdT7+LL0tNU3CRmj98VMBVygiXpVN9ojTg3VjED6f7MVSock5oMYmuvh0dgPA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=eYuVl2YJ; arc=none smtp.client-ip=95.215.58.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="eYuVl2YJ" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1766269864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ATSohVrDsUPFERPnSjtnwMUfGmihgrPoXzJtDALVRVo=; b=eYuVl2YJOWEt9T14aR0Rf4ggxeiqN6+YhJSqikZmgJaV+ArxXWxB+Y5YVwVkANx5njkdrk N4t0FQ6aohZAQdlWVYInxiRWwifpGo9PYn+f+1eCJriWRfDCp5rXhSwISeCP6cQl80rRm9 yQLlEW+4IMwQ8priDYppR/VL/uCX2b8= From: Thorsten Blum To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Srinivas Pandruvada , Ingo Molnar , "Peter Zijlstra (Intel)" , "Xin Li (Intel)" Cc: Thorsten Blum , "Rafael J. Wysocki" , Dave Hansen , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] thermal: intel: int340x: Use sysfs_emit{_at} in sysfs show functions Date: Sat, 20 Dec 2025 23:30:11 +0100 Message-ID: <20251220223026.125678-1-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Replace sprintf() with sysfs_emit() and sysfs_emit_at() in sysfs show functions. sysfs_emit() and sysfs_emit_at() are preferred to format sysfs output as it provides better bounds checking. Signed-off-by: Thorsten Blum Reviewed-by: Srinivas Pandruvada --- .../intel/int340x_thermal/processor_thermal_device.c | 5 +++-- .../intel/int340x_thermal/processor_thermal_rfim.c | 9 +++++---- .../intel/int340x_thermal/processor_thermal_wt_req.c | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device= .c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c index 48e7849d4816..f80dbe2ca7e4 100644 --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include "int340x_thermal_zone.h" @@ -23,7 +24,7 @@ static ssize_t power_limit_##index##_##suffix##_show(stru= ct device *dev, \ { \ struct proc_thermal_device *proc_dev =3D dev_get_drvdata(dev); \ \ - return sprintf(buf, "%lu\n",\ + return sysfs_emit(buf, "%lu\n",\ (unsigned long)proc_dev->power_limits[index].suffix * 1000); \ } =20 @@ -143,7 +144,7 @@ static ssize_t tcc_offset_degree_celsius_show(struct de= vice *dev, if (offset < 0) return offset; =20 - return sprintf(buf, "%d\n", offset); + return sysfs_emit(buf, "%d\n", offset); } =20 static ssize_t tcc_offset_degree_celsius_store(struct device *dev, diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c= b/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c index 589a3a71f0c4..bb9398dfa3c1 100644 --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "processor_thermal_device.h" =20 MODULE_IMPORT_NS("INT340X_THERMAL"); @@ -211,9 +212,9 @@ static ssize_t suffix##_show(struct device *dev,\ ret =3D (reg_val >> mmio_regs[ret].shift) & mmio_regs[ret].mask;\ err =3D get_mapped_string(mapping, attr->attr.name, ret, &str);\ if (!err)\ - return sprintf(buf, "%s\n", str);\ + return sysfs_emit(buf, "%s\n", str);\ if (err =3D=3D -EOPNOTSUPP)\ - return sprintf(buf, "%u\n", ret);\ + return sysfs_emit(buf, "%u\n", ret);\ return err;\ } =20 @@ -398,7 +399,7 @@ static ssize_t rfi_restriction_show(struct device *dev, if (ret) return ret; =20 - return sprintf(buf, "%llu\n", resp); + return sysfs_emit(buf, "%llu\n", resp); } =20 static ssize_t ddr_data_rate_show(struct device *dev, @@ -413,7 +414,7 @@ static ssize_t ddr_data_rate_show(struct device *dev, if (ret) return ret; =20 - return sprintf(buf, "%llu\n", resp); + return sysfs_emit(buf, "%llu\n", resp); } =20 static DEVICE_ATTR_RW(rfi_restriction); diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req= .c b/drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c index b95810f4a011..2372f5202019 100644 --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c @@ -7,6 +7,7 @@ */ =20 #include +#include #include "processor_thermal_device.h" =20 /* List of workload types */ @@ -28,9 +29,9 @@ static ssize_t workload_available_types_show(struct devic= e *dev, int ret =3D 0; =20 while (workload_types[i] !=3D NULL) - ret +=3D sprintf(&buf[ret], "%s ", workload_types[i++]); + ret +=3D sysfs_emit_at(buf, ret, "%s ", workload_types[i++]); =20 - ret +=3D sprintf(&buf[ret], "\n"); + ret +=3D sysfs_emit_at(buf, ret, "\n"); =20 return ret; } @@ -85,7 +86,7 @@ static ssize_t workload_type_show(struct device *dev, if (cmd_resp > ARRAY_SIZE(workload_types) - 1) return -EINVAL; =20 - return sprintf(buf, "%s\n", workload_types[cmd_resp]); + return sysfs_emit(buf, "%s\n", workload_types[cmd_resp]); } =20 static DEVICE_ATTR_RW(workload_type); --=20 Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4