From a4f6eb1e8ea62d9bdb9a53f669066c0def35bcca Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Fri, 16 May 2014 10:04:15 +0200 Subject: [PATCH] staging: rtl8723au: Remove a pile of unused EFUSE read/write functionality All this code was only pulled in since it was registered in the HAL wrapper interface, despite it never being called. It also removes the lasts pieces of code from rtl8723a_set_hal_ops(), so remove it as well. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_efuse.c | 34 -- .../staging/rtl8723au/hal/rtl8723a_hal_init.c | 345 +----------------- drivers/staging/rtl8723au/hal/usb_halinit.c | 1 - drivers/staging/rtl8723au/include/hal_intf.h | 13 - .../staging/rtl8723au/include/rtl8723a_hal.h | 1 - 5 files changed, 2 insertions(+), 392 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_efuse.c b/drivers/staging/rtl8723au/core/rtw_efuse.c index 1c8795620776..8ba5166a2559 100644 --- a/drivers/staging/rtl8723au/core/rtw_efuse.c +++ b/drivers/staging/rtl8723au/core/rtw_efuse.c @@ -465,28 +465,6 @@ efuse_OneByteWrite23a(struct rtw_adapter *pAdapter, u16 addr, u8 data) return bResult; } -int -Efuse_PgPacketRead23a(struct rtw_adapter *pAdapter, u8 offset, u8 *data) -{ - int ret = 0; - - ret = pAdapter->HalFunc.Efuse_PgPacketRead23a(pAdapter, offset, data); - - return ret; -} - -int -Efuse_PgPacketWrite23a(struct rtw_adapter *pAdapter, u8 offset, - u8 word_en, u8 *data) -{ - int ret; - - ret = pAdapter->HalFunc.Efuse_PgPacketWrite23a(pAdapter, offset, - word_en, data); - - return ret; -} - /*----------------------------------------------------------------------------- * Function: efuse_WordEnableDataRead23a * @@ -531,18 +509,6 @@ efuse_WordEnableDataRead23a(u8 word_en, } } -u8 -Efuse_WordEnableDataWrite23a(struct rtw_adapter *pAdapter, u16 efuse_addr, - u8 word_en, u8 *data) -{ - u8 ret = 0; - - ret = pAdapter->HalFunc.Efuse_WordEnableDataWrite23a(pAdapter, efuse_addr, - word_en, data); - - return ret; -} - static u8 efuse_read8(struct rtw_adapter *padapter, u16 address, u8 *value) { return efuse_OneByteRead23a(padapter, address, value); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 283f0f0f1a12..ca122d0f80a6 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -819,67 +819,8 @@ u16 rtl8723a_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter) return retU2; } -static u8 -Hal_EfuseWordEnableDataWrite(struct rtw_adapter *padapter, - u16 efuse_addr, u8 word_en, u8 *data) -{ - u16 tmpaddr = 0; - u16 start_addr = efuse_addr; - u8 badworden = 0x0F; - u8 tmpdata[PGPKT_DATA_SIZE]; - - memset(tmpdata, 0xFF, PGPKT_DATA_SIZE); - - if (!(word_en & BIT(0))) { - tmpaddr = start_addr; - efuse_OneByteWrite23a(padapter, start_addr++, data[0]); - efuse_OneByteWrite23a(padapter, start_addr++, data[1]); - - efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[0]); - efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[1]); - if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) { - badworden &= ~BIT(0); - } - } - if (!(word_en & BIT(1))) { - tmpaddr = start_addr; - efuse_OneByteWrite23a(padapter, start_addr++, data[2]); - efuse_OneByteWrite23a(padapter, start_addr++, data[3]); - - efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[2]); - efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[3]); - if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) { - badworden &= ~BIT(1); - } - } - if (!(word_en & BIT(2))) { - tmpaddr = start_addr; - efuse_OneByteWrite23a(padapter, start_addr++, data[4]); - efuse_OneByteWrite23a(padapter, start_addr++, data[5]); - - efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[4]); - efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[5]); - if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) { - badworden &= ~BIT(2); - } - } - if (!(word_en & BIT(3))) { - tmpaddr = start_addr; - efuse_OneByteWrite23a(padapter, start_addr++, data[6]); - efuse_OneByteWrite23a(padapter, start_addr++, data[7]); - - efuse_OneByteRead23a(padapter, tmpaddr, &tmpdata[6]); - efuse_OneByteRead23a(padapter, tmpaddr + 1, &tmpdata[7]); - if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) { - badworden &= ~BIT(3); - } - } - - return badworden; -} - -static s32 -Hal_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data) +bool +rtl8723a_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data) { u8 efuse_data, word_cnts = 0; u16 efuse_addr = 0; @@ -956,279 +897,6 @@ Hal_EfusePgPacketRead(struct rtw_adapter *padapter, u8 offset, u8 *data) return ret; } -static u8 -hal_EfusePgCheckAvailableAddr(struct rtw_adapter *pAdapter, u8 efuseType) -{ - u16 max_available = 0; - u16 current_size; - - EFUSE_GetEfuseDefinition23a(pAdapter, efuseType, - TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, - &max_available); - - current_size = Efuse_GetCurrentSize23a(pAdapter, efuseType); - if (current_size >= max_available) { - DBG_8723A("%s: Error!! current_size(%d)>max_available(%d)\n", - __func__, current_size, max_available); - return false; - } - return true; -} - -static void -hal_EfuseConstructPGPkt(u8 offset, u8 word_en, u8 *pData, - struct pg_pkt_struct *pTargetPkt) -{ - memset(pTargetPkt->data, 0xFF, PGPKT_DATA_SIZE); - pTargetPkt->offset = offset; - pTargetPkt->word_en = word_en; - efuse_WordEnableDataRead23a(word_en, pData, pTargetPkt->data); - pTargetPkt->word_cnts = Efuse_CalculateWordCnts23a(pTargetPkt->word_en); -} - -static u8 -hal_EfusePartialWriteCheck(struct rtw_adapter *padapter, u8 efuseType, - u16 *pAddr, struct pg_pkt_struct *pTargetPkt) -{ - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - u8 bRet = false; - u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0; - u8 efuse_data = 0; - - EFUSE_GetEfuseDefinition23a(padapter, efuseType, - TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, - &efuse_max_available_len); - EFUSE_GetEfuseDefinition23a(padapter, efuseType, - TYPE_EFUSE_CONTENT_LEN_BANK, &efuse_max); - - if (efuseType == EFUSE_WIFI) - startAddr = pHalData->EfuseUsedBytes; - else - startAddr = pHalData->BTEfuseUsedBytes; - - startAddr %= efuse_max; - - while (1) { - if (startAddr >= efuse_max_available_len) { - bRet = false; - DBG_8723A("%s: startAddr(%d) >= efuse_max_available_" - "len(%d)\n", __func__, startAddr, - efuse_max_available_len); - break; - } - - if (efuse_OneByteRead23a(padapter, startAddr, &efuse_data) && - (efuse_data != 0xFF)) { - bRet = false; - DBG_8723A("%s: Something Wrong! last bytes(%#X = 0x%02X) " - "is not 0xFF\n", __func__, - startAddr, efuse_data); - break; - } else { - /* not used header, 0xff */ - *pAddr = startAddr; - bRet = true; - break; - } - } - - return bRet; -} - -static u8 -hal_EfusePgPacketWrite1ByteHeader(struct rtw_adapter *pAdapter, u8 efuseType, - u16 *pAddr, struct pg_pkt_struct *pTargetPkt) -{ - u8 pg_header = 0, tmp_header = 0; - u16 efuse_addr = *pAddr; - u8 repeatcnt = 0; - - pg_header = ((pTargetPkt->offset << 4) & 0xf0) | pTargetPkt->word_en; - - do { - efuse_OneByteWrite23a(pAdapter, efuse_addr, pg_header); - efuse_OneByteRead23a(pAdapter, efuse_addr, &tmp_header); - if (tmp_header != 0xFF) - break; - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { - DBG_8723A("%s: Repeat over limit for pg_header!!\n", - __func__); - return false; - } - } while (1); - - if (tmp_header != pg_header) { - DBG_8723A(KERN_ERR "%s: PG Header Fail!!(pg = 0x%02X " - "read = 0x%02X)\n", __func__, - pg_header, tmp_header); - return false; - } - - *pAddr = efuse_addr; - - return true; -} - -static u8 -hal_EfusePgPacketWrite2ByteHeader(struct rtw_adapter *padapter, u8 efuseType, - u16 *pAddr, struct pg_pkt_struct *pTargetPkt) -{ - u16 efuse_addr, efuse_max_available_len = 0; - u8 pg_header = 0, tmp_header = 0; - u8 repeatcnt = 0; - - EFUSE_GetEfuseDefinition23a(padapter, efuseType, - TYPE_AVAILABLE_EFUSE_BYTES_BANK, - &efuse_max_available_len); - - efuse_addr = *pAddr; - if (efuse_addr >= efuse_max_available_len) { - DBG_8723A("%s: addr(%d) over avaliable(%d)!!\n", __func__, - efuse_addr, efuse_max_available_len); - return false; - } - - pg_header = ((pTargetPkt->offset & 0x07) << 5) | 0x0F; - - do { - efuse_OneByteWrite23a(padapter, efuse_addr, pg_header); - efuse_OneByteRead23a(padapter, efuse_addr, &tmp_header); - if (tmp_header != 0xFF) - break; - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { - DBG_8723A("%s: Repeat over limit for pg_header!!\n", - __func__); - return false; - } - } while (1); - - if (tmp_header != pg_header) { - DBG_8723A(KERN_ERR - "%s: PG Header Fail!!(pg = 0x%02X read = 0x%02X)\n", - __func__, pg_header, tmp_header); - return false; - } - - /* to write ext_header */ - efuse_addr++; - pg_header = ((pTargetPkt->offset & 0x78) << 1) | pTargetPkt->word_en; - - do { - efuse_OneByteWrite23a(padapter, efuse_addr, pg_header); - efuse_OneByteRead23a(padapter, efuse_addr, &tmp_header); - if (tmp_header != 0xFF) - break; - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { - DBG_8723A("%s: Repeat over limit for ext_header!!\n", - __func__); - return false; - } - } while (1); - - if (tmp_header != pg_header) { /* offset PG fail */ - DBG_8723A(KERN_ERR - "%s: PG EXT Header Fail!!(pg = 0x%02X read = 0x%02X)\n", - __func__, pg_header, tmp_header); - return false; - } - - *pAddr = efuse_addr; - - return true; -} - -static u8 -hal_EfusePgPacketWriteHeader(struct rtw_adapter *padapter, u8 efuseType, - u16 *pAddr, struct pg_pkt_struct *pTargetPkt) -{ - u8 bRet = false; - - if (pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) { - bRet = hal_EfusePgPacketWrite2ByteHeader(padapter, efuseType, - pAddr, pTargetPkt); - } else { - bRet = hal_EfusePgPacketWrite1ByteHeader(padapter, efuseType, - pAddr, pTargetPkt); - } - - return bRet; -} - -static u8 -hal_EfusePgPacketWriteData(struct rtw_adapter *pAdapter, u8 efuseType, - u16 *pAddr, struct pg_pkt_struct *pTargetPkt) -{ - u16 efuse_addr; - u8 badworden; - - efuse_addr = *pAddr; - badworden = - Efuse_WordEnableDataWrite23a(pAdapter, efuse_addr + 1, - pTargetPkt->word_en, pTargetPkt->data); - if (badworden != 0x0F) { - DBG_8723A("%s: Fail!!\n", __func__); - return false; - } - - return true; -} - -static s32 -Hal_EfusePgPacketWrite(struct rtw_adapter *padapter, - u8 offset, u8 word_en, u8 *pData) -{ - struct pg_pkt_struct targetPkt; - u16 startAddr = 0; - u8 efuseType = EFUSE_WIFI; - - if (!hal_EfusePgCheckAvailableAddr(padapter, efuseType)) - return false; - - hal_EfuseConstructPGPkt(offset, word_en, pData, &targetPkt); - - if (!hal_EfusePartialWriteCheck(padapter, efuseType, - &startAddr, &targetPkt)) - return false; - - if (!hal_EfusePgPacketWriteHeader(padapter, efuseType, - &startAddr, &targetPkt)) - return false; - - if (!hal_EfusePgPacketWriteData(padapter, efuseType, - &startAddr, &targetPkt)) - return false; - - return true; -} - -static bool -Hal_EfusePgPacketWrite_BT(struct rtw_adapter *pAdapter, - u8 offset, u8 word_en, u8 *pData) -{ - struct pg_pkt_struct targetPkt; - u16 startAddr = 0; - u8 efuseType = EFUSE_BT; - - if (!hal_EfusePgCheckAvailableAddr(pAdapter, efuseType)) - return false; - - hal_EfuseConstructPGPkt(offset, word_en, pData, &targetPkt); - - if (!hal_EfusePartialWriteCheck(pAdapter, efuseType, - &startAddr, &targetPkt)) - return false; - - if (!hal_EfusePgPacketWriteHeader(pAdapter, efuseType, - &startAddr, &targetPkt)) - return false; - - if (!hal_EfusePgPacketWriteData(pAdapter, efuseType, - &startAddr, &targetPkt)) - return false; - - return true; -} - void rtl8723a_read_chip_version(struct rtw_adapter *padapter) { u32 value32; @@ -1542,15 +1210,6 @@ exit: return ret; } -void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc) -{ - /* Efuse related function */ - pHalFunc->Efuse_PgPacketRead23a = &Hal_EfusePgPacketRead; - pHalFunc->Efuse_PgPacketWrite23a = &Hal_EfusePgPacketWrite; - pHalFunc->Efuse_WordEnableDataWrite23a = &Hal_EfuseWordEnableDataWrite; - pHalFunc->Efuse_PgPacketWrite23a_BT = &Hal_EfusePgPacketWrite_BT; -} - void rtl8723a_InitAntenna_Selection(struct rtw_adapter *padapter) { u8 val; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 96ee3107cb58..a25b018bd905 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1751,6 +1751,5 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->hal_xmit = &rtl8723au_hal_xmit; pHalFunc->mgnt_xmit = &rtl8723au_mgnt_xmit; pHalFunc->hal_xmitframe_enqueue = &rtl8723au_hal_xmitframe_enqueue; - rtl8723a_set_hal_ops(pHalFunc); return 0; } diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index b8fd4033e2bb..dc4fca93c366 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -93,19 +93,6 @@ struct hal_ops { struct xmit_frame *pmgntframe); s32 (*hal_xmitframe_enqueue)(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe); - - void (*EFUSEGetEfuseDefinition)(struct rtw_adapter *padapter, - u8 efuseType, u8 type, void *pOut); - u16 (*EfuseGetCurrentSize)(struct rtw_adapter *padapter, u8 efuseType); - int (*Efuse_PgPacketRead23a)(struct rtw_adapter *padapter, - u8 offset, u8 *data); - int (*Efuse_PgPacketWrite23a)(struct rtw_adapter *padapter, - u8 offset, u8 word_en, u8 *data); - u8 (*Efuse_WordEnableDataWrite23a)(struct rtw_adapter *padapter, - u16 efuse_addr, u8 word_en, - u8 *data); - bool (*Efuse_PgPacketWrite23a_BT)(struct rtw_adapter *padapter, - u8 offset, u8 word_en, u8 *data); }; enum rt_eeprom_type { diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index b61f37f7a308..dd9558460d7b 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -531,7 +531,6 @@ void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, u8 *hwinfo, void Hal_InitChannelPlan23a(struct rtw_adapter *padapter); -void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc); #ifdef CONFIG_8723AU_BT_COEXIST void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter); #endif -- 2.39.5