Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: throw away custom hex digit methods

Recent kernel has common method to convert hex digit to its value.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
e644814a a5cc8049

+5 -15
+3 -2
drivers/usb/atm/ueagle-atm.c
··· 67 67 #include <linux/mutex.h> 68 68 #include <linux/freezer.h> 69 69 #include <linux/slab.h> 70 + #include <linux/kernel.h> 70 71 71 72 #include <asm/unaligned.h> 72 73 ··· 2437 2436 2438 2437 /* Retrieve the device End System Identifier (MAC) */ 2439 2438 2440 - #define htoi(x) (isdigit(x) ? x-'0' : toupper(x)-'A'+10) 2441 2439 static int uea_getesi(struct uea_softc *sc, u_char * esi) 2442 2440 { 2443 2441 unsigned char mac_str[2 * ETH_ALEN + 1]; ··· 2447 2447 return 1; 2448 2448 2449 2449 for (i = 0; i < ETH_ALEN; i++) 2450 - esi[i] = htoi(mac_str[2 * i]) * 16 + htoi(mac_str[2 * i + 1]); 2450 + esi[i] = hex_to_bin(mac_str[2 * i]) * 16 + 2451 + hex_to_bin(mac_str[2 * i + 1]); 2451 2452 2452 2453 return 0; 2453 2454 }
+2 -13
drivers/usb/gadget/u_ether.c
··· 704 704 module_param(host_addr, charp, S_IRUGO); 705 705 MODULE_PARM_DESC(host_addr, "Host Ethernet Address"); 706 706 707 - 708 - static u8 __init nibble(unsigned char c) 709 - { 710 - if (isdigit(c)) 711 - return c - '0'; 712 - c = toupper(c); 713 - if (isxdigit(c)) 714 - return 10 + c - 'A'; 715 - return 0; 716 - } 717 - 718 707 static int get_ether_addr(const char *str, u8 *dev_addr) 719 708 { 720 709 if (str) { ··· 714 725 715 726 if ((*str == '.') || (*str == ':')) 716 727 str++; 717 - num = nibble(*str++) << 4; 718 - num |= (nibble(*str++)); 728 + num = hex_to_bin(*str++) << 4; 729 + num |= hex_to_bin(*str++); 719 730 dev_addr [i] = num; 720 731 } 721 732 if (is_valid_ether_addr(dev_addr))