Skip to content

Commit

Permalink
Staging: bcm: Alter code to move error handling closer to the calls; …
Browse files Browse the repository at this point in the history
…and remove white space, IOCTL_BCM_NVM_WRITE.

This is a clean up patch for IOCTL_BCM_NVM_WRITE
that replaces the assignment of the Status
variable with direct returns of the error code,
replaces the break statements with direct returns,
and removes a white space.

Signed-off-by: Kevin McKinney <klmckinney1@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Kevin McKinney authored and Greg Kroah-Hartman committed Dec 8, 2011
1 parent 09468b0 commit 6561f91
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions drivers/staging/bcm/Bcmchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1269,8 +1269,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
memset(&tv1, 0, sizeof(struct timeval));
if ((Adapter->eNVMType == NVM_FLASH) && (Adapter->uiFlashLayoutMajorVersion == 0)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n");
Status = -EFAULT;
break;
return -EFAULT;
}

if (IsFlash2x(Adapter)) {
Expand All @@ -1279,7 +1278,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
(Adapter->eActiveDSD != DSD2)) {

BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No DSD is active..hence NVM Command is blocked");
return STATUS_FAILURE ;
return STATUS_FAILURE;
}
}

Expand All @@ -1298,18 +1297,16 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)

if ((stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) > Adapter->uiNVMDSDSize) {
/* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Can't allow access beyond NVM Size: 0x%x 0x%x\n", stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes); */
Status = STATUS_FAILURE;
break;
return STATUS_FAILURE;
}

pReadData = kzalloc(stNVMReadWrite.uiNumBytes, GFP_KERNEL);
if (!pReadData)
return -ENOMEM;

if (copy_from_user(pReadData, stNVMReadWrite.pBuffer, stNVMReadWrite.uiNumBytes)) {
Status = -EFAULT;
kfree(pReadData);
break;
return -EFAULT;
}

do_gettimeofday(&tv0);
Expand Down Expand Up @@ -1404,9 +1401,8 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " timetaken by Write/read :%ld msec\n", (tv1.tv_sec - tv0.tv_sec)*1000 + (tv1.tv_usec - tv0.tv_usec)/1000);

kfree(pReadData);
Status = STATUS_SUCCESS;
return STATUS_SUCCESS;
}
break;

case IOCTL_BCM_FLASH2X_SECTION_READ: {
FLASH2X_READWRITE sFlash2xRead = {0};
Expand Down

0 comments on commit 6561f91

Please sign in to comment.