From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Miguel Ojeda <ojeda@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Robin van der Gracht <robin@protonic.nl>,
Paul Burton <paulburton@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH v1 10/15] auxdisplay: linedisp: Provide a small buffer in the struct linedisp
Date: Thu, 8 Feb 2024 18:58:53 +0200 [thread overview]
Message-ID: <20240208165937.2221193-11-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20240208165937.2221193-1-andriy.shevchenko@linux.intel.com>
There is a driver that uses small buffer for the string, when we
add a new one, we may avoid duplication and use one provided by
the line display library. Allow user to skip buffer pointer when
registering a device.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/auxdisplay/line-display.c | 4 ++--
drivers/auxdisplay/line-display.h | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-display.c
index da47fc59f6cb..a3c706e1739d 100644
--- a/drivers/auxdisplay/line-display.c
+++ b/drivers/auxdisplay/line-display.c
@@ -330,8 +330,8 @@ int linedisp_register(struct linedisp *linedisp, struct device *parent,
linedisp->dev.parent = parent;
linedisp->dev.type = &linedisp_type;
linedisp->ops = ops;
- linedisp->buf = buf;
- linedisp->num_chars = num_chars;
+ linedisp->buf = buf ? buf : linedisp->curr;
+ linedisp->num_chars = buf ? num_chars : min(num_chars, LINEDISP_DEFAULT_BUF_SZ);
linedisp->scroll_rate = DEFAULT_SCROLL_RATE;
err = ida_alloc(&linedisp_id, GFP_KERNEL);
diff --git a/drivers/auxdisplay/line-display.h b/drivers/auxdisplay/line-display.h
index 65d782111f53..4c354b8f376e 100644
--- a/drivers/auxdisplay/line-display.h
+++ b/drivers/auxdisplay/line-display.h
@@ -54,12 +54,15 @@ struct linedisp_ops {
void (*update)(struct linedisp *linedisp);
};
+#define LINEDISP_DEFAULT_BUF_SZ 8u
+
/**
* struct linedisp - character line display private data structure
* @dev: the line display device
* @id: instance id of this display
* @timer: timer used to implement scrolling
* @ops: character line display operations
+ * @curr: fallback buffer for the string
* @buf: pointer to the buffer for the string currently displayed
* @message: the full message to display or scroll on the display
* @num_chars: the number of characters that can be displayed
@@ -73,6 +76,7 @@ struct linedisp {
struct timer_list timer;
const struct linedisp_ops *ops;
struct linedisp_map *map;
+ char curr[LINEDISP_DEFAULT_BUF_SZ];
char *buf;
char *message;
unsigned int num_chars;
--
2.43.0.rc1.1.gbec44491f096
next prev parent reply other threads:[~2024-02-08 17:17 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-08 16:58 [PATCH v1 00/15] auxdisplay: linedisp: Clean up and add new driver Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 01/15] auxdisplay: img-ascii-lcd: Make container_of() no-op for struct linedisp Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 02/15] auxdisplay: linedisp: Free allocated resources in ->release() Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 03/15] auxdisplay: linedisp: Use unique number for id Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 04/15] auxdisplay: linedisp: Unshadow error codes in ->store() Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 05/15] auxdisplay: linedisp: Add missing header(s) Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 06/15] auxdisplay: linedisp: Move exported symbols to a namespace Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 07/15] auxdisplay: linedisp: Group line display drivers together Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 08/15] auxdisplay: linedisp: Provide struct linedisp_ops for future extension Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 09/15] auxdisplay: linedisp: Add support for overriding character mapping Andy Shevchenko
2024-02-08 16:58 ` Andy Shevchenko [this message]
2024-02-08 16:58 ` [PATCH v1 11/15] auxdisplay: ht16k33: Move ht16k33_linedisp_ops down Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 12/15] auxdisplay: ht16k33: Switch to use line display character mapping Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 13/15] auxdisplay: ht16k33: Use buffer from struct linedisp Andy Shevchenko
2024-02-08 16:58 ` [PATCH v1 14/15] dt-bindings: auxdisplay: Add Maxim MAX6958/6959 Andy Shevchenko
2024-02-08 17:50 ` Conor Dooley
2024-02-08 18:16 ` Andy Shevchenko
2024-02-08 20:44 ` Conor Dooley
2024-02-09 9:18 ` Krzysztof Kozlowski
2024-02-08 16:58 ` [PATCH v1 15/15] auxdisplay: Add driver for MAX695x 7-segment LED controllers Andy Shevchenko
2024-02-08 17:52 ` [PATCH v1 00/15] auxdisplay: linedisp: Clean up and add new driver Conor Dooley
2024-02-08 18:10 ` Geert Uytterhoeven
2024-02-08 18:49 ` Andy Shevchenko
-- strict thread matches above, loose matches on Subject: below --
2024-02-08 18:47 [resend, PATCH " Andy Shevchenko
2024-02-08 18:48 ` [PATCH v1 10/15] auxdisplay: linedisp: Provide a small buffer in the struct linedisp Andy Shevchenko
2024-02-12 8:25 ` Robin van der Gracht
2024-02-12 11:50 ` Andy Shevchenko
2024-02-12 16:49 ` Andy Shevchenko
2024-02-13 10:53 ` Robin van der Gracht
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=20240208165937.2221193-11-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=paulburton@kernel.org \
--cc=robh@kernel.org \
--cc=robin@protonic.nl \
/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;
as well as URLs for NNTP newsgroup(s).