staging: rtl8723au: Clean up error code mess in rtw_efuse.c
authorJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 16 May 2014 08:04:29 +0000 (10:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 May 2014 18:34:28 +0000 (11:34 -0700)
Use int to return error codes, and avoid mixing and matching
true/false with _FAIL/_SUCCESS at random.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_efuse.c
drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
drivers/staging/rtl8723au/include/rtw_efuse.h

index 8ba5166a25592c8aa3062d6cb23413d2f149cd06..61fef36ab35af092a108ca9dbe64032945072092 100644 (file)
@@ -403,11 +403,11 @@ EFUSE_Write1Byte(
 }/* EFUSE_Write1Byte */
 
 /*  11/16/2008 MH Read one byte from real Efuse. */
-u8
+int
 efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data)
 {
        u8      tmpidx = 0;
-       u8      bResult;
+       int     bResult;
 
        /*  -----------------e-fuse reg ctrl --------------------------------- */
        /* address */
@@ -421,20 +421,20 @@ efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data)
                tmpidx++;
        if (tmpidx < 100) {
                *data = rtw_read8(pAdapter, EFUSE_CTRL);
-               bResult = true;
+               bResult = _SUCCESS;
        } else {
                *data = 0xff;
-               bResult = false;
+               bResult = _FAIL;
        }
        return bResult;
 }
 
 /*  11/16/2008 MH Write one byte to reald Efuse. */
-u8
+int
 efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data)
 {
        u8      tmpidx = 0;
-       u8      bResult;
+       int     bResult;
 
        /* RT_TRACE(COMP_EFUSE, DBG_LOUD, ("Addr = %x Data =%x\n", addr, data)); */
 
@@ -453,14 +453,10 @@ efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data)
                tmpidx++;
        }
 
-       if (tmpidx<100)
-       {
-               bResult = true;
-       }
+       if (tmpidx < 100)
+               bResult = _SUCCESS;
        else
-       {
-               bResult = false;
-       }
+               bResult = _FAIL;
 
        return bResult;
 }
@@ -509,12 +505,12 @@ efuse_WordEnableDataRead23a(u8    word_en,
        }
 }
 
-static u8 efuse_read8(struct rtw_adapter *padapter, u16 address, u8 *value)
+static int efuse_read8(struct rtw_adapter *padapter, u16 address, u8 *value)
 {
        return efuse_OneByteRead23a(padapter, address, value);
 }
 
-static u8 efuse_write8(struct rtw_adapter *padapter, u16 address, u8 *value)
+static int efuse_write8(struct rtw_adapter *padapter, u16 address, u8 *value)
 {
        return efuse_OneByteWrite23a(padapter, address, *value);
 }
@@ -522,13 +518,13 @@ static u8 efuse_write8(struct rtw_adapter *padapter, u16 address, u8 *value)
 /*
  * read/wirte raw efuse data
  */
-u8 rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr,
-                   u16 cnts, u8 *data)
+int rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr,
+                       u16 cnts, u8 *data)
 {
        int i = 0;
-       u16     real_content_len = 0, max_available_size = 0;
-       u8 res = _FAIL ;
-       u8 (*rw8)(struct rtw_adapter *, u16, u8*);
+       u16 real_content_len = 0, max_available_size = 0;
+       int res = _FAIL ;
+       int (*rw8)(struct rtw_adapter *, u16, u8*);
 
        EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI,
                                 TYPE_EFUSE_REAL_CONTENT_LEN,
@@ -557,7 +553,8 @@ u8 rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr,
                }
 
                res = rw8(padapter, start_addr++, data++);
-               if (_FAIL == res) break;
+               if (res == _FAIL)
+                       break;
        }
 
        Efuse_PowerSwitch(padapter, bWrite, false);
@@ -567,14 +564,14 @@ u8 rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr,
 /*  */
 u16 efuse_GetMaxSize23a(struct rtw_adapter *padapter)
 {
-       u16     max_size;
+       u16 max_size;
        EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI,
                                 TYPE_AVAILABLE_EFUSE_BYTES_TOTAL,
                                 (void *)&max_size);
        return max_size;
 }
 /*  */
