Minor cleanup for auxdisplay:

- Reuse hex_to_bin() instead of custom code (Andy Shevchenko)
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEPjU5OPd5QIZ9jqqOGXyLc2htIW0FAl8sTtkACgkQGXyLc2ht
 IW1tmRAAivgSzwjP2LH/gx95WySv3+hfcmqkG3CvnSGPKabDBm4r6k3VB+3ooqEN
 qdyHLIa6mLOBfM3VUV9UK3DW9ETnLM6dochScf2FajLoJGVNm9B+V2YZa6v5crLy
 FhOD+R/mQsPrABHTOH6UyV9tttiPkmSBB/E1lKih5cazdDbhudHWnLsWUFbVU0B2
 Ph1Sz+QM4yl94UO8/uek+KUYRkwSATWg1Cb/L6yw+7n/jGn5P1Uz8oZLM5C2r7Wx
 gJzQEvUzrxpCB68qkd0DEGAUY0KjCzSsFSwOHeIBa6smXq3nXlXoYqBIxp5uWuFv
 7vnm6dDl0H0d3i7lvX5M7CIj3lTrk4xQSA+QQifRbRLI4wpLRbHPG64fsG8i1+YA
 D+fOibTM03VffFX98Tij+KYDxyyHm90iiBRPsh7zAW0YpbdiyjgtkYaR6Hpi3+A9
 BhbCve17D5eGvqhIqjgtWwt8o0JNl/KFQDu9YyspiZ+XE0dQtKasyT1Rx6xSTk2T
 uS7lX+mQolmZHPpqV+c5o1ekJDbWzj5VncNUbVFiMq+IMnh9PSB03YBkRuovvuW0
 cAmErzt0JkA+bzNInkmwc+ylbZBVSwqSET+HoziAEgUQoSzku7jGM+/NsLdNpEVf
 VlVndpB+3N9riijmylQ+r8G0brl1LbNy/qPCIsabyE9hLMSaIk0=
 =PZyA
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2020-08-06 18:09:34 -07:00
commit ed35832648
1 changed files with 8 additions and 13 deletions

View File

@ -485,24 +485,19 @@ static inline int handle_lcd_special_code(struct charlcd *lcd)
shift = 0;
value = 0;
while (*esc && cgoffset < 8) {
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++;
continue;
}
int half;
shift ^= 4;
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));