[PATCH] input: elan_i2c: Add newline to sysfs attribute outputs

Zhongqiu Han posted 1 patch 3 months, 1 week ago
drivers/input/mouse/elan_i2c_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] input: elan_i2c: Add newline to sysfs attribute outputs
Posted by Zhongqiu Han 3 months, 1 week ago
Append newline characters to sysfs_emit() outputs in func min_show() and
max_show(). This aligns with common kernel conventions and improves
readability for userspace tools that expect newline-terminated values.

Signed-off-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
---
 drivers/input/mouse/elan_i2c_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index fee1796da3d0..14b6cfd7a6de 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -861,7 +861,7 @@ static ssize_t min_show(struct device *dev,
 		if (!data->baseline_ready)
 			return -ENODATA;
 
-		return sysfs_emit(buf, "%d", data->min_baseline);
+		return sysfs_emit(buf, "%d\n", data->min_baseline);
 	}
 
 	return -EINTR;
@@ -877,7 +877,7 @@ static ssize_t max_show(struct device *dev,
 		if (!data->baseline_ready)
 			return -ENODATA;
 
-		return sysfs_emit(buf, "%d", data->max_baseline);
+		return sysfs_emit(buf, "%d\n", data->max_baseline);
 	}
 
 	return -EINTR;
-- 
2.43.0
Re: [PATCH] input: elan_i2c: Add newline to sysfs attribute outputs
Posted by Dmitry Torokhov 3 months ago
Hi Zhongqiu,

On Thu, Oct 30, 2025 at 08:34:58PM +0800, Zhongqiu Han wrote:
> Append newline characters to sysfs_emit() outputs in func min_show() and
> max_show(). This aligns with common kernel conventions and improves
> readability for userspace tools that expect newline-terminated values.

This format for this driver was in use for 11 years, and there might be
tools that do not expect newlines. I would rather leave it as is.

Thanks.

-- 
Dmitry
Re: [PATCH] input: elan_i2c: Add newline to sysfs attribute outputs
Posted by Zhongqiu Han 3 months ago
On 11/5/2025 12:55 PM, Dmitry Torokhov wrote:
> Hi Zhongqiu,
> 
> On Thu, Oct 30, 2025 at 08:34:58PM +0800, Zhongqiu Han wrote:
>> Append newline characters to sysfs_emit() outputs in func min_show() and
>> max_show(). This aligns with common kernel conventions and improves
>> readability for userspace tools that expect newline-terminated values.
> 
> This format for this driver was in use for 11 years, and there might be
> tools that do not expect newlines. I would rather leave it as is.
> 
> Thanks.
> 

Hi Dmitry,

Thanks for your review~

Sure, I agree that we should avoid breaking unknown userspace tools.


-- 
Thx and BRs,
Zhongqiu Han