From: "Jean-François Lessard" <jefflessard3@gmail.com>
To: Andy Shevchenko <andy@kernel.org>,
Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/5] auxdisplay: linedisp: display static message when length <= display size
Date: Thu, 18 Sep 2025 08:13:13 -0400 [thread overview]
Message-ID: <20250918121321.116248-4-jefflessard3@gmail.com> (raw)
In-Reply-To: <20250918121321.116248-1-jefflessard3@gmail.com>
Currently, when a message shorter than the display size is written, the
content wraps around (e.g., "123" on a 4-digit display shows "1231")
without scrolling, which is confusing and unintuitive.
Change behavior to display short messages statically with space padding
(e.g. "123 ") while only scrolling messages longer than the display width.
This provides more natural behavior that aligns with user expectations
and current linedisp_display() kernel-doc.
The scroll logic is also consolidated into a helper function for clarity.
No API changes are introduced.
Signed-off-by: Jean-François Lessard <jefflessard3@gmail.com>
---
drivers/auxdisplay/line-display.c | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-display.c
index e44341b1ea22..73e4e77ea4f9 100644
--- a/drivers/auxdisplay/line-display.c
+++ b/drivers/auxdisplay/line-display.c
@@ -36,6 +36,11 @@ static struct linedisp *to_linedisp(struct device *dev)
return container_of(dev, struct linedisp, dev);
}
+static inline bool should_scroll(struct linedisp *linedisp)
+{
+ return linedisp->message_len > linedisp->num_chars && linedisp->scroll_rate;
+}
+
/**
* linedisp_scroll() - scroll the display by a character
* @t: really a pointer to the private data structure
@@ -67,8 +72,7 @@ static void linedisp_scroll(struct timer_list *t)
linedisp->scroll_pos %= linedisp->message_len;
/* rearm the timer */
- if (linedisp->message_len > num_chars && linedisp->scroll_rate)
- mod_timer(&linedisp->timer, jiffies + linedisp->scroll_rate);
+ mod_timer(&linedisp->timer, jiffies + linedisp->scroll_rate);
}
/**
@@ -118,8 +122,16 @@ static int linedisp_display(struct linedisp *linedisp, const char *msg,
linedisp->message_len = count;
linedisp->scroll_pos = 0;
- /* update the display */
- linedisp_scroll(&linedisp->timer);
+ if (should_scroll(linedisp)) {
+ /* display scrolling message */
+ linedisp_scroll(&linedisp->timer);
+ } else {
+ /* display static message */
+ memset(linedisp->buf, ' ', linedisp->num_chars);
+ memcpy(linedisp->buf, linedisp->message,
+ umin(linedisp->num_chars, linedisp->message_len));
+ linedisp->ops->update(linedisp);
+ }
return 0;
}
@@ -186,12 +198,12 @@ static ssize_t scroll_step_ms_store(struct device *dev,
if (err)
return err;
+ timer_delete_sync(&linedisp->timer);
+
linedisp->scroll_rate = msecs_to_jiffies(ms);
- if (linedisp->message && linedisp->message_len > linedisp->num_chars) {
- timer_delete_sync(&linedisp->timer);
- if (linedisp->scroll_rate)
- linedisp_scroll(&linedisp->timer);
- }
+
+ if (should_scroll(linedisp))
+ linedisp_scroll(&linedisp->timer);
return count;
}
--
2.43.0
next prev parent reply other threads:[~2025-09-18 12:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 12:13 [PATCH v2 0/5] auxdisplay: linedisp: support attribute attachment to auxdisplay devices Jean-François Lessard
2025-09-18 12:13 ` [PATCH v2 1/5] docs: ABI: auxdisplay: document linedisp library sysfs attributes Jean-François Lessard
2025-09-18 12:13 ` [PATCH v2 2/5] auxdisplay: linedisp: encapsulate container_of usage within to_linedisp Jean-François Lessard
2025-09-18 12:13 ` Jean-François Lessard [this message]
2025-09-18 12:13 ` [PATCH v2 4/5] auxdisplay: linedisp: add num_chars sysfs attribute Jean-François Lessard
2025-09-18 12:13 ` [PATCH v2 5/5] auxdisplay: linedisp: support attribute attachment to auxdisplay devices Jean-François Lessard
2025-09-26 14:31 ` [PATCH v2 0/5] " Jean-François Lessard
2025-10-09 11:19 ` Jean-François Lessard
2025-10-15 16:47 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250918121321.116248-4-jefflessard3@gmail.com \
--to=jefflessard3@gmail.com \
--cc=andy@kernel.org \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®