Staging: bcm: Alter code to move error handling closer to the calls.
This is a cleanup patch. I've shuffled the code around to move the error handling closer to the calls. I've removed some indent levels. I've replaced break statements with direct returns. Signed-off-by: Kevin McKinney <klmckinney1@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
fef5675ecb
commit
8fbebb091a
@ -765,27 +765,26 @@ cntrlEnd:
|
|||||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
|
||||||
"Starting the firmware download PID =0x%x!!!!\n", current->pid);
|
"Starting the firmware download PID =0x%x!!!!\n", current->pid);
|
||||||
|
|
||||||
if (!down_trylock(&Adapter->fw_download_sema)) {
|
if (down_trylock(&Adapter->fw_download_sema))
|
||||||
Adapter->bBinDownloaded = FALSE;
|
return -EBUSY;
|
||||||
Adapter->fw_download_process_pid = current->pid;
|
|
||||||
Adapter->bCfgDownloaded = FALSE;
|
Adapter->bBinDownloaded = FALSE;
|
||||||
Adapter->fw_download_done = FALSE;
|
Adapter->fw_download_process_pid = current->pid;
|
||||||
netif_carrier_off(Adapter->dev);
|
Adapter->bCfgDownloaded = FALSE;
|
||||||
netif_stop_queue(Adapter->dev);
|
Adapter->fw_download_done = FALSE;
|
||||||
Status = reset_card_proc(Adapter);
|
netif_carrier_off(Adapter->dev);
|
||||||
if (Status) {
|
netif_stop_queue(Adapter->dev);
|
||||||
pr_err(PFX "%s: reset_card_proc Failed!\n", Adapter->dev->name);
|
Status = reset_card_proc(Adapter);
|
||||||
up(&Adapter->fw_download_sema);
|
if (Status) {
|
||||||
up(&Adapter->NVMRdmWrmLock);
|
pr_err(PFX "%s: reset_card_proc Failed!\n", Adapter->dev->name);
|
||||||
break;
|
up(&Adapter->fw_download_sema);
|
||||||
}
|
up(&Adapter->NVMRdmWrmLock);
|
||||||
mdelay(10);
|
return Status;
|
||||||
} else {
|
|
||||||
Status = -EBUSY;
|
|
||||||
}
|
}
|
||||||
|
mdelay(10);
|
||||||
|
|
||||||
up(&Adapter->NVMRdmWrmLock);
|
up(&Adapter->NVMRdmWrmLock);
|
||||||
break;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IOCTL_BCM_BUFFER_DOWNLOAD: {
|
case IOCTL_BCM_BUFFER_DOWNLOAD: {
|
||||||
@ -797,7 +796,7 @@ cntrlEnd:
|
|||||||
"Invalid way to download buffer. Use Start and then call this!!!\n");
|
"Invalid way to download buffer. Use Start and then call this!!!\n");
|
||||||
up(&Adapter->fw_download_sema);
|
up(&Adapter->fw_download_sema);
|
||||||
Status = -EINVAL;
|
Status = -EINVAL;
|
||||||
break;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy Ioctl Buffer structure */
|
/* Copy Ioctl Buffer structure */
|
||||||
@ -832,7 +831,7 @@ cntrlEnd:
|
|||||||
psFwInfo->u32FirmwareLength);
|
psFwInfo->u32FirmwareLength);
|
||||||
up(&Adapter->fw_download_sema);
|
up(&Adapter->fw_download_sema);
|
||||||
Status = -EINVAL;
|
Status = -EINVAL;
|
||||||
break;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = bcm_ioctl_fw_download(Adapter, psFwInfo);
|
Status = bcm_ioctl_fw_download(Adapter, psFwInfo);
|
||||||
@ -857,7 +856,7 @@ cntrlEnd:
|
|||||||
|
|
||||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n");
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n");
|
||||||
kfree(psFwInfo);
|
kfree(psFwInfo);
|
||||||
break;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: {
|
case IOCTL_BCM_BUFFER_DOWNLOAD_STOP: {
|
||||||
@ -868,59 +867,60 @@ cntrlEnd:
|
|||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (down_trylock(&Adapter->fw_download_sema)) {
|
if (!down_trylock(&Adapter->fw_download_sema)) {
|
||||||
Adapter->bBinDownloaded = TRUE;
|
up(&Adapter->fw_download_sema);
|
||||||
Adapter->bCfgDownloaded = TRUE;
|
return -EINVAL;
|
||||||
atomic_set(&Adapter->CurrNumFreeTxDesc, 0);
|
|
||||||
Adapter->CurrNumRecvDescs = 0;
|
|
||||||
Adapter->downloadDDR = 0;
|
|
||||||
|
|
||||||
/* setting the Mips to Run */
|
|
||||||
Status = run_card_proc(Adapter);
|
|
||||||
|
|
||||||
if (Status) {
|
|
||||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Firm Download Failed\n");
|
|
||||||
up(&Adapter->fw_download_sema);
|
|
||||||
up(&Adapter->NVMRdmWrmLock);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG,
|
|
||||||
DBG_LVL_ALL, "Firm Download Over...\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
mdelay(10);
|
|
||||||
|
|
||||||
/* Wait for MailBox Interrupt */
|
|
||||||
if (StartInterruptUrb((PS_INTERFACE_ADAPTER)Adapter->pvInterfaceAdapter))
|
|
||||||
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to send interrupt...\n");
|
|
||||||
|
|
||||||
timeout = 5*HZ;
|
|
||||||
Adapter->waiting_to_fw_download_done = FALSE;
|
|
||||||
wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue,
|
|
||||||
Adapter->waiting_to_fw_download_done, timeout);
|
|
||||||
Adapter->fw_download_process_pid = INVALID_PID;
|
|
||||||
Adapter->fw_download_done = TRUE;
|
|
||||||
atomic_set(&Adapter->CurrNumFreeTxDesc, 0);
|
|
||||||
Adapter->CurrNumRecvDescs = 0;
|
|
||||||
Adapter->PrevNumRecvDescs = 0;
|
|
||||||
atomic_set(&Adapter->cntrlpktCnt, 0);
|
|
||||||
Adapter->LinkUpStatus = 0;
|
|
||||||
Adapter->LinkStatus = 0;
|
|
||||||
|
|
||||||
if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
|
|
||||||
Adapter->DriverState = FW_DOWNLOAD_DONE;
|
|
||||||
wake_up(&Adapter->LEDInfo.notify_led_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!timeout)
|
|
||||||
Status = -ENODEV;
|
|
||||||
} else {
|
|
||||||
Status = -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Adapter->bBinDownloaded = TRUE;
|
||||||
|
Adapter->bCfgDownloaded = TRUE;
|
||||||
|
atomic_set(&Adapter->CurrNumFreeTxDesc, 0);
|
||||||
|
Adapter->CurrNumRecvDescs = 0;
|
||||||
|
Adapter->downloadDDR = 0;
|
||||||
|
|
||||||
|
/* setting the Mips to Run */
|
||||||
|
Status = run_card_proc(Adapter);
|
||||||
|
|
||||||
|
if (Status) {
|
||||||
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Firm Download Failed\n");
|
||||||
|
up(&Adapter->fw_download_sema);
|
||||||
|
up(&Adapter->NVMRdmWrmLock);
|
||||||
|
return Status;
|
||||||
|
} else {
|
||||||
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG,
|
||||||
|
DBG_LVL_ALL, "Firm Download Over...\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
mdelay(10);
|
||||||
|
|
||||||
|
/* Wait for MailBox Interrupt */
|
||||||
|
if (StartInterruptUrb((PS_INTERFACE_ADAPTER)Adapter->pvInterfaceAdapter))
|
||||||
|
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to send interrupt...\n");
|
||||||
|
|
||||||
|
timeout = 5*HZ;
|
||||||
|
Adapter->waiting_to_fw_download_done = FALSE;
|
||||||
|
wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue,
|
||||||
|
Adapter->waiting_to_fw_download_done, timeout);
|
||||||
|
Adapter->fw_download_process_pid = INVALID_PID;
|
||||||
|
Adapter->fw_download_done = TRUE;
|
||||||
|
atomic_set(&Adapter->CurrNumFreeTxDesc, 0);
|
||||||
|
Adapter->CurrNumRecvDescs = 0;
|
||||||
|
Adapter->PrevNumRecvDescs = 0;
|
||||||
|
atomic_set(&Adapter->cntrlpktCnt, 0);
|
||||||
|
Adapter->LinkUpStatus = 0;
|
||||||
|
Adapter->LinkStatus = 0;
|
||||||
|
|
||||||
|
if (Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY) {
|
||||||
|
Adapter->DriverState = FW_DOWNLOAD_DONE;
|
||||||
|
wake_up(&Adapter->LEDInfo.notify_led_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!timeout)
|
||||||
|
Status = -ENODEV;
|
||||||
|
|
||||||
up(&Adapter->fw_download_sema);
|
up(&Adapter->fw_download_sema);
|
||||||
up(&Adapter->NVMRdmWrmLock);
|
up(&Adapter->NVMRdmWrmLock);
|
||||||
break;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IOCTL_BE_BUCKET_SIZE:
|
case IOCTL_BE_BUCKET_SIZE:
|
||||||
|
Loading…
Reference in New Issue
Block a user