Radeon backlight: Adjustments for radeonfb_bl_init()
cover Radeon backlight: Adjustments for radeonfb_bl_init()
From: Markus Elfring <[email protected]>
Date: Mon, 27 Nov 2017 22:14:04 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (5):
Delete an error message for a failed memory allocation Improve a size determination
Delete an unnecessary return statement
Return directly after a failed kmalloc() Delete a jump target
drivers/video/fbdev/aty/radeon_backlight.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
Signature · 1 line
2.15.0
PATCH 1/5 radeon_backlight: Delete an error message for a failed memory allocation in radeonfb_bl_init()
From: Markus Elfring <[email protected]>
Date: Mon, 27 Nov 2017 21:27:51 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/video/fbdev/aty/radeon_backlight.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/video/fbdev/aty/radeon_backlight.c +1 -3
@@ -144,10 +144,8 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo)#endif pdata =kmalloc (sizeof (struct radeon_bl_privdata ),GFP_KERNEL ); -if (!pdata) { -printk ("radeonfb: Memory allocation failed\n" ); +if (!pdata) goto error; - }snprintf (name,sizeof (name),"radeonbl%d" , rinfo->info->node);
Signature · 1 line
2.15.0
PATCH 2/5 radeon_backlight: Improve a size determination in radeonfb_bl_init()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 27 Nov 2017 21:30:06 +0100
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- drivers/video/fbdev/aty/radeon_backlight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/aty/radeon_backlight.c +1 -1
@@ -143,7 +143,7 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo)return ;#endif - pdata =kmalloc (sizeof (struct radeon_bl_privdata ),GFP_KERNEL ); + pdata =kmalloc (sizeof (*pdata),GFP_KERNEL );if (!pdata) goto error;
Signature · 1 line
2.15.0
PATCH 3/5 radeon_backlight: Delete an unnecessary return statement in radeonfb_bl_init()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 27 Nov 2017 21:37:52 +0100
The script "checkpatch.pl" pointed information out like the following.
WARNING: void function return statements are not generally useful
Thus remove such a statement in the affected function.
--- drivers/video/fbdev/aty/radeon_backlight.c | 1 - 1 file changed, 1 deletion(-)
drivers/video/fbdev/aty/radeon_backlight.c +0 -1
@@ -193,7 +193,6 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo) error:kfree (pdata); -return ; }void radeonfb_bl_exit (struct radeonfb_info *rinfo)
Signature · 1 line
2.15.0
PATCH 4/5 radeon_backlight: Return directly after a failed kmalloc() in radeonfb_bl_init()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 27 Nov 2017 21:50:28 +0100
Return directly after a call of the function "kmalloc" failed at the beginning.
--- drivers/video/fbdev/aty/radeon_backlight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/aty/radeon_backlight.c +1 -1
@@ -145,7 +145,7 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo) pdata =kmalloc (sizeof (*pdata),GFP_KERNEL );if (!pdata) - goto error; +return ;snprintf (name,sizeof (name),"radeonbl%d" , rinfo->info->node);
Signature · 1 line
2.15.0
PATCH 5/5 radeon_backlight: Delete a jump target in radeonfb_bl_init()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 27 Nov 2017 22:03:03 +0100
* Replace a goto statement by a direct call of the function "kfree" in an if branch.
* Delete the jump label "error" which became unnecessary with this refactoring.
--- drivers/video/fbdev/aty/radeon_backlight.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/video/fbdev/aty/radeon_backlight.c +2 -6
@@ -157,7 +157,8 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo)if (IS_ERR (bd)) { rinfo->info->bl_dev =NULL ;printk ("radeonfb: Backlight registration failed\n" ); - goto error; +kfree (pdata); +return ; } pdata->rinfo = rinfo;
@@ -188,11 +189,6 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo)backlight_update_status (bd);printk ("radeonfb: Backlight initialized (%s)\n" , name); - -return ; - -error: -kfree (pdata); }void radeonfb_bl_exit (struct radeonfb_info *rinfo)
Signature · 1 line
2.15.0