[PATCH 3/5] auxdisplay: linedisp: add num_chars sysfs attribute

Jean-François Lessard posted 5 patches 1 month ago
There is a newer version of this series
[PATCH 3/5] auxdisplay: linedisp: add num_chars sysfs attribute
Posted by Jean-François Lessard 1 month ago
Add a read-only 'num_chars' sysfs attribute to report display digit count.

The num_chars attribute provides essential capability information to
userspace applications that need to know display dimensions before writing
messages, complementing the existing message and scroll controls.

No functional changes to existing behavior.

Signed-off-by: Jean-François Lessard <jefflessard3@gmail.com>
---
 drivers/auxdisplay/line-display.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-display.c
index ea23c43bb..abeed8812 100644
--- a/drivers/auxdisplay/line-display.c
+++ b/drivers/auxdisplay/line-display.c
@@ -211,6 +211,16 @@ static ssize_t scroll_step_ms_store(struct device *dev,
 
 static DEVICE_ATTR_RW(scroll_step_ms);
 
+static ssize_t num_chars_show(struct device *dev, struct device_attribute *attr,
+			      char *buf)
+{
+	struct linedisp *linedisp = to_linedisp(dev);
+
+	return sysfs_emit(buf, "%u\n", linedisp->num_chars);
+}
+
+static DEVICE_ATTR_RO(num_chars);
+
 static ssize_t map_seg_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct linedisp *linedisp = to_linedisp(dev);
@@ -242,6 +252,7 @@ static DEVICE_ATTR(map_seg14, 0644, map_seg_show, map_seg_store);
 static struct attribute *linedisp_attrs[] = {
 	&dev_attr_message.attr,
 	&dev_attr_scroll_step_ms.attr,
+	&dev_attr_num_chars.attr,
 	&dev_attr_map_seg7.attr,
 	&dev_attr_map_seg14.attr,
 	NULL
-- 
2.43.0

Re: [PATCH 3/5] auxdisplay: linedisp: add num_chars sysfs attribute
Posted by Andy Shevchenko 1 month ago
On Sun, Aug 31, 2025 at 10:00:27PM -0400, Jean-François Lessard wrote:
> Add a read-only 'num_chars' sysfs attribute to report display digit count.
> 
> The num_chars attribute provides essential capability information to
> userspace applications that need to know display dimensions before writing
> messages, complementing the existing message and scroll controls.

...

>  	&dev_attr_message.attr,
>  	&dev_attr_scroll_step_ms.attr,
> +	&dev_attr_num_chars.attr,
>  	&dev_attr_map_seg7.attr,
>  	&dev_attr_map_seg14.attr,

It looks like we have two groups of the attributes here, can we keep the upper
one sorted? (Put the new attribute one line above?)

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH 3/5] auxdisplay: linedisp: add num_chars sysfs attribute
Posted by Jean-François Lessard 1 month ago
Le 2 septembre 2025 06 h 04 min 34 s HAE, Andy Shevchenko <andriy.shevchenko@intel.com> a écrit :
>On Sun, Aug 31, 2025 at 10:00:27PM -0400, Jean-François Lessard wrote:
>> Add a read-only 'num_chars' sysfs attribute to report display digit count.
>> 
>> The num_chars attribute provides essential capability information to
>> userspace applications that need to know display dimensions before writing
>> messages, complementing the existing message and scroll controls.
>
>...
>
>>  	&dev_attr_message.attr,
>>  	&dev_attr_scroll_step_ms.attr,
>> +	&dev_attr_num_chars.attr,
>>  	&dev_attr_map_seg7.attr,
>>  	&dev_attr_map_seg14.attr,
>
>It looks like we have two groups of the attributes here, can we keep the upper
>one sorted? (Put the new attribute one line above?)
>

Acknowledged. I will sort the attributes order accordingly.