Commit a5e4b81e authored by Kevin McKinney's avatar Kevin McKinney Committed by Greg Kroah-Hartman

Staging: bcm: Fix coding style issues in InterfaceDld.c

This patch fixes multiple coding style issues in file,
InterfaceDld.c, found by checkpatch.pl.
Signed-off-by: default avatarKevin McKinney <klmckinney1@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent a3e2940c
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc)
{ {
/*unsigned int reg = 0;*/ /* unsigned int reg = 0; */
mm_segment_t oldfs = {0}; mm_segment_t oldfs = {0};
int errno = 0, len = 0; /*,is_config_file = 0*/ int errno = 0, len = 0; /* ,is_config_file = 0 */
loff_t pos = 0; loff_t pos = 0;
PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg;
/*PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter;*/ /* PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter; */
char *buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL); char *buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL);
if (!buff) if (!buff)
...@@ -17,7 +17,7 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) ...@@ -17,7 +17,7 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc)
oldfs = get_fs(); oldfs = get_fs();
set_fs(get_ds()); set_fs(get_ds());
len = vfs_read(flp, (void __force __user *)buff, len = vfs_read(flp, (void __force __user *)buff,
MAX_TRANSFER_CTRL_BYTE_USB, &pos); MAX_TRANSFER_CTRL_BYTE_USB, &pos);
set_fs(oldfs); set_fs(oldfs);
if (len <= 0) { if (len <= 0) {
if (len < 0) { if (len < 0) {
...@@ -35,8 +35,9 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) ...@@ -35,8 +35,9 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc)
break; break;
} }
/* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_INITEXIT, MP_INIT, /* BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_INITEXIT, MP_INIT,
DBG_LVL_ALL, buff, * DBG_LVL_ALL, buff,
MAX_TRANSFER_CTRL_BYTE_USB);*/ * MAX_TRANSFER_CTRL_BYTE_USB);
*/
errno = InterfaceWRM(psIntfAdapter, on_chip_loc, buff, len); errno = InterfaceWRM(psIntfAdapter, on_chip_loc, buff, len);
if (errno) { if (errno) {
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,
...@@ -51,153 +52,132 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc) ...@@ -51,153 +52,132 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc)
return errno; return errno;
} }
int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, int InterfaceFileReadbackFromChip(PVOID arg, struct file *flp, unsigned int on_chip_loc)
unsigned int on_chip_loc)
{ {
char *buff, *buff_readback; char *buff, *buff_readback;
unsigned int reg = 0; unsigned int reg = 0;
mm_segment_t oldfs={0}; mm_segment_t oldfs = {0};
int errno=0, len=0, is_config_file = 0; int errno = 0, len = 0, is_config_file = 0;
loff_t pos=0; loff_t pos = 0;
static int fw_down = 0; static int fw_down = 0;
INT Status = STATUS_SUCCESS; INT Status = STATUS_SUCCESS;
PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg; PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg;
buff=kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA); buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA);
buff_readback=kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA); buff_readback = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA);
if(!buff || !buff_readback) if (!buff || !buff_readback) {
{ kfree(buff);
kfree(buff); kfree(buff_readback);
kfree(buff_readback);
return -ENOMEM; return -ENOMEM;
} }
is_config_file = (on_chip_loc == CONFIG_BEGIN_ADDR)? 1:0; is_config_file = (on_chip_loc == CONFIG_BEGIN_ADDR) ? 1 : 0;
memset(buff_readback, 0, MAX_TRANSFER_CTRL_BYTE_USB); memset(buff_readback, 0, MAX_TRANSFER_CTRL_BYTE_USB);
memset(buff, 0, MAX_TRANSFER_CTRL_BYTE_USB); memset(buff, 0, MAX_TRANSFER_CTRL_BYTE_USB);
while(1) while (1) {
{ oldfs = get_fs();
oldfs=get_fs(); set_fs(get_ds()); set_fs(get_ds());
len=vfs_read(flp, (void __force __user *)buff, MAX_TRANSFER_CTRL_BYTE_USB, &pos); len = vfs_read(flp, (void __force __user *)buff, MAX_TRANSFER_CTRL_BYTE_USB, &pos);
set_fs(oldfs); set_fs(oldfs);
fw_down++; fw_down++;
if(len<=0)
{
if(len<0)
{
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len < 0");
errno=len;
}
else
{
errno = 0;
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got end of file!");
}
break;
}
if (len <= 0) {
if (len < 0) {
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len < 0");
errno = len;
} else {
errno = 0;
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got end of file!");
}
break;
}
Status = InterfaceRDM(psIntfAdapter, on_chip_loc, buff_readback, len); Status = InterfaceRDM(psIntfAdapter, on_chip_loc, buff_readback, len);
if(Status) if (Status) {
{ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "RDM of len %d Failed! %d", len, reg);
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "RDM of len %d Failed! %d", len, reg);
goto exit; goto exit;
} }
reg++; reg++;
if((len-sizeof(unsigned int))<4) if ((len-sizeof(unsigned int)) < 4) {
{ if (memcmp(buff_readback, buff, len)) {
if(memcmp(buff_readback, buff, len)) BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down);
{ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Length is: %d", len);
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down);
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT,DBG_LVL_ALL,"Length is: %d",len);
Status = -EIO; Status = -EIO;
goto exit; goto exit;
} }
} } else {
else len -= 4;
{
len-=4; while (len) {
while(len) if (*(unsigned int *)&buff_readback[len] != *(unsigned int *)&buff[len]) {
{ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down);
if(*(unsigned int*)&buff_readback[len] != *(unsigned int *)&buff[len]) BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&buff_readback[len]);
{ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len);
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down);
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&buff_readback[len]);
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len);
Status = -EIO; Status = -EIO;
goto exit; goto exit;
} }
len-=4; len -= 4;
} }
} }
on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB; on_chip_loc += MAX_TRANSFER_CTRL_BYTE_USB;
}/* End of while(1)*/ } /* End of while(1) */
exit: exit:
kfree(buff); kfree(buff);
kfree(buff_readback); kfree(buff_readback);
return Status; return Status;
} }
static int bcm_download_config_file(PMINI_ADAPTER Adapter, static int bcm_download_config_file(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo)
FIRMWARE_INFO *psFwInfo)
{ {
int retval = STATUS_SUCCESS; int retval = STATUS_SUCCESS;
B_UINT32 value = 0; B_UINT32 value = 0;
if(Adapter->pstargetparams == NULL) if (Adapter->pstargetparams == NULL) {
{ if ((Adapter->pstargetparams = kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) {
if((Adapter->pstargetparams = return -ENOMEM;
kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL) }
{
return -ENOMEM;
}
}
if(psFwInfo->u32FirmwareLength != sizeof(STARGETPARAMS))
{
return -EIO;
} }
retval = copy_from_user(Adapter->pstargetparams,
psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength); if (psFwInfo->u32FirmwareLength != sizeof(STARGETPARAMS))
if(retval) return -EIO;
{
retval = copy_from_user(Adapter->pstargetparams, psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength);
if (retval) {
kfree(Adapter->pstargetparams); kfree(Adapter->pstargetparams);
Adapter->pstargetparams = NULL; Adapter->pstargetparams = NULL;
return -EFAULT; return -EFAULT;
} }
/* Parse the structure and then Download the Firmware */ /* Parse the structure and then Download the Firmware */
beceem_parse_target_struct(Adapter); beceem_parse_target_struct(Adapter);
//Initializing the NVM. /* Initializing the NVM. */
BcmInitNVM(Adapter); BcmInitNVM(Adapter);
retval = InitLedSettings(Adapter);
retval = InitLedSettings (Adapter); if (retval) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "INIT LED Failed\n");
if(retval)
{
BCM_DEBUG_PRINT (Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "INIT LED Failed\n");
return retval; return retval;
} }
if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
{
Adapter->LEDInfo.bLedInitDone = FALSE; Adapter->LEDInfo.bLedInitDone = FALSE;
Adapter->DriverState = DRIVER_INIT; Adapter->DriverState = DRIVER_INIT;
wake_up(&Adapter->LEDInfo.notify_led_event); wake_up(&Adapter->LEDInfo.notify_led_event);
} }
if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
{
Adapter->DriverState = FW_DOWNLOAD; Adapter->DriverState = FW_DOWNLOAD;
wake_up(&Adapter->LEDInfo.notify_led_event); wake_up(&Adapter->LEDInfo.notify_led_event);
} }
/* Initialize the DDR Controller */ /* Initialize the DDR Controller */
retval = ddr_init(Adapter); retval = ddr_init(Adapter);
if(retval) if (retval) {
{ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Init Failed\n");
BCM_DEBUG_PRINT (Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Init Failed\n");
return retval; return retval;
} }
...@@ -205,197 +185,165 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter, ...@@ -205,197 +185,165 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter,
wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value)); wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value));
wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value)); wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value));
if(Adapter->eNVMType == NVM_FLASH) if (Adapter->eNVMType == NVM_FLASH) {
{
retval = PropagateCalParamsFromFlashToMemory(Adapter); retval = PropagateCalParamsFromFlashToMemory(Adapter);
if(retval) if (retval) {
{ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "propagaion of cal param failed with status :%d", retval);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"propagaion of cal param failed with status :%d", retval);
return retval; return retval;
} }
} }
retval = buffDnldVerify(Adapter, (PUCHAR)Adapter->pstargetparams, sizeof(STARGETPARAMS), CONFIG_BEGIN_ADDR);
retval =buffDnldVerify(Adapter,(PUCHAR)Adapter->pstargetparams,sizeof(STARGETPARAMS),CONFIG_BEGIN_ADDR); if (retval)
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "configuration file not downloaded properly");
if(retval)
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "configuration file not downloaded properly");
}
else else
Adapter->bCfgDownloaded = TRUE; Adapter->bCfgDownloaded = TRUE;
return retval; return retval;
} }
static int bcm_compare_buff_contents(unsigned char *readbackbuff,
unsigned char *buff,unsigned int len) static int bcm_compare_buff_contents(unsigned char *readbackbuff, unsigned char *buff, unsigned int len)
{ {
int retval = STATUS_SUCCESS; int retval = STATUS_SUCCESS;
PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
if((len-sizeof(unsigned int))<4) if ((len-sizeof(unsigned int)) < 4) {
{ if (memcmp(readbackbuff , buff, len))
if(memcmp(readbackbuff , buff, len)) retval = -EINVAL;
{ } else {
retval=-EINVAL; len -= 4;
}
} while (len) {
else if (*(unsigned int *)&readbackbuff[len] != *(unsigned int *)&buff[len]) {
{ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper");
len-=4; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&readbackbuff[len]);
while(len) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len);
{ retval = -EINVAL;
if(*(unsigned int*)&readbackbuff[len] !=
*(unsigned int *)&buff[len])
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper");
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&readbackbuff[len]);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len);
retval=-EINVAL;
break; break;
} }
len-=4; len -= 4;
} }
} }
return retval; return retval;
} }
int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo) int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo)
{ {
int retval = STATUS_SUCCESS; int retval = STATUS_SUCCESS;
PUCHAR buff = NULL; PUCHAR buff = NULL;
/* Config File is needed for the Driver to download the Config file and /* Config File is needed for the Driver to download the Config file and
Firmware. Check for the Config file to be first to be sent from the * Firmware. Check for the Config file to be first to be sent from the
Application * Application
*/ */
atomic_set (&Adapter->uiMBupdate, FALSE); atomic_set(&Adapter->uiMBupdate, FALSE);
if(!Adapter->bCfgDownloaded && if (!Adapter->bCfgDownloaded && psFwInfo->u32StartingAddress != CONFIG_BEGIN_ADDR) {
psFwInfo->u32StartingAddress != CONFIG_BEGIN_ADDR) /* Can't Download Firmware. */
{ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Download the config File first\n");
/*Can't Download Firmware.*/
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Download the config File first\n");
return -EINVAL; return -EINVAL;
} }
/* If Config File, Finish the DDR Settings and then Download CFG File */ /* If Config File, Finish the DDR Settings and then Download CFG File */
if(psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) if (psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR) {
{ retval = bcm_download_config_file(Adapter, psFwInfo);
retval = bcm_download_config_file (Adapter, psFwInfo); } else {
} buff = kzalloc(psFwInfo->u32FirmwareLength, GFP_KERNEL);
else if (buff == NULL) {
{ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed in allocation memory");
buff = kzalloc(psFwInfo->u32FirmwareLength,GFP_KERNEL);
if(buff==NULL)
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Failed in allocation memory");
return -ENOMEM; return -ENOMEM;
} }
retval = copy_from_user(buff,psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength);
if(retval != STATUS_SUCCESS) retval = copy_from_user(buff, psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength);
{ if (retval != STATUS_SUCCESS) {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copying buffer from user space failed"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copying buffer from user space failed");
retval = -EFAULT; retval = -EFAULT;
goto error ; goto error;
} }
retval = buffDnldVerify(Adapter, retval = buffDnldVerify(Adapter,
buff, buff,
psFwInfo->u32FirmwareLength, psFwInfo->u32FirmwareLength,
psFwInfo->u32StartingAddress); psFwInfo->u32StartingAddress);
if(retval != STATUS_SUCCESS)
{ if (retval != STATUS_SUCCESS) {
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"f/w download failed status :%d", retval); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "f/w download failed status :%d", retval);
goto error; goto error;
} }
} }
error: error:
kfree(buff); kfree(buff);
return retval; return retval;
} }
static INT buffDnld(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, static INT buffDnld(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress)
ULONG u32StartingAddress)
{ {
unsigned int len = 0;
unsigned int len = 0;
int retval = STATUS_SUCCESS; int retval = STATUS_SUCCESS;
len = u32FirmwareLength; len = u32FirmwareLength;
while(u32FirmwareLength) while (u32FirmwareLength) {
{ len = MIN_VAL(u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB);
len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); retval = wrm(Adapter, u32StartingAddress, mappedbuffer, len);
retval = wrm (Adapter, u32StartingAddress, mappedbuffer, len);
if(retval) if (retval) {
{ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "wrm failed with status :%d", retval);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "wrm failed with status :%d", retval);
break; break;
} }
u32StartingAddress += len; u32StartingAddress += len;
u32FirmwareLength -= len; u32FirmwareLength -= len;
mappedbuffer +=len; mappedbuffer += len;
} }
return retval; return retval;
} }
static INT buffRdbkVerify(PMINI_ADAPTER Adapter, static INT buffRdbkVerify(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress)
PUCHAR mappedbuffer, UINT u32FirmwareLength,
ULONG u32StartingAddress)
{ {
UINT len = u32FirmwareLength; UINT len = u32FirmwareLength;
INT retval = STATUS_SUCCESS; INT retval = STATUS_SUCCESS;
PUCHAR readbackbuff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB,GFP_KERNEL); PUCHAR readbackbuff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL);
if(NULL == readbackbuff) if (NULL == readbackbuff) {
{ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "MEMORY ALLOCATION FAILED");
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "MEMORY ALLOCATION FAILED");
return -ENOMEM; return -ENOMEM;
} }
while (u32FirmwareLength && !retval)
{
len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB); while (u32FirmwareLength && !retval) {
len = MIN_VAL(u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB);
retval = rdm(Adapter, u32StartingAddress, readbackbuff, len);
retval = rdm (Adapter, u32StartingAddress, readbackbuff, len); if (retval) {
if(retval) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "rdm failed with status %d", retval);
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "rdm failed with status %d" ,retval);
break; break;
} }
if (STATUS_SUCCESS != (retval = bcm_compare_buff_contents (readbackbuff, mappedbuffer, len))) if (STATUS_SUCCESS != (retval = bcm_compare_buff_contents(readbackbuff, mappedbuffer, len)))
{
break; break;
}
u32StartingAddress += len; u32StartingAddress += len;
u32FirmwareLength -= len; u32FirmwareLength -= len;
mappedbuffer +=len; mappedbuffer += len;
}/* end of while (u32FirmwareLength && !retval) */
} /* end of while (u32FirmwareLength && !retval) */
kfree(readbackbuff); kfree(readbackbuff);
return retval; return retval;
} }
INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, unsigned long u32StartingAddress)
unsigned long u32StartingAddress)
{ {
INT status = STATUS_SUCCESS; INT status = STATUS_SUCCESS;
status = buffDnld(Adapter,mappedbuffer,u32FirmwareLength,u32StartingAddress); status = buffDnld(Adapter, mappedbuffer, u32FirmwareLength, u32StartingAddress);
if(status != STATUS_SUCCESS) if (status != STATUS_SUCCESS) {
{ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Buffer download failed");
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Buffer download failed");
goto error; goto error;
} }
status= buffRdbkVerify(Adapter,mappedbuffer,u32FirmwareLength,u32StartingAddress); status = buffRdbkVerify(Adapter, mappedbuffer, u32FirmwareLength, u32StartingAddress);
if(status != STATUS_SUCCESS) if (status != STATUS_SUCCESS) {
{ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Buffer readback verifier failed");
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Buffer readback verifier failed");
goto error; goto error;
} }
error: error:
return status; return status;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment