[PATCH 0/5] staging: rts5208: clean up coding style in rtsx_chip.c

Giedrius Statkevicius giedrius.statkevicius at gmail.com
Fri Oct 3 20:27:03 UTC 2014

From: Giedrius Statkevičius <giedrius.statkevicius at gmail.com>

Align divided lines to the first line's opening paranthesis
Where two or more if's are in form 'if (a) if (b) { [...] }' convert them into one to lower the indentation level.
Use the ternary operator in places where there is code in format of: 'if (a) { b = foo1; } else { b = foo2; }'
Make the names of labels all lower case to avoid Camel Case.
Remove unnecessary parantheses around variables that are after a dereference operator like this: '&(a) => &a'
Switch the if condition around in 'if (0 == (value & (1 << bit))) {' to make it have the same form as the rest of the code.

After this patch checkpatch.pl without --strict doesn't complain about rtsx_chip.c at all and with --strict it only complains about the unmatched parantheses. I am reluctant to move that code with unmatched parantheses into another function to lower the indentation level because I don't have the hardware needed to test this driver and don't have enough experience to do it properly. Doing so would just probably hide the other problems this code has. My patch is purely about changing the code style without creating more functions and moving code to them. 

This patch is against Greg KH's staging-next tree.

Giedrius Statkevičius (5):
  Combine ifs into one where possible to avoid unnecessary indentation
    level increase
  Convert Camel Case labels to lower case, remove unnecessary
    parantheses after a dereference operator and remove empty lines
    before }
  Align lines of divided lines to the opening paranthesis where
  Divide lines to make them less than 80 characters long, align to the
    opening paranthesis where possible
  Use ternary operators where possible and sensible to avoid unnecessary
    increase of indentation level

 drivers/staging/rts5208/rtsx_chip.c | 322 +++++++++++++++---------------------
 1 file changed, 136 insertions(+), 186 deletions(-)


More information about the devel mailing list