diff options
author | Kevin McKinney <klmckinney1@gmail.com> | 2012-06-06 22:54:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-12 10:49:52 -0700 |
commit | 093abf11d3c4ecb8d8c57adec926dced532878ba (patch) | |
tree | 7b24e7f39ea00a05ac82d843011067e78acd8d4b /drivers/staging/bcm | |
parent | 9b754b17f9ac5fbb9586ae6582de7ecbfc46b56d (diff) |
Staging: bcm: Fix all whitespace issues in nvm.c
This patch resolves all whitespace issues as reported
by checkpatch.pl.
Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/bcm')
-rw-r--r-- | drivers/staging/bcm/nvm.c | 4067 |
1 files changed, 1980 insertions, 2087 deletions
diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c index f16d3bb54c3c..2bb87c93b0e9 100644 --- a/drivers/staging/bcm/nvm.c +++ b/drivers/staging/bcm/nvm.c @@ -29,8 +29,8 @@ static INT CorruptDSDSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL e static INT CorruptISOSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal); static INT SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, UINT uiSectAlignAddr); static INT WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter, PUINT pBuff, - FLASH2X_SECTION_VAL eFlash2xSectionVal, - UINT uiOffset, UINT uiNumBytes); + FLASH2X_SECTION_VAL eFlash2xSectionVal, + UINT uiOffset, UINT uiNumBytes); static FLASH2X_SECTION_VAL getHighestPriDSD(struct bcm_mini_adapter *Adapter); static FLASH2X_SECTION_VAL getHighestPriISO(struct bcm_mini_adapter *Adapter); @@ -49,7 +49,7 @@ static INT BeceemFlashBulkWrite( static INT GetFlashBaseAddr(struct bcm_mini_adapter *Adapter); -static INT ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter,UINT dwAddress, UINT *pdwData, UINT dwNumData); +static INT ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter, UINT dwAddress, UINT *pdwData, UINT dwNumData); // Procedure: ReadEEPROMStatusRegister // @@ -62,52 +62,52 @@ static INT ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter,UINT dwAddress, // //----------------------------------------------------------------------------- -static UCHAR ReadEEPROMStatusRegister(struct bcm_mini_adapter *Adapter ) +static UCHAR ReadEEPROMStatusRegister(struct bcm_mini_adapter *Adapter) { UCHAR uiData = 0; - DWORD dwRetries = MAX_EEPROM_RETRIES*RETRIES_PER_DELAY; + DWORD dwRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY; UINT uiStatus = 0; UINT value = 0; UINT value1 = 0; /* Read the EEPROM status register */ - value = EEPROM_READ_STATUS_REGISTER ; - wrmalt( Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value)); + value = EEPROM_READ_STATUS_REGISTER; + wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value)); - while ( dwRetries != 0 ) + while (dwRetries != 0) { - value=0; - uiStatus = 0 ; + value = 0; + uiStatus = 0; rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus)); - if(Adapter->device_removed == TRUE) + if (Adapter->device_removed == TRUE) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Modem has got removed hence exiting...."); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem has got removed hence exiting...."); break; } /* Wait for Avail bit to be set. */ - if ( ( uiStatus & EEPROM_READ_DATA_AVAIL) != 0 ) + if ((uiStatus & EEPROM_READ_DATA_AVAIL) != 0) { /* Clear the Avail/Full bits - which ever is set. */ value = uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL); - wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); + wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - value =0; + value = 0; rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value)); uiData = (UCHAR)value; break; } - dwRetries-- ; - if ( dwRetries == 0 ) + dwRetries--; + if (dwRetries == 0) { - rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG, &value1, sizeof(value1)); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"0x3004 = %x 0x3008 = %x, retries = %d failed.\n",value,value1, MAX_EEPROM_RETRIES*RETRIES_PER_DELAY); + rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); + rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG, &value1, sizeof(value1)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "0x3004 = %x 0x3008 = %x, retries = %d failed.\n", value, value1, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY); return uiData; } - if( !(dwRetries%RETRIES_PER_DELAY) ) + if (!(dwRetries%RETRIES_PER_DELAY)) msleep(1); uiStatus = 0 ; } @@ -129,68 +129,65 @@ static UCHAR ReadEEPROMStatusRegister(struct bcm_mini_adapter *Adapter ) //----------------------------------------------------------------------------- INT ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter, - DWORD dwAddress, - DWORD *pdwData, - DWORD dwNumWords - ) + DWORD dwAddress, + DWORD *pdwData, + DWORD dwNumWords) { DWORD dwIndex = 0; - DWORD dwRetries = MAX_EEPROM_RETRIES*RETRIES_PER_DELAY; + DWORD dwRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY; UINT uiStatus = 0; - UINT value= 0; + UINT value = 0; UINT value1 = 0; UCHAR *pvalue; /* Flush the read and cmd queue. */ - value=( EEPROM_READ_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH ); - wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value) ); - value=0; - wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value)); + value = (EEPROM_READ_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH); + wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value)); + value = 0; + wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value)); /* Clear the Avail/Full bits. */ - value=( EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL ); - wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); + value = (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL); + wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); - value= dwAddress | ( (dwNumWords == 4) ? EEPROM_16_BYTE_PAGE_READ : EEPROM_4_BYTE_PAGE_READ ); - wrmalt( Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value)); - - while ( dwRetries != 0 ) - { + value = dwAddress | ((dwNumWords == 4) ? EEPROM_16_BYTE_PAGE_READ : EEPROM_4_BYTE_PAGE_READ); + wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value)); + while (dwRetries != 0) + { uiStatus = 0; rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus)); - if(Adapter->device_removed == TRUE) + if (Adapter->device_removed == TRUE) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Modem has got Removed.hence exiting from loop..."); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem has got Removed.hence exiting from loop..."); return -ENODEV; } /* If we are reading 16 bytes we want to be sure that the queue * is full before we read. In the other cases we are ok if the * queue has data available */ - if ( dwNumWords == 4 ) + if (dwNumWords == 4) { - if ( ( uiStatus & EEPROM_READ_DATA_FULL ) != 0 ) + if ((uiStatus & EEPROM_READ_DATA_FULL) != 0) { /* Clear the Avail/Full bits - which ever is set. */ - value = ( uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL) ) ; - wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); + value = (uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL)); + wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); break; } } - else if ( dwNumWords == 1 ) + else if (dwNumWords == 1) { - - if ( ( uiStatus & EEPROM_READ_DATA_AVAIL ) != 0 ) + if ((uiStatus & EEPROM_READ_DATA_AVAIL) != 0) { /* We just got Avail and we have to read 32bits so we * need this sleep for Cardbus kind of devices. */ - if (Adapter->chip_id == 0xBECE0210 ) - udelay(800); + if (Adapter->chip_id == 0xBECE0210) + udelay(800); /* Clear the Avail/Full bits - which ever is set. */ - value=( uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL) ); - wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value)); + value = (uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL)); + wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); break; } } @@ -198,25 +195,27 @@ INT ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter, uiStatus = 0; dwRetries--; - if(dwRetries == 0) + if (dwRetries == 0) { - value=0; - value1=0; + value = 0; + value1 = 0; rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value)); rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG, &value1, sizeof(value1)); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "dwNumWords %d 0x3004 = %x 0x3008 = %x retries = %d failed.\n", dwNumWords, value, value1, MAX_EEPROM_RETRIES*RETRIES_PER_DELAY); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "dwNumWords %d 0x3004 = %x 0x3008 = %x retries = %d failed.\n", + dwNumWords, value, value1, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY); return STATUS_FAILURE; } - if( !(dwRetries%RETRIES_PER_DELAY) ) + + if (!(dwRetries%RETRIES_PER_DELAY)) msleep(1); } - for ( dwIndex = 0; dwIndex < dwNumWords ; dwIndex++ ) + for (dwIndex = 0; dwIndex < dwNumWords; dwIndex++) { /* We get only a byte at a time - from LSB to MSB. We shift it into an integer. */ pvalue = (PUCHAR)(pdwData + dwIndex); - value =0; + value = 0; rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value)); pvalue[0] = value; @@ -226,7 +225,7 @@ INT ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter, pvalue[1] = value; - value =0; + value = 0; rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value)); pvalue[2] = value; @@ -256,15 +255,14 @@ INT ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter, //----------------------------------------------------------------------------- INT ReadBeceemEEPROM(struct bcm_mini_adapter *Adapter, - DWORD uiOffset, - DWORD *pBuffer - ) + DWORD uiOffset, + DWORD *pBuffer) { - UINT uiData[8] = {0}; + UINT uiData[8] = {0}; UINT uiByteOffset = 0; UINT uiTempOffset = 0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL," ====> "); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " ====> "); uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE); uiByteOffset = uiOffset - uiTempOffset; @@ -273,18 +271,16 @@ INT ReadBeceemEEPROM(struct bcm_mini_adapter *Adapter, /* A word can overlap at most over 2 pages. In that case we read the * next page too. */ - if ( uiByteOffset > 12 ) + if (uiByteOffset > 12) { ReadBeceemEEPROMBulk(Adapter, uiTempOffset + MAX_RW_SIZE, (PUINT)&uiData[4], 4); } - memcpy( (PUCHAR) pBuffer, ( ((PUCHAR)&uiData[0]) + uiByteOffset ), 4); + memcpy((PUCHAR)pBuffer, (((PUCHAR)&uiData[0]) + uiByteOffset), 4); return STATUS_SUCCESS; } /* ReadBeceemEEPROM() */ - - INT ReadMacAddressFromNVM(struct bcm_mini_adapter *Adapter) { INT Status; @@ -295,7 +291,7 @@ INT ReadMacAddressFromNVM(struct bcm_mini_adapter *Adapter) INIT_PARAMS_1_MACADDRESS_ADDRESS, MAC_ADDRESS_SIZE); - if(Status == STATUS_SUCCESS) + if (Status == STATUS_SUCCESS) memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); return Status; @@ -317,62 +313,56 @@ INT ReadMacAddressFromNVM(struct bcm_mini_adapter *Adapter) // <FAILURE> - if failed. //----------------------------------------------------------------------------- -INT BeceemEEPROMBulkRead( - struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - UINT uiOffset, - UINT uiNumBytes) +INT BeceemEEPROMBulkRead(struct bcm_mini_adapter *Adapter, + PUINT pBuffer, + UINT uiOffset, + UINT uiNumBytes) { - UINT uiData[4] = {0}; - //UINT uiAddress = 0; - UINT uiBytesRemaining = uiNumBytes; - UINT uiIndex = 0; - UINT uiTempOffset = 0; - UINT uiExtraBytes = 0; - UINT uiFailureRetries = 0; + UINT uiData[4] = {0}; + // UINT uiAddress = 0; + UINT uiBytesRemaining = uiNumBytes; + UINT uiIndex = 0; + UINT uiTempOffset = 0; + UINT uiExtraBytes = 0; + UINT uiFailureRetries = 0; PUCHAR pcBuff = (PUCHAR)pBuffer; - - if(uiOffset%MAX_RW_SIZE&& uiBytesRemaining) + if (uiOffset % MAX_RW_SIZE && uiBytesRemaining) { - uiTempOffset = uiOffset - (uiOffset%MAX_RW_SIZE); - uiExtraBytes = uiOffset-uiTempOffset; - ReadBeceemEEPROMBulk(Adapter,uiTempOffset,(PUINT)&uiData[0],4); - if(uiBytesRemaining >= (MAX_RW_SIZE - uiExtraBytes)) + uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE); + uiExtraBytes = uiOffset - uiTempOffset; + ReadBeceemEEPROMBulk(Adapter, uiTempOffset, (PUINT)&uiData[0], 4); + if (uiBytesRemaining >= (MAX_RW_SIZE - uiExtraBytes)) { - memcpy(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),MAX_RW_SIZE - uiExtraBytes); - + memcpy(pBuffer, (((PUCHAR)&uiData[0]) + uiExtraBytes), MAX_RW_SIZE - uiExtraBytes); uiBytesRemaining -= (MAX_RW_SIZE - uiExtraBytes); uiIndex += (MAX_RW_SIZE - uiExtraBytes); uiOffset += (MAX_RW_SIZE - uiExtraBytes); } else { - memcpy(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),uiBytesRemaining); + memcpy(pBuffer, (((PUCHAR)&uiData[0]) + uiExtraBytes), uiBytesRemaining); uiIndex += uiBytesRemaining; uiOffset += uiBytesRemaining; uiBytesRemaining = 0; } - - } - - while(uiBytesRemaining && uiFailureRetries != 128) + while (uiBytesRemaining && uiFailureRetries != 128) { - if(Adapter->device_removed ) + if (Adapter->device_removed) { return -1; } - if(uiBytesRemaining >= MAX_RW_SIZE) + if (uiBytesRemaining >= MAX_RW_SIZE) { /* For the requests more than or equal to 16 bytes, use bulk * read function to make the access faster. * We read 4 Dwords of data */ - if(0 == ReadBeceemEEPROMBulk(Adapter,uiOffset,&uiData[0],4)) + if (0 == ReadBeceemEEPROMBulk(Adapter, uiOffset, &uiData[0], 4)) { - memcpy(pcBuff+uiIndex,&uiData[0],MAX_RW_SIZE); + memcpy(pcBuff + uiIndex, &uiData[0], MAX_RW_SIZE); uiOffset += MAX_RW_SIZE; uiBytesRemaining -= MAX_RW_SIZE; uiIndex += MAX_RW_SIZE; @@ -380,40 +370,39 @@ INT BeceemEEPROMBulkRead( else { uiFailureRetries++; - mdelay(3);//sleep for a while before retry... + mdelay(3); //sleep for a while before retry... } } - else if(uiBytesRemaining >= 4) + else if (uiBytesRemaining >= 4) { - if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) + if (0 == ReadBeceemEEPROM(Adapter, uiOffset, &uiData[0])) { - memcpy(pcBuff+uiIndex,&uiData[0],4); + memcpy(pcBuff + uiIndex, &uiData[0], 4); uiOffset += 4; uiBytesRemaining -= 4; - uiIndex +=4; + uiIndex += 4; } else { uiFailureRetries++; - mdelay(3);//sleep for a while before retry... + mdelay(3); //sleep for a while before retry... } } else - { // Handle the reads less than 4 bytes... + { // Handle the reads less than 4 bytes... PUCHAR pCharBuff = (PUCHAR)pBuffer; pCharBuff += uiIndex; - if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0])) + if (0 == ReadBeceemEEPROM(Adapter, uiOffset, &uiData[0])) { - memcpy(pCharBuff,&uiData[0],uiBytesRemaining);//copy only bytes requested. + memcpy(pCharBuff, &uiData[0], uiBytesRemaining); //copy only bytes requested. uiBytesRemaining = 0; } else { uiFailureRetries++; - mdelay(3);//sleep for a while before retry... + mdelay(3); //sleep for a while before retry... } } - } return 0; @@ -435,11 +424,10 @@ INT BeceemEEPROMBulkRead( // <FAILURE> - if failed. //----------------------------------------------------------------------------- -static INT BeceemFlashBulkRead( - struct bcm_mini_adapter *Adapter, - PUINT pBuffer, - UINT uiOffset, - UINT uiNumBytes) +static INT BeceemFlashBulkRead(struct bcm_mini_adapter *Adapter, + PUINT pBuffer, + UINT uiOffset, + UINT uiNumBytes) { UINT uiIndex = 0; UINT uiBytesToRead = uiNumBytes; @@ -447,30 +435,30 @@ static INT BeceemFlashBulkRead( UINT uiPartOffset = 0; int bytes; - if(Adapter->device_removed ) + if (Adapter->device_removed) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device Got Removed "); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device Got Removed"); return -ENODEV; } - //Adding flash Base address -// uiOffset = uiOffset + GetFlashBaseAddr(Adapter); -#if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) - Status = bcmflash_raw_read((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes); - return Status; -#endif + // Adding flash Base address + // uiOffset = uiOffset + GetFlashBaseAddr(Adapter); + #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS) + Status = bcmflash_raw_read((uiOffset/FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes); + return Status; + #endif Adapter->SelectedChip = RESET_CHIP_SELECT; - if(uiOffset % MAX_RW_SIZE) + if (uiOffset % MAX_RW_SIZE) { - BcmDoChipSelect(Adapter,uiOffset); + BcmDoChipSelect(Adapter, uiOffset); uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); - uiBytesToRead = MAX_RW_SIZE - (uiOffset%MAX_RW_SIZE); - uiBytesToRead = MIN(uiNumBytes,uiBytesToRead); + uiBytesToRead = MAX_RW_SIZE - (uiOffset % MAX_RW_SIZE); + uiBytesToRead = MIN(uiNumBytes, uiBytesToRead); - bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer+uiIndex, uiBytesToRead); + bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer + uiIndex, uiBytesToRead); if (bytes < 0) { Status = bytes; Adapter->SelectedChip = RESET_CHIP_SELECT; @@ -482,24 +470,22 @@ static INT BeceemFlashBulkRead( uiNumBytes -= uiBytesToRead; } - while(uiNumBytes) + while (uiNumBytes) { - BcmDoChipSelect(Adapter,uiOffset); + BcmDoChipSelect(Adapter, uiOffset); uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter); - uiBytesToRead = MIN(uiNumBytes,MAX_RW_SIZE); + uiBytesToRead = MIN(uiNumBytes, MAX_RW_SIZE); - bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer+uiIndex, uiBytesToRead); + bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer + uiIndex, uiBytesToRead); if (bytes < 0) { Status = bytes; break; } - uiIndex += uiBytesToRead; uiOffset += uiBytesToRead; uiNumBytes -= uiBytesToRead; - } Adapter->SelectedChip = RESET_CHIP_SELECT; return Status; @@ -520,12 +506,10 @@ static INT BeceemFlashBulkRead( static UINT BcmGetFlashSize(struct bcm_mini_adapter *Adapter) { - if(IsFlash2x(Adapter)) - return (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER)); + if (IsFlash2x(Adapter)) + return (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER)); else - return 32*1024; - - + return 32 * 1024; } //----------------------------------------------------------------------------- @@ -546,51 +530,48 @@ static UINT BcmGetEEPROMSize(struct bcm_mini_adapter *Adapter) UINT uiData = 0; UINT uiIndex = 0; -// -// if EEPROM is present and already Calibrated,it will have -// 'BECM' string at 0th offset. -// To find the EEPROM size read the possible boundaries of the -// EEPROM like 4K,8K etc..accessing the EEPROM beyond its size will -// result in wrap around. So when we get the End of the EEPROM we will -// get 'BECM' string which is indeed at offset 0. -// - BeceemEEPROMBulkRead(Adapter,&uiData,0x0,4); - if(uiData == BECM) + // + // if EEPROM is present and already Calibrated,it will have + // 'BECM' string at 0th offset. + // To find the EEPROM size read the possible boundaries of the + // EEPROM like 4K,8K etc..accessing the EEPROM beyond its size will + // result in wrap around. So when we get the End of the EEPROM we will + // get 'BECM' string which is indeed at offset 0. + // + BeceemEEPROMBulkRead(Adapter, &uiData, 0x0, 4); + if (uiData == BECM) { - for(uiIndex = 2;uiIndex <=256; uiIndex*=2) + for (uiIndex = 2; uiIndex <= 256; uiIndex *= 2) { - BeceemEEPROMBulkRead(Adapter,&uiData,uiIndex*1024,4); - if(uiData == BECM) + BeceemEEPROMBulkRead(Adapter, &uiData, uiIndex * 1024, 4); + if (uiData == BECM) { - return uiIndex*1024; + return uiIndex * 1024; } } } else { -// -// EEPROM may not be present or not programmed -// - - uiData = 0xBABEFACE; - if(0 == BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&uiData,0,4,TRUE)) + // + // EEPROM may not be present or not programmed + // + uiData = 0xBABEFACE; + if (0 == BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&uiData, 0, 4, TRUE)) { uiData = 0; - for(uiIndex = 2;uiIndex <=256; uiIndex*=2) + for (uiIndex = 2; uiIndex <= 256; uiIndex *= 2) { - BeceemEEPROMBulkRead(Adapter,&uiData,uiIndex*1024,4); - if(uiData == 0xBABEFACE) + BeceemEEPROMBulkRead(Adapter, &uiData, uiIndex * 1024, 4); + if (uiData == 0xBABEFACE) { - return uiIndex*1024; + return uiIndex * 1024; } } } - } return 0; } - //----------------------------------------------------------------------------- // Procedure: FlashSectorErase // @@ -606,17 +587,16 @@ static UINT BcmGetEEPROMSize(struct bcm_mini_adapter *Adapter) // //----------------------------------------------------------------------------- - static INT FlashSectorErase(struct bcm_mini_adapter *Adapter, - UINT addr, - UINT numOfSectors) + UINT addr, + UINT numOfSectors) { UINT iIndex = 0, iRetries = 0; UINT uiStatus = 0; UINT value; int bytes; - for(iIndex=0;iIndex<numOfSectors;iIndex++) + for (iIndex = 0; iIndex < numOfSectors; iIndex++) { value = 0x06000000; wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)); @@ -628,9 +608,9 @@ static INT FlashSectorErase(struct bcm_mini_adapter *Adapter, do { value = (FLASH_CMD_STATUS_REG_READ << 24); - if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) + if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails"); return STATUS_FAILURE; } @@ -641,15 +621,15 @@ static INT FlashSectorErase(struct bcm_mini_adapter *Adapter, return uiStatus; } iRetries++; - //After every try lets make the CPU free for 10 ms. generally time taken by the - //the sector erase cycle is 500 ms to 40000 msec. hence sleeping 10 ms - //won't hamper performance in any case. + // After every try lets make the CPU free for 10 ms. generally time taken by the + // the sector erase cycle is 500 ms to 40000 msec. hence sleeping 10 ms + // won't hamper performance in any case. msleep(10); - }while((uiStatus & 0x1) && (iRetries < 400)); + } while ((uiStatus & 0x1) && (iRetries < 400)); - if(uiStatus & 0x1) + if (uiStatus & 0x1) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"iRetries crossing the limit of 80000\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "iRetries crossing the limit of 80000\n"); return STATUS_FAILURE; } @@ -671,45 +651,42 @@ static INT FlashSectorErase(struct bcm_mini_adapter *Adapter, // //----------------------------------------------------------------------------- -static INT flashByteWrite( - struct bcm_mini_adapter *Adapter, - UINT uiOffset, - PVOID pData) +static INT flashByteWrite(struct bcm_mini_adapter *Adapter, + UINT uiOffset, + PVOID pData) { - UINT uiStatus = 0; INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3 - UINT value; ULONG ulData = *(PUCHAR)pData; int bytes; + // + // need not write 0xFF because write requires an erase and erase will + // make whole sector 0xFF. + // -// -// need not write 0xFF because write requires an erase and erase will -// make whole sector 0xFF. -// - - if(0xFF == ulData) + if (0xFF == ulData) { return STATUS_SUCCESS; } -// DumpDebug(NVM_RW,("flashWrite ====>\n")); + // DumpDebug(NVM_RW,("flashWrite ====>\n")); value = (FLASH_CMD_WRITE_ENABLE << 24); - if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0) + if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write enable in FLASH_SPI_CMDQ_REG register fails"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write enable in FLASH_SPI_CMDQ_REG register fails"); return STATUS_FAILURE; } - if(wrm(Adapter,FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0 ) + + if (wrm(Adapter, FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"DATA Write on FLASH_SPI_WRITEQ_REG fails"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DATA Write on FLASH_SPI_WRITEQ_REG fails"); return STATUS_FAILURE; } value = (0x02000000 | (uiOffset & 0xFFFFFF)); - if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0 ) + if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programming of FLASH_SPI_CMDQ_REG fails"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programming of FLASH_SPI_CMDQ_REG fails"); return STATUS_FAILURE; } @@ -718,35 +695,33 @@ static INT flashByteWrite( do { value = (FLASH_CMD_STATUS_REG_READ << 24); - if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails"); + if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) + { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails"); return STATUS_FAILURE; - } - //__udelay(1); + } + //__udelay(1); bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)); if (bytes < 0) { uiStatus = bytes; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails"); return uiStatus; } - iRetries--; - if( iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) - msleep(1); + iRetries--; + if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) + msleep(1); - }while((uiStatus & 0x1) && (iRetries >0) ); + } while ((uiStatus & 0x1) && (iRetries > 0)); - if(uiStatus & 0x1) + if (uiStatus & 0x1) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Write fails even after checking status for 200 times."); - return STATUS_FAILURE ; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times."); + return STATUS_FAILURE; } return STATUS_SUCCESS; } - - //----------------------------------------------------------------------------- // Procedure: flashWrite // @@ -761,11 +736,9 @@ static INT flashByteWrite( // //----------------------------------------------------------------------------- -static INT flashWrite( - struct bcm_mini_adapter *Adapter, - UINT uiOffset, - PVOID pData) - +static INT flashWrite(struct bcm_mini_adapter *Adapter, + UINT uiOffset, + PVOID pData) { //UINT uiStatus = 0; //INT iRetries = 0; @@ -773,14 +746,13 @@ static INT flashWrite( UINT uiStatus = 0; INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3 - UINT value; - UINT uiErasePattern[4] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; + UINT uiErasePattern[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; int bytes; -// -// need not write 0xFFFFFFFF because write requires an erase and erase will -// make whole sector 0xFFFFFFFF. -// + // + // need not write 0xFFFFFFFF because write requires an erase and erase will + // make whole sector 0xFFFFFFFF. + // if (!memcmp(pData, uiErasePattern, MAX_RW_SIZE)) { return 0; @@ -788,14 +760,15 @@ static INT flashWrite( value = (FLASH_CMD_WRITE_ENABLE << 24); - if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0 ) + if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write Enable of FLASH_SPI_CMDQ_REG fails"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write Enable of FLASH_SPI_CMDQ_REG fails"); return STATUS_FAILURE; } - if(wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) + + if (wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Data write fails..."); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Data write fails..."); return STATUS_FAILURE; } @@ -803,12 +776,12 @@ static INT flashWrite( do { value = (FLASH_CMD_STATUS_REG_READ << 24); - if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails"); + if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) + { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails"); return STATUS_FAILURE; - } - //__udelay(1); + } + //__udelay(1); bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)); if (bytes < 0) { uiStatus = bytes; @@ -821,14 +794,14 @@ static INT flashWrite( //currently one rdm/wrm takes 125 us. //Hence 125 *2 * FLASH_PER_RETRIES_DELAY > 3 ms(worst case delay) //Hence current implementation cycle will intoduce no delay in current path - if(iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) - msleep(1); - }while((uiStatus & 0x1) && (iRetries > 0)); + if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) + msleep(1); + } while ((uiStatus & 0x1) && (iRetries > 0)); - if(uiStatus & 0x1) + if (uiStatus & 0x1) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Write fails even after checking status for 200 times."); - return STATUS_FAILURE ; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times."); + return STATUS_FAILURE; } return STATUS_SUCCESS; @@ -847,10 +820,9 @@ static INT flashWrite( // OSAL_STATUS_CODE // //----------------------------------------------------------------------------- -static INT flashByteWriteStatus( - struct bcm_mini_adapter *Adapter, - UINT uiOffset, - PVOID pData) +static INT flashByteWriteStatus(struct bcm_mini_adapter *Adapter, + UINT uiOffset, + PVOID pData) { UINT uiStatus = 0; INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3 @@ -858,12 +830,12 @@ static INT flashByteWriteStatus( UINT value; int bytes; -// -// need not write 0xFFFFFFFF because write requires an erase and erase will -// make whole sector 0xFFFFFFFF. -// + // + // need not write 0xFFFFFFFF because write requires an erase and erase will + // make whole sector 0xFFFFFFFF. + // - if(0xFF == ulData) + if (0xFF == ulData) { return STATUS_SUCCESS; } @@ -871,31 +843,31 @@ static INT flashByteWriteStatus( // DumpDebug(NVM_RW,("flashWrite ====>\n")); value = (FLASH_CMD_WRITE_ENABLE << 24); - if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0) + if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write enable in FLASH_SPI_CMDQ_REG register fails"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write enable in FLASH_SPI_CMDQ_REG register fails"); return STATUS_SUCCESS; } - if(wrm(Adapter,FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0) + if (wrm(Adapter, FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"DATA Write on FLASH_SPI_WRITEQ_REG fails"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DATA Write on FLASH_SPI_WRITEQ_REG fails"); return STATUS_FAILURE; } value = (0x02000000 | (uiOffset & 0xFFFFFF)); - if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0) + if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programming of FLASH_SPI_CMDQ_REG fails"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programming of FLASH_SPI_CMDQ_REG fails"); return STATUS_FAILURE; } - //msleep(1); + //msleep(1); do { value = (FLASH_CMD_STATUS_REG_READ << 24); - if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) + if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails"); return STATUS_FAILURE; } //__udelay(1); @@ -907,18 +879,18 @@ static INT flashByteWriteStatus( } iRetries--; - if( iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) - msleep(1); - }while((uiStatus & 0x1) && (iRetries > 0)); + if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0)) + msleep(1); + + } while ((uiStatus & 0x1) && (iRetries > 0)); - if(uiStatus & 0x1) + if (uiStatus & 0x1) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Write fails even after checking status for 200 times."); - return STATUS_FAILURE ; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times."); + return STATUS_FAILURE; } return STATUS_SUCCESS; - } //----------------------------------------------------------------------------- // Procedure: flashWriteStatus @@ -934,68 +906,69 @@ static INT flashByteWriteStatus( // //----------------------------------------------------------------------------- -static INT flashWriteStatus( - struct bcm_mini_adapter *Adapter, - UINT uiOffset, - PVOID pData) +static INT flashWriteStatus(struct bcm_mini_adapter *Adapter, + UINT uiOffset, + PVOID pData) { UINT uiStatus = 0; INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3 //UINT uiReadBack = 0; UINT value; - UINT uiErasePattern[4] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; + UINT uiErasePattern[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; int bytes; -// -// need not write 0xFFFFFFFF because write requires an erase and erase will -// make whole sector 0xFFFFFFFF. -// - if (!memcmp(pData,uiErasePattern,MAX_RW_SIZE)) + // + // need not write 0xFFFFFFFF because write requires an erase and erase will + // make whole sector 0xFFFFFFFF. + // + if (!memcmp(pData, uiErasePattern, MAX_RW_SIZE)) { return 0; } value = (FLASH_CMD_WRITE_ENABLE << 24); - if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0) + if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write Enable of FLASH_SPI_CMDQ_REG fails"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write Enable of FLASH_SPI_CMDQ_REG fails"); return STATUS_FAILURE; } - if(wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) + + if (wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Data write fails..."); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Data write fails..."); return STATUS_FAILURE; } - // __udelay(1); + // __udelay(1); do { value = (FLASH_CMD_STATUS_REG_READ << 24); - if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails"); + if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) + { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails"); return STATUS_FAILURE; - } - //__udelay(1); + } + //__udelay(1); bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus)); i |