Skip to content

Commit ed35832

Browse files
committed
Merge tag 'auxdisplay-for-linus-v5.9-rc1' of git://github.com/ojeda/linux
Pull auxdisplay update from Miguel Ojeda: "Minor cleanup for auxdisplay: rReuse hex_to_bin() instead of custom code (Andy Shevchenko)" * tag 'auxdisplay-for-linus-v5.9-rc1' of git://github.com/ojeda/linux: auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code
2 parents dfdf16e + 3f03b64 commit ed35832

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

drivers/auxdisplay/charlcd.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -485,24 +485,19 @@ static inline int handle_lcd_special_code(struct charlcd *lcd)
485485
shift = 0;
486486
value = 0;
487487
while (*esc && cgoffset < 8) {
488+
int half;
489+
488490
shift ^= 4;
489-
if (*esc >= '0' && *esc <= '9') {
490-
value |= (*esc - '0') << shift;
491-
} else if (*esc >= 'A' && *esc <= 'F') {
492-
value |= (*esc - 'A' + 10) << shift;
493-
} else if (*esc >= 'a' && *esc <= 'f') {
494-
value |= (*esc - 'a' + 10) << shift;
495-
} else {
496-
esc++;
491+
492+
half = hex_to_bin(*esc++);
493+
if (half < 0)
497494
continue;
498-
}
499495

496+
value |= half << shift;
500497
if (shift == 0) {
501498
cgbytes[cgoffset++] = value;
502499
value = 0;
503500
}
504-
505-
esc++;
506501
}
507502

508503
lcd->ops->write_cmd(lcd, LCD_CMD_SET_CGRAM_ADDR | (cgaddr * 8));

0 commit comments

Comments
 (0)