Skip to contentSkip to conversation

Staging: fbtft: Added blank line after declaration

PATCH In review aybuke ozdemir 2 participants 6 messages Feb 19, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Staging: fbtft: Added blank line after declaration

WARNING: Missing a blank line after declaration
chackpatch.pl warning in fb_ssd1351.c

---
 drivers/staging/fbtft/fb_ssd1351.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/fbtft/fb_ssd1351.c +1 -0
index 062d986..b59120c 100644
@@ -72,6 +72,7 @@ static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
 static int set_var(struct fbtft_par *par)
 {
 	unsigned remap;
+
 	fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
 
 	if (par->fbtftops.init_display != init_display) {
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 Staging: fbtft: Fix struct backlight_ops should normally be const

This patch fixes following checkpatch.pl warningi in fb_ssd1351.c:
WARNING: struct backlight_ops should normally be const

---
 drivers/staging/fbtft/fb_ssd1351.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/fbtft/fb_ssd1351.c +2 -2
index b59120c..bc4d188 100644
@@ -212,11 +212,11 @@ static void register_onboard_backlight(struct fbtft_par *par)
 {
 	struct backlight_device *bd;
 	struct backlight_properties bl_props = { 0, };
-	struct backlight_ops *bl_ops;
+	const struct backlight_ops *bl_ops;
 
 	fbtft_par_dbg(DEBUG_BACKLIGHT, par, "%s()\n", __func__);
 
-	bl_ops = devm_kzalloc(par->info->device, sizeof(struct backlight_ops),
+	bl_ops = devm_kzalloc(par->info->device, sizeof(const struct backlight_ops),
 				GFP_KERNEL);
 	if (!bl_ops) {
 		dev_err(par->info->device,
Signature · 1 line
1.9.1
#2 lore raw

Re: [Outreachy kernel] [PATCH 2/2] Staging: fbtft: Fix struct backlight_ops should normally be const

Hi Aybuke,

Thank you for the patch.

Quoted 2 lines · On Thursday 19 February 2015 20:42:44 aybuke ozdemir wrote:

This patch fixes following checkpatch.pl warningi in fb_ssd1351.c:
WARNING: struct backlight_ops should normally be const

A good commit message is split in two parts:

- The subject line should summarize what the commit does. In this case, you could say "staging: fbtft: Make struct backlight_ops const".

- The commit message body should explain why the change is needed. There's a reason behind checkpatch warnings, they indicate issues with the code. You should try to understand why a non-const struct backlight_ops is an issue, and explain it. In this case the reason why struct backlight_ops is usually const would lead to a totally different fix than the one below.

Quoted 10 lines
---
 drivers/staging/fbtft/fb_ssd1351.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/fbtft/fb_ssd1351.c index b59120c..bc4d188 100644

drivers/staging/fbtft/fb_ssd1351.c static void register_onboard_backlight(struct · line 215

Quoted 5 lines
drivers/staging/fbtft/fb_ssd1351.c +1 -1
@@ -212,11 +212,11 @@ static void register_onboard_backlight(struct
 fbtft_par *par) {
 	struct backlight_device *bd;
 	struct backlight_properties bl_props = { 0, };
-	struct backlight_ops *bl_ops;
+	const struct backlight_ops *bl_ops;

This introduces a compilation error as the code later assigns bl_ops-

Quoted 1 line

update_status. Please make sure you always at least compile the code before

submitting a patch.

Quoted 5 lines
drivers/staging/fbtft/fb_ssd1351.c +1 -1
 	fbtft_par_dbg(DEBUG_BACKLIGHT, par, "%s()\n", __func__);
 
-	bl_ops = devm_kzalloc(par->info->device, sizeof(struct backlight_ops),
+	bl_ops = devm_kzalloc(par->info->device, sizeof(const struct

backlight_ops),

The kernel coding style tends to favour sizeof(var) instead of sizeof(type). In this case this would become sizeof(*bl_ops). This ensures that the size stays correct if the type of the variable is changed.

Quoted 3 lines

GFP_KERNEL);

drivers/staging/fbtft/fb_ssd1351.c +0 -0
 	if (!bl_ops) {
 		dev_err(par->info->device,
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

Re: [Outreachy kernel] [PATCH 2/2] Staging: fbtft: Fix struct backlight_ops should normally be const

Hi Laurent,

I will pay much more attention to the commit messages and subject line. I use this command while compiling this file: make M=drivers/staging/fbtft I didn't encounter a problem. I guess, I'm using the wrong the "make" command.
Thanks :)

2015-02-19 20:52 GMT+02:00 Laurent Pinchart <
[email protected]>:

Quoted 65 lines

Hi Aybuke,

Thank you for the patch.

Quoted 2 lines · On Thursday 19 February 2015 20:42:44 aybuke ozdemir wrote:

This patch fixes following checkpatch.pl warningi in fb_ssd1351.c:
WARNING: struct backlight_ops should normally be const

A good commit message is split in two parts:

- The subject line should summarize what the commit does. In this case, you could say "staging: fbtft: Make struct backlight_ops const".

- The commit message body should explain why the change is needed. There's a
reason behind checkpatch warnings, they indicate issues with the code. You should try to understand why a non-const struct backlight_ops is an issue, and
explain it. In this case the reason why struct backlight_ops is usually const
would lead to a totally different fix than the one below.

Quoted 10 lines
---
 drivers/staging/fbtft/fb_ssd1351.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/fbtft/fb_ssd1351.c index b59120c..bc4d188 100644

drivers/staging/fbtft/fb_ssd1351.c static void register_onboard_backlight(struct · line 215

Quoted 5 lines
drivers/staging/fbtft/fb_ssd1351.c +1 -1
@@ -212,11 +212,11 @@ static void register_onboard_backlight(struct
 fbtft_par *par) {
      struct backlight_device *bd;
      struct backlight_properties bl_props = { 0, };
-     struct backlight_ops *bl_ops;
+     const struct backlight_ops *bl_ops;

This introduces a compilation error as the code later assigns bl_ops-

Quoted 1 line

update_status. Please make sure you always at least compile the code

before
submitting a patch.

Quoted 3 lines
      fbtft_par_dbg(DEBUG_BACKLIGHT, par, "%s()\n", __func__);

- bl_ops = devm_kzalloc(par->info->device, sizeof(struct

backlight_ops),

Quoted 2 lines

+ bl_ops = devm_kzalloc(par->info->device, sizeof(const struct
backlight_ops),

The kernel coding style tends to favour sizeof(var) instead of sizeof(type).
In this case this would become sizeof(*bl_ops). This ensures that the size stays correct if the type of the variable is changed.

Quoted 3 lines
GFP_KERNEL);
      if (!bl_ops) {
              dev_err(par->info->device,

--
Regards,

Laurent Pinchart

Signature · 2 lines
Aybüke Özdemir
http://www.aybukeozdemir.com
#4 lore raw

Re: [Outreachy kernel] [PATCH 2/2] Staging: fbtft: Fix struct backlight_ops should normally be const

Hi Aybüke,

Quoted 6 lines · On Thursday 19 February 2015 21:43:22 aybüke özdemir wrote:

Hi Laurent,

I will pay much more attention to the commit messages and subject line. I use this command while compiling this file: make M=drivers/staging/fbtft I didn't encounter a problem. I guess, I'm using the wrong the "make" command.

The command is correct, but you also need to make sure that the driver is selected in the kernel configuration, otherwise it won't get compiled.

A good way to find out whether a .c source file has been compiled is to check that a .o file with the same base name has been created in the same directory. The kernel build system should also print

CC drivers/staging/fbtft/fb_ssd1351.o

during compilation.

Signature · 3 lines
Regards,

Laurent Pinchart
#5 lore raw

Re: [Outreachy kernel] [PATCH 2/2] Staging: fbtft: Fix struct backlight_ops should normally be const

Many thanks for clarifying, When I compile , I will consider your description :)

2015-02-19 22:13 GMT+02:00 Laurent Pinchart <
[email protected]>:

Quoted 30 lines

Hi Aybüke,

Quoted 4 lines · On Thursday 19 February 2015 21:43:22 aybüke özdemir wrote:

Hi Laurent,

I will pay much more attention to the commit messages and subject line. I use this command while compiling this file: make M=drivers/staging/fbtft

I

Quoted 2 lines

didn't encounter a problem. I guess, I'm using the wrong the "make" command.

The command is correct, but you also need to make sure that the driver is selected in the kernel configuration, otherwise it won't get compiled.

A good way to find out whether a .c source file has been compiled is to check
that a .o file with the same base name has been created in the same directory.
The kernel build system should also print

CC drivers/staging/fbtft/fb_ssd1351.o

during compilation.

--
Regards,

Laurent Pinchart

Signature · 2 lines
Aybüke Özdemir
http://www.aybukeozdemir.com