staging: fbtft: code cleanup patchset - checkpatch
Subsystems (2)
v3 cover staging: fbtft: code cleanup patchset - checkpatch
Implement code formatting corrections as flagged by checkpatch script. Common issues around lines exceeding 80 column limit and similar formatting issues for the fbtft driver files are considered in the scope of this patchset.
Note that top two patches in the list below were sent to the mailing list for review as individual patches earlier. As I found additional similar issues in the same area, I am requesting to combine these related patches in this patchset.
Changes since v2:
- Implement Corrections suggested by Stefano for [patch 1/4, 2/4, 3/4]:
1. Typos in patch description.
2. Improve variable name as per coding style guidelines.
- Advised following for Patch 4/4
1. Reviewed-by: Stefano Brivio <[email protected]>
Changes since v1:
- Corrections suggested by Julia for [patch 4 /4]:
1. Update commit message - use word "potential" in place of "likely".
2. Update log message - use word "parentheses" in place of "braces".
3. Rephrase log message - make it concise and easy to understand.
Deepak R Varma (4):
staging: fbtft: Reformat line over 80 characters
staging: fbtft: Reformat long macro definitions
staging: fbtft: simplify array index computation
staging: fbtft: Avoid potential precedence issues
drivers/staging/fbtft/fbtft-core.c | 4 +++- drivers/staging/fbtft/fbtft-sysfs.c | 6 +++++- drivers/staging/fbtft/fbtft.h | 18 +++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/4 staging: fbtft: Reformat line over 80 characters
A long variable name beyond 80 characters extends into the next line. Reformatting the line makes it more readable. Also adding an extra line for the next instruction following current if block helps understand it better.
--- drivers/staging/fbtft/fbtft-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/fbtft/fbtft-core.c +3 -1
@@ -1186,7 +1186,9 @@ static struct fbtft_platform_data *fbtft_properties_read(struct device *dev)if (device_property_present (dev,"led-gpios" )) pdata->display.backlight =1 ;if (device_property_present (dev,"init" )) - pdata->display.fbtftops.init_display = fbtft_init_display_from_property; + pdata->display.fbtftops.init_display = + fbtft_init_display_from_property; + pdata->display.fbtftops.request_gpios = fbtft_request_gpios;return pdata;
Signature · 1 line
2.17.1
PATCH v3 2/4 staging: fbtft: Reformat long macro definitions
In reply to Deepak R VarmaMultiple macro definitions crossing 80 character line length makes them hard to understand. Reformatting the these lines makes the code more readable and easier to understand. Issue flagged by checkpatch script.
--- drivers/staging/fbtft/fbtft.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/staging/fbtft/fbtft.h +11 -3
@@ -348,9 +348,17 @@ module_exit(fbtft_driver_module_exit);/* shorthand debug levels */ #define DEBUG_LEVEL_1 DEBUG_REQUEST_GPIOS -#define DEBUG_LEVEL_2 (DEBUG_LEVEL_1 | DEBUG_DRIVER_INIT_FUNCTIONS | DEBUG_TIME_FIRST_UPDATE) -#define DEBUG_LEVEL_3 (DEBUG_LEVEL_2 | DEBUG_RESET | DEBUG_INIT_DISPLAY | DEBUG_BLANK | DEBUG_REQUEST_GPIOS | DEBUG_FREE_GPIOS | DEBUG_VERIFY_GPIOS | DEBUG_BACKLIGHT | DEBUG_SYSFS) -#define DEBUG_LEVEL_4 (DEBUG_LEVEL_2 | DEBUG_FB_READ | DEBUG_FB_WRITE | DEBUG_FB_FILLRECT | DEBUG_FB_COPYAREA | DEBUG_FB_IMAGEBLIT | DEBUG_FB_BLANK) +#define DEBUG_LEVEL_2 (DEBUG_LEVEL_1 | DEBUG_DRIVER_INIT_FUNCTIONS \ + | DEBUG_TIME_FIRST_UPDATE) +#define DEBUG_LEVEL_3 (DEBUG_LEVEL_2 | DEBUG_RESET | DEBUG_INIT_DISPLAY \ + | DEBUG_BLANK | DEBUG_REQUEST_GPIOS \ + | DEBUG_FREE_GPIOS \ + | DEBUG_VERIFY_GPIOS \ + | DEBUG_BACKLIGHT | DEBUG_SYSFS) +#define DEBUG_LEVEL_4 (DEBUG_LEVEL_2 | DEBUG_FB_READ | DEBUG_FB_WRITE \ + | DEBUG_FB_FILLRECT \ + | DEBUG_FB_COPYAREA \ + | DEBUG_FB_IMAGEBLIT | DEBUG_FB_BLANK)#define DEBUG_LEVEL_5 (DEBUG_LEVEL_3 | DEBUG_UPDATE_DISPLAY)#define DEBUG_LEVEL_6 (DEBUG_LEVEL_4 | DEBUG_LEVEL_5)#define DEBUG_LEVEL_7 0xFFFFFFFF
Signature · 1 line
2.17.1
PATCH v3 3/4 staging: fbtft: simplify array index computation
In reply to Deepak R VarmaAn array index is being computed by mathematical calculation on the Lvalue side of the expression. This also further results in the statement exceeding 80 character statement length.
A local variable can store the value of the array index computation. The variable can then be used as array index. This improves readability of the code and also address 80 character warning raised by checkpatch.
--- drivers/staging/fbtft/fbtft-sysfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/staging/fbtft/fbtft-sysfs.c +5 -1
@@ -25,6 +25,7 @@ int fbtft_gamma_parse_str(struct fbtft_par *par, u32 *curves,unsigned long val =0 ;int ret =0 ;int curve_counter, value_counter; +int _count;fbtft_par_dbg (DEBUG_SYSFS , par,"%s() str=\n" , __func__);
@@ -68,7 +69,10 @@ int fbtft_gamma_parse_str(struct fbtft_par *par, u32 *curves, ret =get_next_ulong (&curve_p, &val," " ,16 );if (ret) goto out; - curves[curve_counter * par->gamma.num_values + value_counter] = val; + + _count = curve_counter * par->gamma.num_values + + value_counter; + curves[_count] = val; value_counter++; }if (value_counter != par->gamma.num_values) {
Signature · 1 line
2.17.1
PATCH v3 4/4 staging: fbtft: Avoid potential precedence issues
In reply to Deepak R VarmaPut parentheses around uses of macro parameters to avoid possible precedence issues. Problem detected by checkpatch.
--- drivers/staging/fbtft/fbtft.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/fbtft/fbtft.h +2 -2
@@ -406,8 +406,8 @@ do { \ #define fbtft_par_dbg(level, par, format, arg...) \ do { \ - if (unlikely(par->debug & level)) \ - dev_info(par->info->device, format, ##arg); \ + if (unlikely((par)->debug & (level))) \ + dev_info((par)->info->device, format, ##arg); \ } while (0) #define fbtft_par_dbg_hex(level, par, dev, type, buf, num, format, arg...) \
Signature · 1 line
2.17.1
Re: [Outreachy kernel] [PATCH 4/4] staging: fbtft: Avoid potential precedence issues
By "carrying" the tag I really meant that you would, here (not in the cover letter), add:
Quoted 4 lines · On Mon, 16 Mar 2020 05:12:32 +0530 Deepak R Varma <[email protected]> wrote:
Put parentheses around uses of macro parameters to avoid possible precedence issues. Problem detected by checkpatch.
Signed-off-by Deepak R Varma <[email protected]>
"Reviewed-by: Stefano Brivio <[email protected]>"
after your Signed-off-by. Mind, however, that you should only do this in case the reviewer tells you explicitly (I've seen it being done implicitly, with myself and others, it's really not nice).
In any case,
(will check the rest later).
Signature · 1 line
Stefano
Re: [Outreachy kernel] [PATCH 4/4] staging: fbtft: Avoid potential precedence issues
Quoted 18 lines · Stefano Brivio
By "carrying" the tag I really meant that you would, here (not in the cover letter), add:
Quoted 4 lines · On Mon, 16 Mar 2020 05:12:32 +0530 Deepak R Varma <[email protected]…
Put parentheses around uses of macro parameters to avoid possible precedence issues. Problem detected by checkpatch.
Signed-off-by Deepak R Varma <[email protected] <javascript:>>"Reviewed-by: Stefano Brivio <[email protected] <javascript:>>"
after your Signed-off-by. Mind, however, that you should only do this in case the reviewer tells you explicitly (I've seen it being done implicitly, with myself and others, it's really not nice).
Quoted 9 lines
In any case,
Reviewed-by Stefano Brivio <[email protected] <javascript:>>(will check the rest later).
Signature · 1 line
Stefano
My apologies for any confusion. I learned it now. will take care going forward.
Thank you,
Deepak.
Greg KH
maintainerRe: [PATCH 4/4] staging: fbtft: Avoid potential precedence issues
In reply to Deepak R VarmaQuoted 14 lines · Deepak R Varma
Put parentheses around uses of macro parameters to avoid possible precedence issues. Problem detected by checkpatch.
Signed-off-by Deepak R Varma <[email protected]>Reviewed-by Stefano Brivio <[email protected]>--- drivers/staging/fbtft/fbtft.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/fbtft/fbtft.h +0
-0
drivers/staging/fbtft/fbtft.h do { \ · line 410
Quoted 7 lines
drivers/staging/fbtft/fbtft.h +2
-2@@ -406,8 +406,8 @@ do { \ #define fbtft_par_dbg(level, par, format, arg...) \ do { \ - if (unlikely(par->debug & level)) \ - dev_info(par->info->device, format, ##arg); \ + if (unlikely((par)->debug & (level))) \ + dev_info((par)->info->device, format, ##arg); \
"precedence issues" are impossible to happen here, it's a pointer that we are dealing with, not some other type of expression.
So I'll take this, just to shut checkpatch up, but note that this is _NOT_ a real issue at all.
And what about all of the other macros like this in this file? Does only this one need the changes?
thanks,
greg k-h
Re: [PATCH 4/4] staging: fbtft: Avoid potential precedence issues
Quoted 26 lines · Greg KH
Quoted 14 lines · Deepak R Varma
Put parentheses around uses of macro parameters to avoid possible precedence issues. Problem detected by checkpatch.
Signed-off-by Deepak R Varma <[email protected]>Reviewed-by Stefano Brivio <[email protected]>--- drivers/staging/fbtft/fbtft.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/fbtft/fbtft.h +0
-0drivers/staging/fbtft/fbtft.h do { \ · line 410
Quoted 7 lines
drivers/staging/fbtft/fbtft.h +2
-2@@ -406,8 +406,8 @@ do { \ #define fbtft_par_dbg(level, par, format, arg...) \ do { \ - if (unlikely(par->debug & level)) \ - dev_info(par->info->device, format, ##arg); \ + if (unlikely((par)->debug & (level))) \ + dev_info((par)->info->device, format, ##arg); \"precedence issues" are impossible to happen here, it's a pointer that we are dealing with, not some other type of expression.
Quoted 2 lines
So I'll take this, just to shut checkpatch up, but note that this is _NOT_ a real issue at all.
Thank you Greg.
Quoted 3 lines
And what about all of the other macros like this in this file? Does only this one need the changes?
There is one more macro that accepts arguments, but its already fixed in the past. I did not find any other macro with similar checkpatch warning.
Quoted 4 lines
thanks,
greg k-h
Re: [PATCH 4/4] staging: fbtft: Avoid potential precedence issues
In reply to Greg KHQuoted 26 lines · Greg KH
Quoted 14 lines · Deepak R Varma
Put parentheses around uses of macro parameters to avoid possible precedence issues. Problem detected by checkpatch.
Signed-off-by Deepak R Varma <[email protected]>Reviewed-by Stefano Brivio <[email protected]>--- drivers/staging/fbtft/fbtft.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/fbtft/fbtft.h +0
-0drivers/staging/fbtft/fbtft.h do { \ · line 410
Quoted 7 lines
drivers/staging/fbtft/fbtft.h +2
-2@@ -406,8 +406,8 @@ do { \ #define fbtft_par_dbg(level, par, format, arg...) \ do { \ - if (unlikely(par->debug & level)) \ - dev_info(par->info->device, format, ##arg); \ + if (unlikely((par)->debug & (level))) \ + dev_info((par)->info->device, format, ##arg); \"precedence issues" are impossible to happen here, it's a pointer that we are dealing with, not some other type of expression.
Quoted 6 lines
So I'll take this, just to shut checkpatch up, but note that this is _NOT_ a real issue at all.
And what about all of the other macros like this in this file? Does only this one need the changes?
No Greg, other macros are either taken care of earlier or do not need similar consideration.
Thank you.
Quoted 3 lines
thanks,
greg k-h