-u8 efuse_GetCurrentSize23a(struct rtw_adapter *padapter, u16 *size)
+int efuse_GetCurrentSize23a(struct rtw_adapter *padapter, u16 *size)
 {
        Efuse_PowerSwitch(padapter, false, true);
        *size = Efuse_GetCurrentSize23a(padapter, EFUSE_WIFI);
@@ -583,9 +580,10 @@ u8 efuse_GetCurrentSize23a(struct rtw_adapter *padapter, u16 *size)
        return _SUCCESS;
 }
 /*  */
-u8 rtw_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data)
+int rtw_efuse_map_read23a(struct rtw_adapter *padapter,
+                         u16 addr, u16 cnts, u8 *data)
 {
-       u16     mapLen = 0;
+       u16 mapLen = 0;
 
        EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI,
                                 TYPE_EFUSE_MAP_LEN, (void *)&mapLen);
@@ -602,9 +600,10 @@ u8 rtw_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *d
        return _SUCCESS;
 }
 
-u8 rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data)
+int rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter,
+                            u16 addr, u16 cnts, u8 *data)
 {
-       u16     mapLen = 0;
+       u16 mapLen = 0;
 
        EFUSE_GetEfuseDefinition23a(padapter, EFUSE_BT,
                                 TYPE_EFUSE_MAP_LEN, (void *)&mapLen);
index ca122d0f80a6d4d104b194cb474bbe3d88d1d93a..3a9a96a2a5ea43abb654427c04c636a89106e166 100644 (file)
@@ -703,7 +703,7 @@ u16 rtl8723a_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter)
 
        while (AVAILABLE_EFUSE_ADDR(efuse_addr)) {
                if (efuse_OneByteRead23a(padapter, efuse_addr, &efuse_data) ==
-                   false) {
+                   _FAIL) {
                        DBG_8723A(KERN_ERR "%s: efuse_OneByteRead23a Fail! "
                                  "addr = 0x%X !!\n", __func__, efuse_addr);
                        break;
@@ -774,7 +774,7 @@ u16 rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter)
 
                while (AVAILABLE_EFUSE_ADDR(efuse_addr)) {
                        if (efuse_OneByteRead23a(padapter, efuse_addr,
-                                             &efuse_data) == false) {
+                                             &efuse_data) == _FAIL) {
                                DBG_8723A(KERN_ERR "%s: efuse_OneByteRead23a Fail!"
                                          " addr = 0x%X !!\n",
                                          __func__, efuse_addr);
@@ -851,7 +851,7 @@ rtl8723a_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data)
        /*  */
        while (AVAILABLE_EFUSE_ADDR(efuse_addr)) {
                if (efuse_OneByteRead23a(padapter, efuse_addr++, &efuse_data) ==
-                   false) {
+                   _FAIL) {
                        ret = false;
                        break;
                }
index a7755056163f4ff00d4ce22a8986dc2957a5e774..07bdc3464443b141f1091057505731ff58d76d22 100644 (file)
@@ -81,20 +81,19 @@ struct pg_pkt_struct {
 
 /*------------------------Export global variable----------------------------*/
 
-u8     efuse_GetCurrentSize23a(struct rtw_adapter *padapter, u16 *size);
 u16    efuse_GetMaxSize23a(struct rtw_adapter *padapter);
-u8     rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bRead, u16 start_addr, u16 cnts, u8 *data);
-u8     rtw_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data);
+int    rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bRead, u16 start_addr, u16 cnts, u8 *data);
+int    rtw_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data);
 u8     rtw_efuse_map_write(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data);
-u8     rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data);
+int    rtw_BT_efuse_map_read23a(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data);
 u8     rtw_BT_efuse_map_write(struct rtw_adapter *padapter, u16 addr, u16 cnts, u8 *data);
 
 u16    Efuse_GetCurrentSize23a(struct rtw_adapter *pAdapter, u8 efuseType);
 u8     Efuse_CalculateWordCnts23a(u8 word_en);
 void   ReadEFuseByte23a(struct rtw_adapter *Adapter, u16 _offset, u8 *pbuf);
 void   EFUSE_GetEfuseDefinition23a(struct rtw_adapter *pAdapter, u8 efuseType, u8 type, void *pOut);
-u8     efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data);
-u8     efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data);
+int    efuse_OneByteRead23a(struct rtw_adapter *pAdapter, u16 addr, u8 *data);
+int    efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data);
 
 void   Efuse_PowerSwitch23a(struct rtw_adapter *pAdapter,u8    bWrite,u8        PwrState);
 int    Efuse_PgPacketRead23a(struct rtw_adapter *pAdapter, u8 offset, u8 *data);