From: Markus Elfring <[email protected]>
Date: Sat, 3 Feb 2018 21:12:24 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete an error message for a failed memory allocation in three functions
Improve a size determination in picolcd_probe()
drivers/hid/hid-picolcd_core.c | 3 +--
drivers/hid/hid-picolcd_fb.c | 5 ++---
drivers/hid/hid-picolcd_leds.c | 1 -
3 files changed, 3 insertions(+), 6 deletions(-)
--
2.16.1
From: Markus Elfring <[email protected]>
Date: Sat, 3 Feb 2018 21:00:37 +0100
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <[email protected]>
---
drivers/hid/hid-picolcd_core.c | 1 -
drivers/hid/hid-picolcd_fb.c | 5 ++---
drivers/hid/hid-picolcd_leds.c | 1 -
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
index c1b29a9eb41a..5dc48ecc1b98 100644
--- a/drivers/hid/hid-picolcd_core.c
+++ b/drivers/hid/hid-picolcd_core.c
@@ -549,7 +549,6 @@ static int picolcd_probe(struct hid_device *hdev,
*/
data = kzalloc(sizeof(struct picolcd_data), GFP_KERNEL);
if (data == NULL) {
- hid_err(hdev, "can't allocate space for Minibox PicoLCD device data\n");
error = -ENOMEM;
goto err_no_cleanup;
}
diff --git a/drivers/hid/hid-picolcd_fb.c b/drivers/hid/hid-picolcd_fb.c
index 7f965e231433..5fb0b67b8d59 100644
--- a/drivers/hid/hid-picolcd_fb.c
+++ b/drivers/hid/hid-picolcd_fb.c
@@ -548,10 +548,9 @@ int picolcd_init_framebuffer(struct picolcd_data *data)
fbdata->force = 1;
fbdata->vbitmap = info->par + sizeof(struct picolcd_fb_data);
fbdata->bitmap = vmalloc(PICOLCDFB_SIZE*8);
- if (fbdata->bitmap == NULL) {
- dev_err(dev, "can't get a free page for framebuffer\n");
+ if (!fbdata->bitmap)
goto err_nomem;
- }
+
info->screen_base = (char __force __iomem *)fbdata->bitmap;
info->fix.smem_start = (unsigned long)fbdata->bitmap;
memset(fbdata->vbitmap, 0xff, PICOLCDFB_SIZE);
diff --git a/drivers/hid/hid-picolcd_leds.c b/drivers/hid/hid-picolcd_leds.c
index a802b4f49c7b..871cad90730a 100644
--- a/drivers/hid/hid-picolcd_leds.c
+++ b/drivers/hid/hid-picolcd_leds.c
@@ -122,7 +122,6 @@ int picolcd_init_leds(struct picolcd_data *data, struct hid_report *report)
for (i = 0; i < 8; i++) {
led = kzalloc(sizeof(struct led_classdev)+name_sz, GFP_KERNEL);
if (!led) {
- dev_err(dev, "can't allocate memory for LED %d\n", i);
ret = -ENOMEM;
goto err;
}
--
2.16.1
From: Markus Elfring <[email protected]>
Date: Sat, 3 Feb 2018 21:05:55 +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 <[email protected]>
---
drivers/hid/hid-picolcd_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c
index 5dc48ecc1b98..ff38016be6fb 100644
--- a/drivers/hid/hid-picolcd_core.c
+++ b/drivers/hid/hid-picolcd_core.c
@@ -547,7 +547,7 @@ static int picolcd_probe(struct hid_device *hdev,
* Let's allocate the picolcd data structure, set some reasonable
* defaults, and associate it with the device
*/
- data = kzalloc(sizeof(struct picolcd_data), GFP_KERNEL);
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
if (data == NULL) {
error = -ENOMEM;
goto err_no_cleanup;
--
2.16.1