staging: rtl8188eu: substitute custom hex2bin()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 10 Jul 2014 03:41:21 +0000 (09:11 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Jul 2014 04:07:43 +0000 (21:07 -0700)
Instead of using custom code to convert hexdecinal strings to their binary
represantation let's use kernel's library function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: navin patidar <navin.patidar@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8188eu/core/rtw_ieee80211.c
drivers/staging/rtl8188eu/include/wlan_bssdef.h
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c

index 3eeab2c822bdeadbd2c21700a98061ddcdfc7c19..02bd3b032f12bf18594a6c984eb4f1a0b6e02708 100644 (file)
@@ -1084,11 +1084,6 @@ u8 str_2char2num(u8 hch, u8 lch)
     return (key_char2num(hch) * 10) + key_char2num(lch);
 }
 
-u8 key_2char2num(u8 hch, u8 lch)
-{
-    return (key_char2num(hch) << 4) | key_char2num(lch);
-}
-
 void rtw_macaddr_cfg(u8 *mac_addr)
 {
        u8 mac[ETH_ALEN];
index e70075d586d7dbee15f94305a813abb795e727a2..85e4b9250c005330166066de5b94aeace2d07118 100644 (file)
@@ -340,7 +340,6 @@ struct ndis_802_11_cap {
        struct ndis_802_11_auth_encrypt AuthenticationEncryptionSupported[1];
 };
 
-u8 key_2char2num(u8 hch, u8 lch);
 u8 key_char2num(u8 ch);
 u8 str_2char2num(u8 hch, u8 lch);
 
index 762920643037ab65c694b1fd40450da586a9137c..6402f48bbd1be93dc3b8bd6ed3d21e74941d15f7 100644 (file)
@@ -5855,7 +5855,7 @@ static int rtw_mp_efuse_set(struct net_device *dev,
        struct efuse_hal *pEfuseHal;
 
        u8 ips_mode = 0, lps_mode = 0;
-       u32 i, jj, kk;
+       u32 i;
        u8 *setdata = NULL;
        u8 *ShadowMapBT = NULL;
        u8 *ShadowMapWiFi = NULL;
@@ -5933,8 +5933,11 @@ static int rtw_mp_efuse_set(struct net_device *dev,
                DBG_88E("%s: cnts =%d\n", __func__, cnts);
                DBG_88E("%s: map data =%s\n", __func__, tmp[2]);
 
-               for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2)
-                       setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]);
+               if (hex2bin(setdata, tmp[2], cnts) < 0) {
+                       err = -EINVAL;
+                       goto exit;
+               }
+
                /* Change to check TYPE_EFUSE_MAP_LEN, because 8188E raw 256, logic map over 256. */
                EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size);
                if ((addr+cnts) > max_available_size) {
@@ -5972,8 +5975,10 @@ static int rtw_mp_efuse_set(struct net_device *dev,
                DBG_88E("%s: cnts =%d\n", __func__, cnts);
                DBG_88E("%s: raw data =%s\n", __func__, tmp[2]);
 
-               for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2)
-                       setrawdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]);
+               if (hex2bin(setrawdata, tmp[2], cnts) < 0) {
+                       err = -EINVAL;
+                       goto exit;
+               }
 
                if (rtw_efuse_access(padapter, true, addr, cnts, setrawdata) == _FAIL) {
                        DBG_88E("%s: rtw_efuse_access error!!\n", __func__);
@@ -6008,8 +6013,11 @@ static int rtw_mp_efuse_set(struct net_device *dev,
                DBG_88E("%s: cnts =%d\n", __func__, cnts);
                DBG_88E("%s: MAC address =%s\n", __func__, tmp[1]);
 
-               for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2)
-                       setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]);
+               if (hex2bin(setdata, tmp[1], cnts) < 0) {
+                       err = -EINVAL;
+                       goto exit;
+               }
+
                /* Change to check TYPE_EFUSE_MAP_LEN, because 8188E raw 256, logic map over 256. */
                EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size);
                if ((addr+cnts) > max_available_size) {
@@ -6046,8 +6054,10 @@ static int rtw_mp_efuse_set(struct net_device *dev,
                DBG_88E("%s: cnts =%d\n", __func__, cnts);
                DBG_88E("%s: VID/PID =%s\n", __func__, tmp[1]);
 
-               for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2)
-                       setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]);
+               if (hex2bin(setdata, tmp[1], cnts) < 0) {
+                       err = -EINVAL;
+                       goto exit;
+               }
 
                EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size);
                if ((addr+cnts) > max_available_size) {
@@ -6085,8 +6095,10 @@ static int rtw_mp_efuse_set(struct net_device *dev,
                DBG_88E("%s: cnts =%d\n", __func__, cnts);
                DBG_88E("%s: BT data =%s\n", __func__, tmp[2]);
 
-               for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2)
-                       setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]);
+               if (hex2bin(setdata, tmp[2], cnts) < 0) {
+                       err = -EINVAL;
+                       goto exit;
+               }
 
                EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size);
                if ((addr+cnts) > max_available_size) {
@@ -6119,8 +6131,10 @@ static int rtw_mp_efuse_set(struct net_device *dev,
                DBG_88E("%s: cnts =%d\n", __func__, cnts);
                DBG_88E("%s: BT tmp data =%s\n", __func__, tmp[2]);
 
-               for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2)
-                       pEfuseHal->fakeBTEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]);
+               if (hex2bin(pEfuseHal->fakeBTEfuseModifiedMap + addr, tmp[2], cnts) < 0) {
+                       err = -EINVAL;
+                       goto exit;
+               }
        } else if (strcmp(tmp[0], "wldumpfake") == 0) {
                if (rtw_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN,  pEfuseHal->fakeEfuseModifiedMap) == _SUCCESS) {
                        DBG_88E("%s: BT read all map success\n", __func__);
@@ -6173,8 +6187,10 @@ static int rtw_mp_efuse_set(struct net_device *dev,
                DBG_88E("%s: cnts =%d\n", __func__, cnts);
                DBG_88E("%s: map tmp data =%s\n", __func__, tmp[2]);
 
-               for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2)
-                       pEfuseHal->fakeEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]);
+               if (hex2bin(pEfuseHal->fakeEfuseModifiedMap + addr, tmp[2], cnts) < 0) {
+                       err = -EINVAL;
+                       goto exit;
+               }
        }
 
 exit: