diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-08-07 03:09:34 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-08-07 03:09:34 +0200 |
commit | ed35832648b5c22ce39fe9c476065389c6f330ef (patch) | |
tree | ac0b11553dbe6d6d0bb54166a0b6022a2ffb32ee /drivers/auxdisplay | |
parent | Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi (diff) | |
parent | auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code (diff) | |
download | linux-ed35832648b5c22ce39fe9c476065389c6f330ef.tar.xz linux-ed35832648b5c22ce39fe9c476065389c6f330ef.zip |
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
Diffstat (limited to 'drivers/auxdisplay')
-rw-r--r-- | drivers/auxdisplay/charlcd.c | 17 |
1 files 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)); |