* [PATCH 1/4] video: sm501fb: Delete error messages for a failed memory allocation in two functions
2017-11-26 10:16 [PATCH 0/4] video: sm501fb: Adjustments for seven function implementations SF Markus Elfring
@ 2017-11-26 10:17 ` SF Markus Elfring
2017-11-26 10:18 ` [PATCH 2/4] video: sm501fb: Improve a size determination in sm501fb_probe() SF Markus Elfring
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-11-26 10:17 UTC (permalink / raw)
To: linux-fbdev, dri-devel, Alexey Khoroshilov,
Bartlomiej Zolnierkiewicz, Bhumika Goyal, Colin Ian King,
Gustavo A. R. Silva, Sudip Mukherjee
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/video/fbdev/sm501fb.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/video/fbdev/sm501fb.c b/drivers/video/fbdev/sm501fb.c
index 6f0a19501c6a..e8301c4e7d44 100644
--- a/drivers/video/fbdev/sm501fb.c
+++ b/drivers/video/fbdev/sm501fb.c
@@ -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);
--
2.15.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] video: sm501fb: Improve a size determination in sm501fb_probe()
2017-11-26 10:16 [PATCH 0/4] video: sm501fb: Adjustments for seven function implementations SF Markus Elfring
2017-11-26 10:17 ` [PATCH 1/4] video: sm501fb: Delete error messages for a failed memory allocation in two functions SF Markus Elfring
@ 2017-11-26 10:18 ` SF Markus Elfring
2018-04-26 10:15 ` Bartlomiej Zolnierkiewicz
2017-11-26 10:19 ` [PATCH 3/4] video: sm501fb: Combine substrings for four messages SF Markus Elfring
2017-11-26 10:22 ` [PATCH 4/4] video: sm501fb: Adjust 15 checks for null pointers SF Markus Elfring
3 siblings, 1 reply; 6+ messages in thread
From: SF Markus Elfring @ 2017-11-26 10:18 UTC (permalink / raw)
To: linux-fbdev, dri-devel, Alexey Khoroshilov,
Bartlomiej Zolnierkiewicz, Bhumika Goyal, Colin Ian King,
Gustavo A. R. Silva, Sudip Mukherjee
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/video/fbdev/sm501fb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/video/fbdev/sm501fb.c b/drivers/video/fbdev/sm501fb.c
index e8301c4e7d44..80bda5a655c0 100644
--- a/drivers/video/fbdev/sm501fb.c
+++ b/drivers/video/fbdev/sm501fb.c
@@ -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;
--
2.15.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/4] video: sm501fb: Improve a size determination in sm501fb_probe()
2017-11-26 10:18 ` [PATCH 2/4] video: sm501fb: Improve a size determination in sm501fb_probe() SF Markus Elfring
@ 2018-04-26 10:15 ` Bartlomiej Zolnierkiewicz
0 siblings, 0 replies; 6+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-04-26 10:15 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-fbdev, dri-devel, Alexey Khoroshilov, Bhumika Goyal,
Colin Ian King, Gustavo A. R. Silva, Sudip Mukherjee, LKML,
kernel-janitors
On Sunday, November 26, 2017 11:18:26 AM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Hand applied and queued for 4.18, thanks.
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] video: sm501fb: Combine substrings for four messages
2017-11-26 10:16 [PATCH 0/4] video: sm501fb: Adjustments for seven function implementations SF Markus Elfring
2017-11-26 10:17 ` [PATCH 1/4] video: sm501fb: Delete error messages for a failed memory allocation in two functions SF Markus Elfring
2017-11-26 10:18 ` [PATCH 2/4] video: sm501fb: Improve a size determination in sm501fb_probe() SF Markus Elfring
@ 2017-11-26 10:19 ` SF Markus Elfring
2017-11-26 10:22 ` [PATCH 4/4] video: sm501fb: Adjust 15 checks for null pointers SF Markus Elfring
3 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-11-26 10:19 UTC (permalink / raw)
To: linux-fbdev, dri-devel, Alexey Khoroshilov,
Bartlomiej Zolnierkiewicz, Bhumika Goyal, Colin Ian King,
Gustavo A. R. Silva, Sudip Mukherjee
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/video/fbdev/sm501fb.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/video/fbdev/sm501fb.c b/drivers/video/fbdev/sm501fb.c
index 80bda5a655c0..f38e3773ccc0 100644
--- a/drivers/video/fbdev/sm501fb.c
+++ b/drivers/video/fbdev/sm501fb.c
@@ -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");
--
2.15.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] video: sm501fb: Adjust 15 checks for null pointers
2017-11-26 10:16 [PATCH 0/4] video: sm501fb: Adjustments for seven function implementations SF Markus Elfring
` (2 preceding siblings ...)
2017-11-26 10:19 ` [PATCH 3/4] video: sm501fb: Combine substrings for four messages SF Markus Elfring
@ 2017-11-26 10:22 ` SF Markus Elfring
3 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-11-26 10:22 UTC (permalink / raw)
To: linux-fbdev, dri-devel, Alexey Khoroshilov,
Bartlomiej Zolnierkiewicz, Bhumika Goyal, Colin Ian King,
Gustavo A. R. Silva, Sudip Mukherjee
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/video/fbdev/sm501fb.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/drivers/video/fbdev/sm501fb.c b/drivers/video/fbdev/sm501fb.c
index f38e3773ccc0..313acc83bb71 100644
--- a/drivers/video/fbdev/sm501fb.c
+++ b/drivers/video/fbdev/sm501fb.c
@@ -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;
--
2.15.0
^ permalink raw reply related [flat|nested] 6+ messages in thread