[haiku-commits] r42414 - haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 11 Jul 2011 23:35:27 +0200 (CEST)

Author: kallisti5
Date: 2011-07-11 23:35:27 +0200 (Mon, 11 Jul 2011)
New Revision: 42414
Changeset: https://dev.haiku-os.org/changeset/42414

Modified:
   
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp
   
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemDevice.cpp
   
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemNVM.cpp
   haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/Driver.cpp
Log:
* Lots of style cleanup on my code
* Remove some badly ported code in FlashBulkWrite


Modified: 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp
    2011-07-11 20:06:39 UTC (rev 42413)
+++ 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp
    2011-07-11 21:35:27 UTC (rev 42414)
@@ -63,7 +63,6 @@
 BeceemCPU::CPUReset()
 {
        unsigned int value = 0;
-       unsigned int uiResetValue = 0;
 
        if (fWmxDevice->deviceChipID >= T3LPB) {
                BizarroReadRegister(SYS_CFG, sizeof(value), &value);
@@ -115,6 +114,8 @@
        }
        // TODO : ELSE OLDER CHIP ID's < T3LP see Misc.c:1048
 
+       unsigned int uiResetValue = 0;
+
        if (fWmxDevice->CPUFlashBoot) {
                // In flash boot mode MIPS state register has reverse polarity.
                // So just or with setting bit 30.

Modified: 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemDevice.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemDevice.cpp
 2011-07-11 20:06:39 UTC (rev 42413)
+++ 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemDevice.cpp
 2011-07-11 21:35:27 UTC (rev 42414)
@@ -41,7 +41,7 @@
 // auto-release helper class
 class USBSmartLock {
 public:
-       USBSmartLock()  { mutex_lock(&gUSBLock); }
+       USBSmartLock() { mutex_lock(&gUSBLock); }
        ~USBSmartLock() { mutex_unlock(&gUSBLock); }
 };
 
@@ -1005,8 +1005,6 @@
 status_t
 BeceemDevice::LoadConfig()
 {
-       int     dtaread = 0;
-
        int fh = open(FIRM_CFG, O_RDONLY);
 
        struct stat cfgStat;
@@ -1024,9 +1022,7 @@
                return B_ERROR;
        }
 
-       dtaread = read(fh, buffer, MAX_USB_TRANSFER);
-
-       if (dtaread < 0) {
+       if (read(fh, buffer, MAX_USB_TRANSFER) < 0) {
                TRACE_ALWAYS("Error: Error reading from vendor 
configuration.\n");
                close(fh);
                free(buffer);

Modified: 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemNVM.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemNVM.cpp
    2011-07-11 20:06:39 UTC (rev 42413)
+++ 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemNVM.cpp
    2011-07-11 21:35:27 UTC (rev 42414)
@@ -57,13 +57,12 @@
 status_t
 BeceemNVM::NVMFlush()
 {
-       unsigned int value = 0;
-
        /* Chipset Bug : Clear the Avail bits on the Read queue. The default
         * value on this register is supposed to be 0x00001102.
         * But we get 0x00001122. */
        TRACE("Debug: Fixing reset value on 0x0f003004\n");
-       value = NVM_READ_DATA_AVAIL;
+
+       unsigned int value = NVM_READ_DATA_AVAIL;
        BizarroWriteRegister(NVM_SPI_Q_STATUS1_REG, sizeof(value), &value);
 
        /* Flush the all of the NVM queues. */
@@ -73,18 +72,17 @@
        value = 0;
        BizarroWriteRegister(SPI_FLUSH_REG, sizeof(value), &value);
 
-return B_OK;
+       return B_OK;
 }
 
 
 status_t
 BeceemNVM::NVMDetect()
 {
-       unsigned int    uiData          =       0;
+       unsigned int uiData = 0;
 
        EEPROMBulkRead(0x0, 4, &uiData);
-       if (uiData == BECM)
-       {
+       if (uiData == BECM) {
                TRACE_ALWAYS("Info: EEPROM nvm detected.\n");
                pwmxdevice->nvmType = NVM_EEPROM;
                pwmxdevice->nvmDSDSize = EEPROMGetSize();
@@ -96,8 +94,7 @@
                return B_ERROR;
 
        FlashBulkRead(0x0 + pwmxdevice->nvmFlashCalStart, 4, &uiData);
-       if (uiData == BECM)
-       {
+       if (uiData == BECM) {
                        TRACE_ALWAYS("Info: Flash nvm detected.\n");
                        pwmxdevice->nvmType = NVM_FLASH;
                        pwmxdevice->nvmDSDSize = FlashGetSize();
@@ -107,7 +104,8 @@
        pwmxdevice->nvmType = NVM_UNKNOWN;
 
        TRACE_ALWAYS("Error: Couldn't detect nvm storage method, found 0x%X\n",
-                               uiData);
+               uiData);
+
        return B_ERROR;
 }
 
@@ -115,63 +113,61 @@
 status_t
 BeceemNVM::NVMChipSelect(unsigned int offset)
 {
-       int                             ChipIndex = 0;
-       unsigned int    PartNum = 0;
-       unsigned int    FlashConfig = 0;
-       unsigned int    GPIOConfig = 0;
+       int chipIndex = offset / FLASH_PART_SIZE;
 
-       ChipIndex = offset / FLASH_PART_SIZE;
-
        // Chip to be selected is already selected
-       if (bSelectedChip == ChipIndex)
+       if (bSelectedChip == chipIndex)
                return B_OK;
 
        TRACE("Debug: Selecting chip %d for transaction at 0x%x\n",
-               ChipIndex, offset);
+               chipIndex, offset);
 
        // Migrate selected chip to new selection
-       bSelectedChip = ChipIndex;
+       bSelectedChip = chipIndex;
 
-       BizarroReadRegister(FLASH_CONFIG_REG, 4, &FlashConfig);
-       BizarroReadRegister(FLASH_GPIO_CONFIG_REG, 4, &GPIOConfig);
+       unsigned int flashConfig = 0;
+       BizarroReadRegister(FLASH_CONFIG_REG, 4, &flashConfig);
 
+       unsigned int gpioConfig = 0;
+       BizarroReadRegister(FLASH_GPIO_CONFIG_REG, 4, &gpioConfig);
+
        // TRACE("Reading GPIO config 0x%x\n", &GPIOConfig);
        // TRACE("Reading Flash config 0x%x\n", &FlashConfig);
 
-       switch (ChipIndex)
-       {
+       unsigned int partitionNumber = 0;
+       switch (chipIndex) {
        case 0:
-               PartNum = 0;
+               partitionNumber = 0;
                break;
        case 1:
-               PartNum = 3;
-               GPIOConfig |= (0x4 << 12);
+               partitionNumber = 3;
+               gpioConfig |= 0x4 << 12;
                break;
        case 2:
-               PartNum = 1;
-               GPIOConfig |= (0x1 << 12);
+               partitionNumber = 1;
+               gpioConfig |= 0x1 << 12;
                break;
        case 3:
-               PartNum = 2;
-               GPIOConfig |= (0x2 << 12);
+               partitionNumber = 2;
+               gpioConfig |= 0x2 << 12;
                break;
        }
 
-       if (PartNum == ((FlashConfig >> 12) & 0x3))
+       if (partitionNumber == ((flashConfig >> 12) & 0x3))
                return B_OK;
 
-       FlashConfig &= 0xFFFFCFFF;
-       FlashConfig = (FlashConfig | (PartNum<<12));
+       flashConfig &= 0xFFFFCFFF;
+       flashConfig = (flashConfig | (partitionNumber<<12));
 
-       // TRACE("Writing GPIO config 0x%x\n", &GPIOConfig);
-       // TRACE("Writing Flash config 0x%x\n", &FlashConfig);
+       // TRACE("Writing GPIO config 0x%x\n", &gpioConfig);
+       // TRACE("Writing Flash config 0x%x\n", &flashConfig);
 
        TRACE("Debug: Selecting chip %x.\n", bSelectedChip);
 
-       BizarroWriteRegister(FLASH_GPIO_CONFIG_REG, 4, &GPIOConfig);
+       BizarroWriteRegister(FLASH_GPIO_CONFIG_REG, 4, &gpioConfig);
        snooze(100);
 
-       BizarroWriteRegister(FLASH_CONFIG_REG, 4, &FlashConfig);
+       BizarroWriteRegister(FLASH_CONFIG_REG, 4, &flashConfig);
        snooze(100);
 
        return B_OK;
@@ -183,7 +179,7 @@
 {
        unsigned int temp = 0;
        unsigned int value = 0;
-       int Status = 0;
+       int status = 0;
        unsigned int myOffset = 0;
 
        if (pwmxdevice->nvmType == NVM_FLASH) {
@@ -203,9 +199,7 @@
                        BizarroWriteRegister(0x0f000C80, sizeof(value), &value);
                }
 
-               Status = FlashBulkRead(myOffset,
-                                       size,
-                                       buffer);
+               status = FlashBulkRead(myOffset, size, buffer);
 
                if (pwmxdevice->driverFwPushed == true) {
                        // Write stored value back
@@ -214,21 +208,22 @@
 
        } else if (pwmxdevice->nvmType == NVM_EEPROM) {
                TRACE_ALWAYS("TODO: NVM_EEPROM Read\n");
-               Status = -1;
+               status = -1;
        } else {
-               Status = -1;
+               status = -1;
        }
 
-       return Status;
+       return status;
 }
 
 
 int
-BeceemNVM::NVMWrite(unsigned int offset, unsigned int size, unsigned int* 
buffer)
+BeceemNVM::NVMWrite(unsigned int offset, unsigned int size,
+       unsigned int* buffer)
 {
        unsigned int temp = 0;
        unsigned int value = 0;
-       int Status = 0;
+       int status = 0;
 
        if (pwmxdevice->nvmType == NVM_FLASH) {
                // Save data at register
@@ -237,21 +232,19 @@
                // Flash register with 0
                BizarroWriteRegister(0x0f000C80, sizeof(value), &value);
 
-               Status = FlashBulkWrite(offset,
-                                                               size,
-                                                               buffer);
+               status = FlashBulkWrite(offset, size, buffer);
 
                // Write stored value back
                BizarroWriteRegister(0x0f000C80, sizeof(temp), &temp);
 
        } else if (pwmxdevice->nvmType == NVM_EEPROM) {
                TRACE_ALWAYS("Todo: NVM_EEPROM Write\n");
-               Status = -1;
+               status = -1;
        } else {
-               Status = -1;
+               status = -1;
        }
 
-       return Status;
+       return status;
 }
 
 
@@ -295,28 +288,25 @@
 unsigned long
 BeceemNVM::FlashReadID()
 {
-       unsigned long   RDID = 0;
-       unsigned int    value;
        // Read the ID from FLASH_CMD_READ_ID
-       value = (FLASH_CMD_READ_ID<<24);
+       unsigned int value = FLASH_CMD_READ_ID << 24;
        BizarroWriteRegister(FLASH_SPI_CMDQ_REG, sizeof(value), &value);
 
        snooze(10);
 
        // Read SPI READQ Register, The output will be 4 bytes long
        // The ID is the first 3 bytes.
-       BizarroReadRegister(FLASH_SPI_READQ_REG, sizeof(RDID),
-               (unsigned int*)&RDID);
+       unsigned long readQID = 0;
+       BizarroReadRegister(FLASH_SPI_READQ_REG, sizeof(readQID),
+               (unsigned int*)&readQID);
 
-       return (RDID >>8);
+       return readQID >> 8;
 }
 
 
 status_t
 BeceemNVM::FlashReadCS()
 {
-       unsigned int value;
-
        // Set initial start addresses
        pwmxdevice->nvmFlashCSStart = FLASH_CS_INFO_START_ADDR;
        pwmxdevice->nvmFlashBaseAddr = 0;
@@ -328,7 +318,7 @@
 
        if (pwmxdevice->driverDDRinit == false)
        {
-               value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT;
+               unsigned int value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT;
                BizarroWriteRegister(0xAF00A080, sizeof(value), &value);
        }
 
@@ -340,8 +330,8 @@
                = ntohl(pwmxdevice->nvmFlashCSInfo->FlashLayoutVersion);
 
        TRACE_ALWAYS("Info: Flash CS Version/Signature: 0x%X/0x%X\n",
-                               
(pwmxdevice->nvmFlashCSInfo->FlashLayoutVersion),
-                               ntohl(pwmxdevice->nvmFlashCSInfo->MagicNumber));
+               (pwmxdevice->nvmFlashCSInfo->FlashLayoutVersion),
+               ntohl(pwmxdevice->nvmFlashCSInfo->MagicNumber));
 
        if (ntohl(pwmxdevice->nvmFlashCSInfo->MagicNumber) == 
FLASH_CS_SIGNATURE) {
                pwmxdevice->nvmFlashMajor
@@ -368,33 +358,13 @@
                        = 
(pwmxdevice->nvmFlashCSInfo->OffsetFromZeroForCalibrationStart);
 
                if (!((pwmxdevice->nvmFlashMajor == 1)
-                       && (pwmxdevice->nvmFlashMinor == 1)))
-               {
+                       && (pwmxdevice->nvmFlashMinor == 1))) {
                        pwmxdevice->nvmFlashCSStart
-                               = 
(pwmxdevice->nvmFlashCSInfo->OffsetFromZeroForControlSectionStart);
+                               = 
pwmxdevice->nvmFlashCSInfo->OffsetFromZeroForControlSectionStart;
                }
 
                // TODO : Flash Write sizes.. no write support atm
-               #if 0
-               if((FLASH_CS_SIGNATURE == 
(pwmxdevice->nvmFlashCSInfo->MagicNumber)) &&
-                       (SCSI_FIRMWARE_MINOR_VERSION <= 
MINOR_VERSION(pwmxdevice->nvmFlashCSInfo->SCSIFirmwareVersion)) &&
-                       (FLASH_SECTOR_SIZE_SIG == 
(pwmxdevice->nvmFlashCSInfo->FlashSectorSizeSig)) &&
-                       (BYTE_WRITE_SUPPORT == 
(pwmxdevice->nvmFlashCSInfo->FlashWriteSupportSize)))
-               {
-                       pwmxdevice->ulFlashWriteSize = 
(pwmxdevice->nvmFlashCSInfo->FlashWriteSupportSize);
-                       pwmxdevice->fpFlashWrite = flashByteWrite;
-                       pwmxdevice->fpFlashWriteWithStatusCheck = 
flashByteWriteStatus;
-               } else {
-                       pwmxdevice->ulFlashWriteSize = MAX_RW_SIZE;
-                       pwmxdevice->fpFlashWrite = flashWrite;
-                       pwmxdevice->fpFlashWriteWithStatusCheck = 
flashWriteStatus;
-               }
-               */
 
-               //BcmGetFlashSectorSize(Adapter, 
(Adapter->psFlashCSInfo->FlashSectorSizeSig),
-               //                                              
(Adapter->psFlashCSInfo->FlashSectorSize));
-               #endif
-
                pwmxdevice->nvmFlashBaseAddr = 
pwmxdevice->nvmFlashCSInfo->FlashBaseAddr
                        & 0xFCFFFFFF;
 
@@ -414,33 +384,53 @@
 status_t
 BeceemNVM::FlashCSFlip(PFLASH_CS_INFO FlashCSInfo)
 {
-       FlashCSInfo->MagicNumber                                                
        = ntohl(FlashCSInfo->MagicNumber);
-       FlashCSInfo->FlashLayoutVersion                                         
= ntohl(FlashCSInfo->FlashLayoutVersion);
-       FlashCSInfo->ISOImageVersion                                            
= ntohl(FlashCSInfo->ISOImageVersion);
+       FlashCSInfo->MagicNumber = ntohl(FlashCSInfo->MagicNumber);
+       FlashCSInfo->FlashLayoutVersion = 
ntohl(FlashCSInfo->FlashLayoutVersion);
+       FlashCSInfo->ISOImageVersion = ntohl(FlashCSInfo->ISOImageVersion);
 
        // won't convert according to old assumption
-       FlashCSInfo->SCSIFirmwareVersion                                        
= (FlashCSInfo->SCSIFirmwareVersion);
+       FlashCSInfo->SCSIFirmwareVersion = FlashCSInfo->SCSIFirmwareVersion;
 
-       FlashCSInfo->OffsetFromZeroForPart1ISOImage                     = 
ntohl(FlashCSInfo->OffsetFromZeroForPart1ISOImage);
-       FlashCSInfo->OffsetFromZeroForScsiFirmware                      = 
ntohl(FlashCSInfo->OffsetFromZeroForScsiFirmware);
-       FlashCSInfo->SizeOfScsiFirmware                                         
= ntohl(FlashCSInfo->SizeOfScsiFirmware);
-       FlashCSInfo->OffsetFromZeroForPart2ISOImage                     = 
ntohl(FlashCSInfo->OffsetFromZeroForPart2ISOImage);
-       FlashCSInfo->OffsetFromZeroForCalibrationStart          = 
ntohl(FlashCSInfo->OffsetFromZeroForCalibrationStart);
-       FlashCSInfo->OffsetFromZeroForCalibrationEnd            = 
ntohl(FlashCSInfo->OffsetFromZeroForCalibrationEnd);
-       FlashCSInfo->OffsetFromZeroForVSAStart                          = 
ntohl(FlashCSInfo->OffsetFromZeroForVSAStart);
-       FlashCSInfo->OffsetFromZeroForVSAEnd                            = 
ntohl(FlashCSInfo->OffsetFromZeroForVSAEnd);
-       FlashCSInfo->OffsetFromZeroForControlSectionStart       = 
ntohl(FlashCSInfo->OffsetFromZeroForControlSectionStart);
-       FlashCSInfo->OffsetFromZeroForControlSectionData        = 
ntohl(FlashCSInfo->OffsetFromZeroForControlSectionData);
-       FlashCSInfo->CDLessInactivityTimeout                            = 
ntohl(FlashCSInfo->CDLessInactivityTimeout);
-       FlashCSInfo->NewImageSignature                                          
= ntohl(FlashCSInfo->NewImageSignature);
-       FlashCSInfo->FlashSectorSizeSig                                         
= ntohl(FlashCSInfo->FlashSectorSizeSig);
-       FlashCSInfo->FlashSectorSize                                            
= ntohl(FlashCSInfo->FlashSectorSize);
-       FlashCSInfo->FlashWriteSupportSize                                      
= ntohl(FlashCSInfo->FlashWriteSupportSize);
-       FlashCSInfo->TotalFlashSize                                             
        = ntohl(FlashCSInfo->TotalFlashSize);
-       FlashCSInfo->FlashBaseAddr                                              
        = ntohl(FlashCSInfo->FlashBaseAddr);
-       FlashCSInfo->FlashPartMaxSize                                           
= ntohl(FlashCSInfo->FlashPartMaxSize);
-       FlashCSInfo->IsCDLessDeviceBootSig                                      
= ntohl(FlashCSInfo->IsCDLessDeviceBootSig);
-       FlashCSInfo->MassStorageTimeout                                         
= ntohl(FlashCSInfo->MassStorageTimeout);
+       FlashCSInfo->OffsetFromZeroForPart1ISOImage
+               = ntohl(FlashCSInfo->OffsetFromZeroForPart1ISOImage);
+       FlashCSInfo->OffsetFromZeroForScsiFirmware
+               = ntohl(FlashCSInfo->OffsetFromZeroForScsiFirmware);
+       FlashCSInfo->SizeOfScsiFirmware
+               = ntohl(FlashCSInfo->SizeOfScsiFirmware);
+       FlashCSInfo->OffsetFromZeroForPart2ISOImage
+               = ntohl(FlashCSInfo->OffsetFromZeroForPart2ISOImage);
+       FlashCSInfo->OffsetFromZeroForCalibrationStart
+               = ntohl(FlashCSInfo->OffsetFromZeroForCalibrationStart);
+       FlashCSInfo->OffsetFromZeroForCalibrationEnd
+               = ntohl(FlashCSInfo->OffsetFromZeroForCalibrationEnd);
+       FlashCSInfo->OffsetFromZeroForVSAStart
+               = ntohl(FlashCSInfo->OffsetFromZeroForVSAStart);
+       FlashCSInfo->OffsetFromZeroForVSAEnd
+               = ntohl(FlashCSInfo->OffsetFromZeroForVSAEnd);
+       FlashCSInfo->OffsetFromZeroForControlSectionStart
+               = ntohl(FlashCSInfo->OffsetFromZeroForControlSectionStart);
+       FlashCSInfo->OffsetFromZeroForControlSectionData
+               = ntohl(FlashCSInfo->OffsetFromZeroForControlSectionData);
+       FlashCSInfo->CDLessInactivityTimeout
+               = ntohl(FlashCSInfo->CDLessInactivityTimeout);
+       FlashCSInfo->NewImageSignature
+               = ntohl(FlashCSInfo->NewImageSignature);
+       FlashCSInfo->FlashSectorSizeSig
+               = ntohl(FlashCSInfo->FlashSectorSizeSig);
+       FlashCSInfo->FlashSectorSize
+               = ntohl(FlashCSInfo->FlashSectorSize);
+       FlashCSInfo->FlashWriteSupportSize
+               = ntohl(FlashCSInfo->FlashWriteSupportSize);
+       FlashCSInfo->TotalFlashSize
+               = ntohl(FlashCSInfo->TotalFlashSize);
+       FlashCSInfo->FlashBaseAddr
+               = ntohl(FlashCSInfo->FlashBaseAddr);
+       FlashCSInfo->FlashPartMaxSize
+               = ntohl(FlashCSInfo->FlashPartMaxSize);
+       FlashCSInfo->IsCDLessDeviceBootSig
+               = ntohl(FlashCSInfo->IsCDLessDeviceBootSig);
+       FlashCSInfo->MassStorageTimeout
+               = ntohl(FlashCSInfo->MassStorageTimeout);
 
        return B_OK;
 }
@@ -450,30 +440,54 @@
 BeceemNVM::FlashCSDump(PFLASH_CS_INFO FlashCSInfo)
 {
        TRACE_ALWAYS("************Debug dump of Flash CS Info 
map************\n");
-       TRACE_ALWAYS("                         MagicNumber is 0x%x\n", 
FlashCSInfo->MagicNumber);
-       TRACE_ALWAYS("                  FlashLayoutVersion is 0x%x\n", 
FlashCSInfo->FlashLayoutVersion);
-       TRACE_ALWAYS("                     ISOImageVersion is 0x%x\n", 
FlashCSInfo->ISOImageVersion);
-       TRACE_ALWAYS("                 SCSIFirmwareVersion is 0x%x\n", 
FlashCSInfo->SCSIFirmwareVersion);
-       TRACE_ALWAYS("      OffsetFromZeroForPart1ISOImage is 0x%x\n", 
FlashCSInfo->OffsetFromZeroForPart1ISOImage);
-       TRACE_ALWAYS("       OffsetFromZeroForScsiFirmware is 0x%x\n", 
FlashCSInfo->OffsetFromZeroForScsiFirmware);
-       TRACE_ALWAYS("                  SizeOfScsiFirmware is 0x%x\n", 
FlashCSInfo->SizeOfScsiFirmware);
-       TRACE_ALWAYS("      OffsetFromZeroForPart2ISOImage is 0x%x\n", 
FlashCSInfo->OffsetFromZeroForPart2ISOImage);
-       TRACE_ALWAYS("   OffsetFromZeroForCalibrationStart is 0x%x\n", 
FlashCSInfo->OffsetFromZeroForCalibrationStart);
-       TRACE_ALWAYS("     OffsetFromZeroForCalibrationEnd is 0x%x\n", 
FlashCSInfo->OffsetFromZeroForCalibrationEnd);
-       TRACE_ALWAYS("           OffsetFromZeroForVSAStart is 0x%x\n", 
FlashCSInfo->OffsetFromZeroForVSAStart);
-       TRACE_ALWAYS("             OffsetFromZeroForVSAEnd is 0x%x\n", 
FlashCSInfo->OffsetFromZeroForVSAEnd);
-       TRACE_ALWAYS("OffsetFromZeroForControlSectionStart is 0x%x\n", 
FlashCSInfo->OffsetFromZeroForControlSectionStart);
-       TRACE_ALWAYS(" OffsetFromZeroForControlSectionData is 0x%x\n", 
FlashCSInfo->OffsetFromZeroForControlSectionData);
-       TRACE_ALWAYS("             CDLessInactivityTimeout is 0x%x\n", 
FlashCSInfo->CDLessInactivityTimeout);
-       TRACE_ALWAYS("                   NewImageSignature is 0x%x\n", 
FlashCSInfo->NewImageSignature);
-       TRACE_ALWAYS("                  FlashSectorSizeSig is 0x%x\n", 
FlashCSInfo->FlashSectorSizeSig);
-       TRACE_ALWAYS("                     FlashSectorSize is 0x%x\n", 
FlashCSInfo->FlashSectorSize);
-       TRACE_ALWAYS("               FlashWriteSupportSize is 0x%x\n", 
FlashCSInfo->FlashWriteSupportSize);
-       TRACE_ALWAYS("                      TotalFlashSize is 0x%x\n", 
FlashCSInfo->TotalFlashSize);
-       TRACE_ALWAYS("                       FlashBaseAddr is 0x%x\n", 
FlashCSInfo->FlashBaseAddr);
-       TRACE_ALWAYS("                    FlashPartMaxSize is 0x%x\n", 
FlashCSInfo->FlashPartMaxSize);
-       TRACE_ALWAYS("               IsCDLessDeviceBootSig is 0x%x\n", 
FlashCSInfo->IsCDLessDeviceBootSig);
-       TRACE_ALWAYS("                  MassStorageTimeout is 0x%x\n", 
FlashCSInfo->MassStorageTimeout);
+       TRACE_ALWAYS("                         MagicNumber is 0x%x\n",
+               FlashCSInfo->MagicNumber);
+       TRACE_ALWAYS("                  FlashLayoutVersion is 0x%x\n",
+               FlashCSInfo->FlashLayoutVersion);
+       TRACE_ALWAYS("                     ISOImageVersion is 0x%x\n",
+               FlashCSInfo->ISOImageVersion);
+       TRACE_ALWAYS("                 SCSIFirmwareVersion is 0x%x\n",
+               FlashCSInfo->SCSIFirmwareVersion);
+       TRACE_ALWAYS("      OffsetFromZeroForPart1ISOImage is 0x%x\n",
+               FlashCSInfo->OffsetFromZeroForPart1ISOImage);
+       TRACE_ALWAYS("       OffsetFromZeroForScsiFirmware is 0x%x\n",
+               FlashCSInfo->OffsetFromZeroForScsiFirmware);
+       TRACE_ALWAYS("                  SizeOfScsiFirmware is 0x%x\n",
+               FlashCSInfo->SizeOfScsiFirmware);
+       TRACE_ALWAYS("      OffsetFromZeroForPart2ISOImage is 0x%x\n",
+               FlashCSInfo->OffsetFromZeroForPart2ISOImage);
+       TRACE_ALWAYS("   OffsetFromZeroForCalibrationStart is 0x%x\n",
+               FlashCSInfo->OffsetFromZeroForCalibrationStart);
+       TRACE_ALWAYS("     OffsetFromZeroForCalibrationEnd is 0x%x\n",
+               FlashCSInfo->OffsetFromZeroForCalibrationEnd);
+       TRACE_ALWAYS("           OffsetFromZeroForVSAStart is 0x%x\n",
+               FlashCSInfo->OffsetFromZeroForVSAStart);
+       TRACE_ALWAYS("             OffsetFromZeroForVSAEnd is 0x%x\n",
+               FlashCSInfo->OffsetFromZeroForVSAEnd);
+       TRACE_ALWAYS("OffsetFromZeroForControlSectionStart is 0x%x\n",
+               FlashCSInfo->OffsetFromZeroForControlSectionStart);
+       TRACE_ALWAYS(" OffsetFromZeroForControlSectionData is 0x%x\n",
+               FlashCSInfo->OffsetFromZeroForControlSectionData);
+       TRACE_ALWAYS("             CDLessInactivityTimeout is 0x%x\n",
+               FlashCSInfo->CDLessInactivityTimeout);
+       TRACE_ALWAYS("                   NewImageSignature is 0x%x\n",
+               FlashCSInfo->NewImageSignature);
+       TRACE_ALWAYS("                  FlashSectorSizeSig is 0x%x\n",
+               FlashCSInfo->FlashSectorSizeSig);
+       TRACE_ALWAYS("                     FlashSectorSize is 0x%x\n",
+               FlashCSInfo->FlashSectorSize);
+       TRACE_ALWAYS("               FlashWriteSupportSize is 0x%x\n",
+               FlashCSInfo->FlashWriteSupportSize);
+       TRACE_ALWAYS("                      TotalFlashSize is 0x%x\n",
+               FlashCSInfo->TotalFlashSize);
+       TRACE_ALWAYS("                       FlashBaseAddr is 0x%x\n",
+               FlashCSInfo->FlashBaseAddr);
+       TRACE_ALWAYS("                    FlashPartMaxSize is 0x%x\n",
+               FlashCSInfo->FlashPartMaxSize);
+       TRACE_ALWAYS("               IsCDLessDeviceBootSig is 0x%x\n",
+               FlashCSInfo->IsCDLessDeviceBootSig);
+       TRACE_ALWAYS("                  MassStorageTimeout is 0x%x\n",
+               FlashCSInfo->MassStorageTimeout);
        
TRACE_ALWAYS("*******************************************************\n");
 
        return B_OK;
@@ -481,14 +495,9 @@
 
 
 status_t
-BeceemNVM::FlashBulkRead(unsigned int offset, unsigned int size, unsigned int* 
buffer)
+BeceemNVM::FlashBulkRead(unsigned int offset, unsigned int size,
+       unsigned int* buffer)
 {
-       unsigned int workOffset         = offset;       // our work offset
-       unsigned int partOffset         = 0;            // register we will read
-       unsigned int workBytes          = 0;            // bytes we are working 
on
-       unsigned int bytesLeft          = size;         // counter holding 
bytes left
-       unsigned int outputOffset       = 0;            // where we are in the 
output
-
        if (pwmxdevice->driverHalt == true)
                return -ENODEV;
 
@@ -499,21 +508,27 @@
 
        TRACE("Debug: About to read %d bytes from 0x%x \n", size, offset);
 
+       unsigned int workOffset = offset; // our scratch work offset
+       unsigned int bytesLeft = size; // counter holding bytes left
+       unsigned int outputOffset = 0; // where we are in the output
+
        while (bytesLeft > 0)
        {
                NVMChipSelect(workOffset);
 
-               partOffset = (workOffset & (FLASH_PART_SIZE - 1)) + 
FlashGetBaseAddr();
-               workBytes = MIN(MAX_RW_SIZE,bytesLeft);
+               unsigned int partOffset = (workOffset & (FLASH_PART_SIZE - 1))
+                       + FlashGetBaseAddr();
+               unsigned int workBytes = MIN(MAX_RW_SIZE, bytesLeft);
                        // We read the max RW size or whats left
 
                TRACE("Debug: reading %d bytes from 0x%x to 0x%x (output offset 
%d)\n",
                        workBytes, partOffset, partOffset + workBytes, 
outputOffset);
 
                if (ReadRegister(partOffset, workBytes,
-                       (unsigned int*)((unsigned char*)buffer+outputOffset)) 
!= B_OK) {
+                       (unsigned int*)((unsigned char*)buffer + outputOffset)) 
!= B_OK) {
                                // I've only done this once before.
-                               TRACE_ALWAYS("Error: Read error at 0x%x.  Read 
of %d bytes failed.\n",
+                               TRACE_ALWAYS("Error: Read error at 0x%x."
+                                       " Read of %d bytes failed.\n",
                                        partOffset, workBytes);
                                bSelectedChip = RESET_CHIP_SELECT;
                                return B_ERROR;
@@ -535,8 +550,7 @@
 status_t
 BeceemNVM::RestoreBlockProtect(unsigned long writestatus)
 {
-       unsigned int value;
-       value = (FLASH_CMD_WRITE_ENABLE<< 24);
+       unsigned int value = (FLASH_CMD_WRITE_ENABLE<< 24);
        BizarroWriteRegister(FLASH_SPI_CMDQ_REG, sizeof(value), &value);
 
        snooze(20);
@@ -556,196 +570,40 @@
 
 
 status_t
-BeceemNVM::FlashBulkWrite(unsigned int offset, unsigned int size, unsigned 
int* buffer)
+BeceemNVM::FlashBulkWrite(unsigned int offset, unsigned int size,
+       unsigned int* buffer)
 {
-       unsigned long   BPStatus                        = 0;
-       unsigned int    OffsetFromSectStart     = 0;
-       unsigned int    CurrSectOffsetAddr      = 0;
-       unsigned int    NumSectTobeRead         = 0;
-       unsigned int    SectAlignAddr           = 0;
-       unsigned int    SectBoundary            = 0;
-       unsigned int    PartOffset                      = 0;
-       // unsigned int uiIndex                         = 0;    // used in 
validation
-
-       status_t                Status                          = B_ERROR;
-
-       unsigned char*  ucBuffer                        = (unsigned 
char*)buffer;
-       // unsigned char        ucReadBk[16]            = {0};  // used in 
validation
-       char*                   TempBuffer                      = NULL;
-
-       // if (fRemoved == true)
-       //      return -ENODEV;
-
-       OffsetFromSectStart     =       offset & ~(NVM_SECTOR_SIZE - 1);
-       SectAlignAddr           =       offset & ~(NVM_SECTOR_SIZE - 1);
-       SectBoundary            =       SectAlignAddr + NVM_SECTOR_SIZE;
-
-       TempBuffer                      =       (char*)malloc(NVM_SECTOR_SIZE);
-
-       if (TempBuffer == NULL) {
-               TRACE_ALWAYS("Error: Couldn't allocate temporary buffer.\n");
-               Status = B_ERROR;
-               goto FlashBulkWriteEND;
-       }
-
-       // See if data to be written goes over sector boundry
-       if (offset + size < SectBoundary) {
-               NumSectTobeRead = 1;
-       } else {
-               // Number of sectors  = Last sector start address/First sector 
start address
-               NumSectTobeRead = (CurrSectOffsetAddr + size) / NVM_SECTOR_SIZE;
-               if ((CurrSectOffsetAddr + size)%NVM_SECTOR_SIZE)
-               {
-                       NumSectTobeRead++;
-               }
-       }
-
-       // TODO : Flash2x?
-
-       bSelectedChip = RESET_CHIP_SELECT;
-
-       while (NumSectTobeRead)
-       {
-               NVMChipSelect(offset);
-               PartOffset = (offset & (FLASH_PART_SIZE - 1)) + 
FlashGetBaseAddr();
-
-               if (FlashBulkRead(OffsetFromSectStart,
-                       NVM_SECTOR_SIZE,
-                       (unsigned int*)TempBuffer) != B_OK )
-               {
-                       TRACE_ALWAYS("Error: Couldn't perform FlashBulkRead\n");
-                       Status = B_ERROR;
-                       goto FlashBulkWriteEND;
-               }
-
-               BPStatus = DisableBlockProtect(SectAlignAddr, NVM_SECTOR_SIZE);
-
-               if (NumSectTobeRead > 1)
-               {
-                       memcpy(&TempBuffer[CurrSectOffsetAddr], ucBuffer,
-                               SectBoundary - (SectAlignAddr + 
CurrSectOffsetAddr));
-                       ucBuffer += ((SectBoundary-(SectAlignAddr + 
CurrSectOffsetAddr)));
-                       size -= (SectBoundary-(SectAlignAddr + 
CurrSectOffsetAddr));
-               } else {
-                       memcpy(&TempBuffer[CurrSectOffsetAddr], ucBuffer, size);
-               }
-
-               // TODO : SaveHeaderIfPresent if IsFlash2x?
-
-               FlashSectorErase(PartOffset, 1);
-
-               #if 0
-               //for(uiIndex = 0; uiIndex < NVM_SECTOR_SIZE; uiIndex += 
MAX_RW_SIZE)
-               //{
-                       //if(devicePresent == false)
-                       //{
-                       //      free(TempBuffer);
-                       //      Status = B_ERROR;
-                       //      return Status;
-                       //}
-                       //if(B_OK != 
(*Adapter->fpFlashWrite)(Adapter,uiPartOffset+uiIndex,(&pTempBuff[uiIndex])))
-                       //{
-                       //      free(TempBuffer);
-                       //      Status = B_ERROR;
-                       //      return Status;
-                       //}
-               //}
-
-               // TODO: Data verification needs structs not yet implimented.. 
this is optional
-               // add verify boolean option to function in future
-               for(uiIndex = 0;uiIndex < NVM_SECTOR_SIZE ;uiIndex += 
MAX_RW_SIZE)
-               {
-                       if(FlashBulkRead(OffsetFromSectStart+uiIndex, 
MAX_RW_SIZE ,(unsigned int*)ucReadBk))
-                       {
-                               if(Adapter->ulFlashWriteSize == 1)
-                               {
-                                       unsigned int uiReadIndex = 0;
-                                       for(uiReadIndex = 0; uiReadIndex < 16; 
uiReadIndex++)
-                                       {
-                                               if(ucReadBk[uiReadIndex] != 
TempBuff[uiIndex+uiReadIndex])
-                                               {
-                                                       if(B_OK != 
(*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex+uiReadIndex,&pTempBuff[uiIndex+uiReadIndex]))
-                                                       {
-                                                               Status = 
STATUS_FAILURE;
-                                                               goto 
BeceemFlashBulkWrite_EXIT;
-                                                       }
-                                               }
-                                       }
-                               }
-                               else
-                               {
-                                       
if(OsalMemCompare(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE))
-                                       {
-                                               if(STATUS_SUCCESS != 
(*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex,&pTempBuff[uiIndex]))
-                                               {
-                                                       Status = STATUS_FAILURE;
-                                                       goto 
BeceemFlashBulkWrite_EXIT;
-                                               }
-                                       }
-                               }
-                       }
-               }
-               #endif
-
-               if (BPStatus)
-               {
-                       RestoreBlockProtect(BPStatus);
-                       BPStatus = 0;
-               }
-
-               CurrSectOffsetAddr = 0;
-               SectAlignAddr = SectBoundary;
-               SectBoundary += NVM_SECTOR_SIZE;
-               OffsetFromSectStart += NVM_SECTOR_SIZE;
-               NumSectTobeRead--;
-       }
-
-FlashBulkWriteEND:
-
-       if (BPStatus)
-       {
-               RestoreBlockProtect(BPStatus);
-       }
-
-       if (TempBuffer)
-               free(TempBuffer);
-
-       bSelectedChip = RESET_CHIP_SELECT;
-       return Status;
+       // TODO : Implement flash writing, not really needed for normal use
+       TRACE_ALWAYS("%s: Not yet implemented\n", __func__);
+       return B_ERROR;
 }
 
 
 status_t
 BeceemNVM::FlashSectorErase(unsigned int addr, unsigned int numOfSectors)
 {
-       unsigned int iIndex = 0, iRetries = 0;
-       unsigned int uiStatus = 0;
-       unsigned int value;
-
        TRACE("Debug: Erasing %d sectors at 0x%x\n", numOfSectors, addr);
 
-       for (iIndex = 0 ; iIndex < numOfSectors ; iIndex++)
-       {
-               value = 0x06000000;
+       unsigned int uiStatus = 0;
+       unsigned int iIndex;
+       for (iIndex = 0 ; iIndex < numOfSectors ; iIndex++) {
+               unsigned int value = 0x06000000;
                BizarroWriteRegister(FLASH_SPI_CMDQ_REG, sizeof(value), &value);
 
                value = (0xd8000000 | (addr & 0xFFFFFF));
                BizarroWriteRegister(FLASH_SPI_CMDQ_REG, sizeof(value), &value);
-               iRetries = 0;
+               unsigned int iRetries = 0;
 
-               do
-               {
+               do {
                        value = (FLASH_CMD_STATUS_REG_READ << 24);
                        if ( BizarroWriteRegister(FLASH_SPI_CMDQ_REG,
-                               sizeof(value), &value) != B_OK )
-                       {
+                               sizeof(value), &value) != B_OK ) {
                                TRACE_ALWAYS("Error: Failure writing 
FLASH_SPI_CMDQ_REG\n");
                                return B_ERROR;
                        }
 
                        if ( BizarroReadRegister(FLASH_SPI_READQ_REG,
-                               sizeof(uiStatus), &uiStatus) != B_OK)
-                       {
+                               sizeof(uiStatus), &uiStatus) != B_OK) {
                                TRACE_ALWAYS("Error: Failure reading 
FLASH_SPI_READQ_REG\n");
                                return B_ERROR;
                        }
@@ -756,8 +614,7 @@
                        snooze(10);
                } while ((uiStatus & 0x1) && (iRetries < 400));
 
-               if (uiStatus & 0x1)
-               {
+               if (uiStatus & 0x1) {
                        TRACE_ALWAYS("Error: sector erase retry loop 
exhausted");
                        return B_ERROR;
                }
@@ -772,44 +629,33 @@
 status_t
 BeceemNVM::ReadMACFromNVM(ether_address *address)
 {
-       status_t                Status  =       B_ERROR;
-       unsigned char   MacAddr[6] = {0};
-
-       Status = NVMRead(MAC_ADDR_OFFSET,
-                               6,
-                               (unsigned int*)&MacAddr[0]);
-
+       unsigned char MacAddr[6] = {0};
+       status_t status = NVMRead(MAC_ADDR_OFFSET, 6, (unsigned 
int*)&MacAddr[0]);
        memcpy(address, MacAddr, 6);
 
-       return (Status);
+       return (status);
 }
 
 
 unsigned int
 BeceemNVM::EEPROMGetSize()
 {
-       unsigned int    uiData = 0;
-       unsigned int    uiIndex = 0;
-
        // 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.
 
+       unsigned int uiData = 0;
        EEPROMBulkRead(0x0, 4, &uiData);
 
-       if (ntohl(uiData) == BECM)
-       {
+       if (ntohl(uiData) == BECM) {
                // If EEPROM is present, it will have 'BECM' string at 0th 
offset.
-
-               for (uiIndex = 1 ; uiIndex <= 256; uiIndex *= 2)
-               {
+               unsigned int uiIndex;
+               for (uiIndex = 1 ; uiIndex <= 256; uiIndex *= 2) {
                        EEPROMBulkRead(uiIndex * 1024, 4, &uiData);
 
                        if (ntohl(uiData) == BECM)
-                       {
                                return uiIndex * 1024;
-                       }
                }
        }
 
@@ -822,28 +668,24 @@
 {
        // Read 4 bytes from EEPROM
 
-       unsigned int    dwReadValue = 0;
-       unsigned int    dwRetries = 16;
-       unsigned int    Value = 0;
-
        // read 0x0f003020 until bit 2 of 0x0f003008 is set.
+       unsigned int regValue = 0;
        BizarroReadRegister(EEPROM_SPI_Q_STATUS_REG,
-               sizeof(unsigned int), &Value);
+               sizeof(unsigned int), &regValue);
 
-       while ((( Value >>2 )&1)==0 )
-       {
-               dwRetries--;
+       unsigned int retries = 16;
+       while (((regValue >> 2) & 1) == 0) {
+               retries--;
 
                snooze(200);
 
-               if (dwRetries == 0)
-               {
+               if (retries == 0) {
                        TRACE_ALWAYS("Error: CMD FIFO is not empty\n");
                        return B_ERROR;
                }
 
                BizarroReadRegister(EEPROM_SPI_Q_STATUS_REG,
-                       sizeof(unsigned int), &Value);
+                       sizeof(unsigned int), &regValue);
        }
 
        // wrm (0x0f003018, 0xNbXXXXXX)
@@ -857,41 +699,40 @@
 
        BizarroWriteRegister(EEPROM_CMDQ_SPI_REG, sizeof(unsigned int), 
&offset);
 
-       dwRetries = 50;
+       retries = 50;
 
-       BizarroReadRegister(EEPROM_SPI_Q_STATUS_REG, sizeof(unsigned int), 
&Value);
+       BizarroReadRegister(EEPROM_SPI_Q_STATUS_REG, sizeof(unsigned int),
+               &regValue);
 
-       while ((( Value >>1)&1)==1 )
-       {
-               dwRetries--;
+       while (((regValue >> 1) & 1) == 1) {
+               retries--;
 
                snooze(200);
 
-               if (dwRetries == 0)
-               {
+               if (retries == 0) {
                        TRACE_ALWAYS("Error: READ FIFO is empty\n");
                        return B_ERROR;
                }
 
                BizarroReadRegister(EEPROM_SPI_Q_STATUS_REG, sizeof(unsigned 
int),
-                       &Value);
+                       &regValue);
        }
 
-       BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), 
&Value);
+       BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), 
&regValue);
 
-       dwReadValue = Value;
+       unsigned int dwReadValue = regValue;
 
-       BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), 
&Value);
+       BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), 
&regValue);
 
-       dwReadValue |= (Value<<8);
+       dwReadValue |= regValue << 8;
 
-       BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), 
&Value);
+       BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), 
&regValue);
 
-       dwReadValue |= (Value<<16);
+       dwReadValue |= regValue << 16;
 
-       BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), 
&Value);
+       BizarroReadRegister(EEPROM_READ_DATAQ_REG, sizeof(unsigned int), 
&regValue);
 
-       dwReadValue |= (Value<<24);
+       dwReadValue |= regValue << 24;
 
        *pdwData = dwReadValue;
 
@@ -900,7 +741,8 @@
 
 
 status_t
-BeceemNVM::EEPROMBulkRead( unsigned int offset, size_t numBytes, unsigned int* 
buffer)
+BeceemNVM::EEPROMBulkRead(unsigned int offset, size_t numBytes,
+       unsigned int* buffer)
 {
        unsigned int    uiData[4] = {0};
        unsigned int    uiBytesRemaining = numBytes;
@@ -910,18 +752,15 @@
        unsigned int    uiExtraBytes = 0;
        unsigned char*  pcBuff = (unsigned char*)buffer;
 
-
        TRACE("Debug: Reading %x bytes at offset %x.\n", numBytes, offset);
 
-       if (offset%16 && uiBytesRemaining)
-       {
+       if (offset%16 && uiBytesRemaining) {
                uiTempOffset = offset - (offset%16);
                uiExtraBytes = offset - uiTempOffset;
 
                EEPROMBulkRead(uiTempOffset, 16, (unsigned int*)&uiData[0]);
 
-               if (uiBytesRemaining >= (16 - uiExtraBytes))
-               {
+               if (uiBytesRemaining >= (16 - uiExtraBytes)) {
                        memcpy(buffer,
                                (((unsigned char*)&uiData[0])+uiExtraBytes),
                                16 - uiExtraBytes);
@@ -938,14 +777,13 @@
                }
        }
 
-       while (uiBytesRemaining)
-       {
-               if (uiBytesRemaining >= 16)
-               {       // for the requests more than or equal to 16 bytes,
+       while (uiBytesRemaining) {
+               if (uiBytesRemaining >= 16) {
+                       // for the requests more than or equal to 16 bytes,
                        // use bulk read function to make the access faster.
 
-                       // TODO : Impliment function to read more data faster
-                       //ReadBeceemEEPROMBulk(offset, &uiData[0]);
+                       // TODO : Implement function to read more data faster
+                       // ReadBeceemEEPROMBulk(offset, &uiData[0]);

[... truncated: 178 lines follow ...]

Other related posts:

  • » [haiku-commits] r42414 - haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx - kallisti5