From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>,
linux-kernel@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1] auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code
Date: Mon, 18 May 2020 22:36:17 +0300 [thread overview]
Message-ID: <20200518193617.74548-1-andriy.shevchenko@linux.intel.com> (raw)
hex_to_bin() may be used to convert hexdecimal digit to its binary
representation.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/auxdisplay/charlcd.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
index d58278ae9e4a..5aee0f546351 100644
--- a/drivers/auxdisplay/charlcd.c
+++ b/drivers/auxdisplay/charlcd.c
@@ -485,24 +485,19 @@ static inline int handle_lcd_special_code(struct charlcd *lcd)
shift = 0;
value = 0;
while (*esc && cgoffset < 8) {
+ int half;
+
shift ^= 4;
- if (*esc >= '0' && *esc <= '9') {
- value |= (*esc - '0') << shift;
- } else if (*esc >= 'A' && *esc <= 'F') {
- value |= (*esc - 'A' + 10) << shift;
- } else if (*esc >= 'a' && *esc <= 'f') {
- value |= (*esc - 'a' + 10) << shift;
- } else {
- esc++;
+
+ half = hex_to_bin(*esc++);
+ if (half < 0)
continue;
- }
+ value |= half << shift;
if (shift == 0) {
cgbytes[cgoffset++] = value;
value = 0;
}
-
- esc++;
}
lcd->ops->write_cmd(lcd, LCD_CMD_SET_CGRAM_ADDR | (cgaddr * 8));
--
2.26.2
next reply other threads:[~2020-05-18 19:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-18 19:36 Andy Shevchenko [this message]
2020-05-29 21:48 ` [PATCH v1] auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code Miguel Ojeda
2020-08-06 9:56 ` Andy Shevchenko
2020-08-06 14:20 ` Miguel Ojeda
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=20200518193617.74548-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
/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