linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code
@ 2020-05-18 19:36 Andy Shevchenko
  2020-05-29 21:48 ` Miguel Ojeda
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2020-05-18 19:36 UTC (permalink / raw)
  To: Miguel Ojeda Sandonis, linux-kernel; +Cc: Andy Shevchenko

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code
  2020-05-18 19:36 [PATCH v1] auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code Andy Shevchenko
@ 2020-05-29 21:48 ` Miguel Ojeda
  2020-08-06  9:56   ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Miguel Ojeda @ 2020-05-29 21:48 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel

Hi Andy,

On Mon, May 18, 2020 at 9:36 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> hex_to_bin() may be used to convert hexdecimal digit to its binary
> representation.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---

Looks fine to me and the logic is simpler for the `esc` increase too.
Thanks for the cleanup! Were you able to test it, by any chance? I
will queue it up for -rc1.

 (Sidenote: it would be nice if `git patch` allowed for a full-to-full
comparison for patches like this since the unified format is harder to
read; I couldn't find the option from a quick look...).

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code
  2020-05-29 21:48 ` Miguel Ojeda
@ 2020-08-06  9:56   ` Andy Shevchenko
  2020-08-06 14:20     ` Miguel Ojeda
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2020-08-06  9:56 UTC (permalink / raw)
  To: Miguel Ojeda; +Cc: linux-kernel

On Fri, May 29, 2020 at 11:48:53PM +0200, Miguel Ojeda wrote:
> Hi Andy,
> 
> On Mon, May 18, 2020 at 9:36 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > hex_to_bin() may be used to convert hexdecimal digit to its binary
> > representation.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> 
> Looks fine to me and the logic is simpler for the `esc` increase too.
> Thanks for the cleanup! Were you able to test it, by any chance? I
> will queue it up for -rc1.

May I ask which version did you have in mind? Now it's merge window for
v5.9-rc1 and patch is still not there...

>  (Sidenote: it would be nice if `git patch` allowed for a full-to-full
> comparison for patches like this since the unified format is harder to
> read; I couldn't find the option from a quick look...).
> 
> Cheers,
> Miguel

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code
  2020-08-06  9:56   ` Andy Shevchenko
@ 2020-08-06 14:20     ` Miguel Ojeda
  0 siblings, 0 replies; 4+ messages in thread
From: Miguel Ojeda @ 2020-08-06 14:20 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel

Hi Andy,

On Thu, Aug 6, 2020 at 11:56 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> May I ask which version did you have in mind? Now it's merge window for
> v5.9-rc1 and patch is still not there...

Yeah, apologies, sending it during this merge window... :-)

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-06 17:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18 19:36 [PATCH v1] auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code Andy Shevchenko
2020-05-29 21:48 ` Miguel Ojeda
2020-08-06  9:56   ` Andy Shevchenko
2020-08-06 14:20     ` Miguel Ojeda

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).