Commit 3f03b649 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Miguel Ojeda

auxdisplay: charlcd: Reuse hex_to_bin() instead of custom code

hex_to_bin() may be used to convert hexdecimal digit to its binary
representation.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
parent 9cb1fd0e
...@@ -485,24 +485,19 @@ static inline int handle_lcd_special_code(struct charlcd *lcd) ...@@ -485,24 +485,19 @@ static inline int handle_lcd_special_code(struct charlcd *lcd)
shift = 0; shift = 0;
value = 0; value = 0;
while (*esc && cgoffset < 8) { while (*esc && cgoffset < 8) {
int half;
shift ^= 4; shift ^= 4;
if (*esc >= '0' && *esc <= '9') {
value |= (*esc - '0') << shift; half = hex_to_bin(*esc++);
} else if (*esc >= 'A' && *esc <= 'F') { if (half < 0)
value |= (*esc - 'A' + 10) << shift;
} else if (*esc >= 'a' && *esc <= 'f') {
value |= (*esc - 'a' + 10) << shift;
} else {
esc++;
continue; continue;
}
value |= half << shift;
if (shift == 0) { if (shift == 0) {
cgbytes[cgoffset++] = value; cgbytes[cgoffset++] = value;
value = 0; value = 0;
} }
esc++;
} }
lcd->ops->write_cmd(lcd, LCD_CMD_SET_CGRAM_ADDR | (cgaddr * 8)); lcd->ops->write_cmd(lcd, LCD_CMD_SET_CGRAM_ADDR | (cgaddr * 8));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment