diff options
author | Michael Straube <straube.linux@gmail.com> | 2018-06-27 19:36:49 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-06-28 22:46:01 +0900 |
commit | a50d971c08ea72506d5f986fb7df9a5909c3997c (patch) | |
tree | 74edb995181a8760a8008fc53afbee73807512c8 /drivers/staging/rtl8723bs/core/rtw_ieee80211.c | |
parent | 9579ba6e5d4f2e823a16f0f99ba755cb345c3605 (diff) | |
download | linux-a50d971c08ea72506d5f986fb7df9a5909c3997c.tar.bz2 |
staging: rtl8723bs: use mac_pton() in rtw_macaddr_cfg()
Use the mac_pton() helper to convert the mac address string.
The functions key_char2num() and key_2char2num() are not used
anywhere else and can be removed.
This also has the benefit of validating the input since mac_pton()
returns false if the string is not valid.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/rtl8723bs/core/rtw_ieee80211.c')
-rw-r--r-- | drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 8af4a89e632f..8e0025e1ff14 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -1137,25 +1137,6 @@ ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len, } -static u8 key_char2num(u8 ch); -static u8 key_char2num(u8 ch) -{ - if ((ch >= '0') && (ch <= '9')) - return ch - '0'; - else if ((ch >= 'a') && (ch <= 'f')) - return ch - 'a' + 10; - else if ((ch >= 'A') && (ch <= 'F')) - return ch - 'A' + 10; - else - return 0xff; -} - -u8 key_2char2num(u8 hch, u8 lch); -u8 key_2char2num(u8 hch, u8 lch) -{ - return ((key_char2num(hch) << 4) | key_char2num(lch)); -} - void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr) { u8 mac[ETH_ALEN]; @@ -1166,14 +1147,11 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr) if (!mac_addr) return; - if (rtw_initmac) { /* Users specify the mac address */ - int jj, kk; - - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) { - mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk + 1]); - } + if (rtw_initmac && mac_pton(rtw_initmac, mac)) { + /* Users specify the mac address */ ether_addr_copy(mac_addr, mac); - } else{ /* Use the mac address stored in the Efuse */ + } else { + /* Use the mac address stored in the Efuse */ ether_addr_copy(mac, mac_addr); } |