video: sm501fb: Adjustments for seven function implementations
Subsystems (2)
cover video: sm501fb: Adjustments for seven function implementations
From: Markus Elfring <[email protected]>
Date: Sun, 26 Nov 2017 11:10:01 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (4):
Delete error messages for a failed memory allocation in two functions Improve a size determination in sm501fb_probe()
Combine substrings for four messages
Adjust 15 checks for null pointers
drivers/video/fbdev/sm501fb.c | 66 ++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 38 deletions(-)
Signature · 1 line
2.15.0
PATCH 1/4 video: sm501fb: Delete error messages for a failed memory allocation in two functions
From: Markus Elfring <[email protected]>
Date: Sun, 26 Nov 2017 10:10:31 +0100
Omit extra messages for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
--- drivers/video/fbdev/sm501fb.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/video/fbdev/sm501fb.c +3 -9
@@ -1934,10 +1934,8 @@ static int sm501fb_probe(struct platform_device *pdev)/* allocate our framebuffers */ info =kzalloc (sizeof (struct sm501fb_info ),GFP_KERNEL ); -if (!info) { -dev_err (dev,"failed to allocate state\n" ); +if (!info)return -ENOMEM ; - } info->dev = dev = &pdev->dev;platform_set_drvdata (pdev, info);
@@ -2121,16 +2119,12 @@ static int sm501fb_suspend_fb(struct sm501fb_info *info,/* backup copies in case chip is powered down over suspend */ par->store_fb =vmalloc (par->screen.size); -if (par->store_fb ==NULL ) { -dev_err (info->dev,"no memory to store screen\n" ); +if (!par->store_fb)return -ENOMEM ; - } par->store_cursor =vmalloc (par->cursor.size); -if (par->store_cursor ==NULL ) { -dev_err (info->dev,"no memory to store cursor\n" ); +if (!par->store_cursor) goto err_nocursor; - }dev_dbg (info->dev,"suspending screen to %p\n" , par->store_fb);dev_dbg (info->dev,"suspending cursor to %p\n" , par->store_cursor);
Signature · 1 line
2.15.0
PATCH 2/4 video: sm501fb: Improve a size determination in sm501fb_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 26 Nov 2017 10:22:37 +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/sm501fb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/sm501fb.c +1 -2
@@ -1932,8 +1932,7 @@ static int sm501fb_probe(struct platform_device *pdev)int ret;/* allocate our framebuffers */ - - info =kzalloc (sizeof (struct sm501fb_info ),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ;
Signature · 1 line
2.15.0
PATCH 3/4 video: sm501fb: Combine substrings for four messages
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 26 Nov 2017 10:43:36 +0100
The script "checkpatch.pl" pointed information out like the following.
WARNING: quoted string split across lines
Thus fix four source code places.
--- drivers/video/fbdev/sm501fb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/video/fbdev/sm501fb.c +10 -10
@@ -510,10 +510,10 @@ static int sm501fb_set_par_common(struct fb_info *info,/* update fb layer with actual clock used */ var->pixclock =sm501fb_hz_to_ps (sm501pixclock); -dev_dbg (fbi->dev,"%s: pixclock(ps) = %u, pixclock(Hz) = %lu, " -"sm501pixclock = %lu, error = %ld%%\n" , - __func__, var->pixclock, pixclock, sm501pixclock, - ((pixclock - sm501pixclock)*100 )/pixclock); +dev_dbg (fbi->dev, +"%s: pixclock(ps) = %u, pixclock(Hz) = %lu, sm501pixclock = %lu, error = %ld%%\n" , + __func__, var->pixclock, pixclock, sm501pixclock, + ((pixclock - sm501pixclock) *100 ) / pixclock);return 0 ; }
@@ -1789,16 +1789,16 @@ static int sm501fb_init_fb(struct fb_info *fb, enum sm501_controller head,switch (ret) {case 1 : -dev_info (info->dev,"using mode specified in " -"@mode\n" ); +dev_info (info->dev, +"using mode specified in @mode\n" );break ;case 2 : -dev_info (info->dev,"using mode specified in " -"@mode with ignored refresh rate\n" ); +dev_info (info->dev, +"using mode specified in @mode with ignored refresh rate\n" );break ;case 3 : -dev_info (info->dev,"using mode default " -"mode\n" ); +dev_info (info->dev, +"using mode default mode\n" );break ;case 4 :dev_info (info->dev,"using mode from list\n" );
Signature · 1 line
2.15.0
PATCH 4/4 video: sm501fb: Adjust 15 checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 26 Nov 2017 10:56:46 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written !…
Thus fix the affected source code places.
--- drivers/video/fbdev/sm501fb.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
drivers/video/fbdev/sm501fb.c +14 -17
@@ -1484,7 +1484,7 @@ static int sm501_init_cursor(struct fb_info *fbi, unsigned int reg_base)struct sm501fb_info *info;int ret; -if (fbi =NULL ) +if (!fbi)return 0 ; par = fbi->par;
@@ -1532,7 +1532,7 @@ static int sm501fb_start(struct sm501fb_info *info,/* allocate, reserve and remap resources for display * controller registers */ res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (res =NULL ) { +if (!res) {dev_err (dev,"no resource definition for registers\n" ); ret = -ENOENT ; goto err_release;
@@ -1541,15 +1541,14 @@ static int sm501fb_start(struct sm501fb_info *info, info->regs_res =request_mem_region (res->start,resource_size (res), pdev->name); - -if (info->regs_res =NULL ) { +if (!info->regs_res) {dev_err (dev,"cannot claim registers\n" ); ret = -ENXIO ; goto err_release; } info->regs =ioremap (res->start,resource_size (res)); -if (info->regs =NULL ) { +if (!info->regs) {dev_err (dev,"cannot remap registers\n" ); ret = -ENXIO ; goto err_regs_res;
@@ -1558,7 +1557,7 @@ static int sm501fb_start(struct sm501fb_info *info,/* allocate, reserve and remap resources for 2d * controller registers */ res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); -if (res =NULL ) { +if (!res) {dev_err (dev,"no resource definition for 2d registers\n" ); ret = -ENOENT ; goto err_regs_map;
@@ -1567,15 +1566,14 @@ static int sm501fb_start(struct sm501fb_info *info, info->regs2d_res =request_mem_region (res->start,resource_size (res), pdev->name); - -if (info->regs2d_res =NULL ) { +if (!info->regs2d_res) {dev_err (dev,"cannot claim registers\n" ); ret = -ENXIO ; goto err_regs_map; } info->regs2d =ioremap (res->start,resource_size (res)); -if (info->regs2d =NULL ) { +if (!info->regs2d) {dev_err (dev,"cannot remap registers\n" ); ret = -ENXIO ; goto err_regs2d_res;
@@ -1583,7 +1581,7 @@ static int sm501fb_start(struct sm501fb_info *info,/* allocate, reserve resources for framebuffer */ res =platform_get_resource (pdev,IORESOURCE_MEM ,2 ); -if (res =NULL ) { +if (!res) {dev_err (dev,"no memory resource defined\n" ); ret = -ENXIO ; goto err_regs2d_map;
@@ -1592,14 +1590,14 @@ static int sm501fb_start(struct sm501fb_info *info, info->fbmem_res =request_mem_region (res->start,resource_size (res), pdev->name); -if (info->fbmem_res =NULL ) { +if (!info->fbmem_res) {dev_err (dev,"cannot claim framebuffer\n" ); ret = -ENXIO ; goto err_regs2d_map; } info->fbmem =ioremap (res->start,resource_size (res)); -if (info->fbmem =NULL ) { +if (!info->fbmem) {dev_err (dev,"cannot remap framebuffer\n" ); ret = -ENXIO ; goto err_mem_res;
@@ -1862,13 +1860,13 @@ static int sm501fb_probe_one(struct sm501fb_info *info, pd = (head =HEAD_CRT ) ? info->pdata->fb_crt : info->pdata->fb_pnl;/* Do not initialise if we've not been given any platform data */ -if (pd =NULL ) { +if (!pd) {dev_info (info->dev,"no data for fb %s (disabled)\n" , name);return 0 ; } fbi =framebuffer_alloc (sizeof (struct sm501fb_par ), info->dev); -if (fbi =NULL ) { +if (!fbi) {dev_err (info->dev,"cannot allocate %s framebuffer\n" , name);return -ENOMEM ; }
@@ -1944,7 +1942,7 @@ static int sm501fb_probe(struct platform_device *pdev) info->pdata = pd->fb; } -if (info->pdata =NULL ) { +if (!info->pdata) {int found =0 ;#if defined(CONFIG_OF )struct device_node *np = pdev->dev.parent->of_node;
@@ -1987,8 +1985,7 @@ static int sm501fb_probe(struct platform_device *pdev) goto err_probed_crt; } -if (info->fb[HEAD_PANEL ] =NULL && - info->fb[HEAD_CRT ] =NULL ) { +if (!info->fb[HEAD_PANEL ] && !info->fb[HEAD_CRT ]) {dev_err (dev,"no framebuffers found\n" ); ret = -ENODEV ; goto err_alloc;
Signature · 1 line
2.15.0
Re: [PATCH 2/4] video: sm501fb: Improve a size determination in sm501fb_probe()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 26 Nov 2017 10:22:37 +0100Replace 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.
Signed-off-by Markus Elfring <[email protected]>
Hand applied and queued for 4.18, thanks.
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics