]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
auxdisplay: linedisp: add num_chars sysfs attribute
authorJean-François Lessard <jefflessard3@gmail.com>
Thu, 18 Sep 2025 12:13:14 +0000 (08:13 -0400)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 15 Oct 2025 16:46:01 +0000 (18:46 +0200)
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>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Documentation/ABI/testing/sysfs-auxdisplay-linedisp
drivers/auxdisplay/line-display.c

index 45cf4e5a2febb281645ecfe0f67284371cb77873..55f1b559e84ebe015d1b837366b9c54c848ea3e5 100644 (file)
@@ -15,6 +15,17 @@ Description:
                  echo "Hello World" > message
                  cat message                   # Returns "Hello World\n"
 
+What:          /sys/.../num_chars
+Date:          November 2025
+KernelVersion: 6.18
+Contact:       Jean-François Lessard <jefflessard3@gmail.com>
+Description:
+               Read-only attribute showing the character width capacity of
+               the line display device. Messages longer than this will scroll.
+
+               Example:
+                 cat num_chars         # Returns "16\n" for 16-char display
+
 What:          /sys/.../scroll_step_ms
 Date:          October 2021
 KernelVersion: 5.16
index 73e4e77ea4f9bdffce0f70e9b5630082a2a0dbc0..7f3e53e2847bb66f6d3c47de2c84110523105ee9 100644 (file)
@@ -178,6 +178,16 @@ static ssize_t message_store(struct device *dev, struct device_attribute *attr,
 
 static DEVICE_ATTR_RW(message);
 
+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 scroll_step_ms_show(struct device *dev,
                                   struct device_attribute *attr, char *buf)
 {
@@ -240,6 +250,7 @@ static DEVICE_ATTR(map_seg14, 0644, map_seg_show, map_seg_store);
 
 static struct attribute *linedisp_attrs[] = {
        &dev_attr_message.attr,
+       &dev_attr_num_chars.attr,
        &dev_attr_scroll_step_ms.attr,
        &dev_attr_map_seg7.attr,
        &dev_attr_map_seg14.attr,