auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code
PATCH 1/1 auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code
hex_to_bin() may be used to convert hexdecimal digit to its binary representation.
--- drivers/auxdisplay/charlcd.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/auxdisplay/charlcd.c +6 -11
@@ -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 ));
Signature · 1 line
2.26.2
Hi Andy,
Quoted 6 lines · Andy Shevchenko
hex_to_bin()may be used to convert hexdecimal digit to its binary representation.Signed-off-by Andy Shevchenko <[email protected]>---
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
Quoted 8 lines · Miguel Ojeda
Hi Andy,
Quoted 4 lines · Andy Shevchenko
hex_to_bin()may be used to convert hexdecimal digit to its binary representation.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Andy Shevchenko <[email protected]>---
Looks fine to me and the logic is simpler for the
escincrease 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...
Quoted 6 lines
(Sidenote: it would be nice if
git patchallowed 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
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi Andy,
Quoted 3 lines · Andy Shevchenko
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