Skip to content

Commit

Permalink
Staging: bcm: Alter LOC for readability/understandability purposes
Browse files Browse the repository at this point in the history
This patch alters a line of code to make it more readable
and easier to understand. The purpose of the original line
of code was to compute the amount of memory to request from
kmalloc. This mulit-step algorithm was being done in one
line of code, thus making it more difficult to understand.
Therefore, I split this algorithm into three logical steps.

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 Sep 30, 2011
1 parent 0a2cc49 commit 2505aa6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/staging/bcm/Bcmchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
RDM_BUFFER sRdmBuffer = {0};
PCHAR temp_buff;
UINT Bufflen;
u16 temp_value;

/* Copy Ioctl Buffer structure */
if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
Expand All @@ -221,7 +222,10 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
return -EINVAL;
}

Bufflen = IoBuffer.OutputLength + (4 - IoBuffer.OutputLength%4)%4;
Bufflen = IoBuffer.OutputLength;
temp_value = 4 - (Bufflen % 4);
Bufflen += temp_value % 4;

temp_buff = kmalloc(Bufflen, GFP_KERNEL);
if (!temp_buff)
return -ENOMEM;
Expand Down

0 comments on commit 2505aa6

Please sign in to comment.