* [PATCH 0/2] Input: nspire-keypad: Adjustments for nspire_keypad_probe()
From: SF Markus Elfring @ 2018-01-27 9:52 UTC (permalink / raw)
To: linux-input, Daniel Tang, Dmitry Torokhov; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 10:48:28 +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
Improve a size determination
drivers/input/keyboard/nspire-keypad.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
--
2.16.1
^ permalink raw reply
* [PATCH 1/2] Input: nspire-keypad: Delete an error message for a failed memory allocation in nspire_keypad_probe()
From: SF Markus Elfring @ 2018-01-27 9:54 UTC (permalink / raw)
To: linux-input, Daniel Tang, Dmitry Torokhov; +Cc: LKML, kernel-janitors
In-Reply-To: <bb959d5e-5600-df03-303e-1f96d2890717@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 10:33:37 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/input/keyboard/nspire-keypad.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c
index c7f26fa3034c..f13b50213f94 100644
--- a/drivers/input/keyboard/nspire-keypad.c
+++ b/drivers/input/keyboard/nspire-keypad.c
@@ -175,10 +175,8 @@ static int nspire_keypad_probe(struct platform_device *pdev)
keypad = devm_kzalloc(&pdev->dev, sizeof(struct nspire_keypad),
GFP_KERNEL);
- if (!keypad) {
- dev_err(&pdev->dev, "failed to allocate keypad memory\n");
+ if (!keypad)
return -ENOMEM;
- }
keypad->row_shift = get_count_order(KEYPAD_BITMASK_COLS);
--
2.16.1
^ permalink raw reply related
* [PATCH 2/2] Input: nspire-keypad: Improve a size determination in nspire_keypad_probe()
From: SF Markus Elfring @ 2018-01-27 9:55 UTC (permalink / raw)
To: linux-input, Daniel Tang, Dmitry Torokhov; +Cc: LKML, kernel-janitors
In-Reply-To: <bb959d5e-5600-df03-303e-1f96d2890717@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 10:36:20 +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/input/keyboard/nspire-keypad.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c
index f13b50213f94..caadc99741c0 100644
--- a/drivers/input/keyboard/nspire-keypad.c
+++ b/drivers/input/keyboard/nspire-keypad.c
@@ -173,8 +173,7 @@ static int nspire_keypad_probe(struct platform_device *pdev)
return -EINVAL;
}
- keypad = devm_kzalloc(&pdev->dev, sizeof(struct nspire_keypad),
- GFP_KERNEL);
+ keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad), GFP_KERNEL);
if (!keypad)
return -ENOMEM;
--
2.16.1
^ permalink raw reply related
* [PATCH 0/2] Input: max7359_keypad: Adjustments for max7359_probe()
From: SF Markus Elfring @ 2018-01-27 12:13 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 13:08: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
Improve a size determination
drivers/input/keyboard/max7359_keypad.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
--
2.16.1
^ permalink raw reply
* [PATCH 1/2] Input: max7359_keypad: Delete an error message for a failed memory allocation in max7359_probe()
From: SF Markus Elfring @ 2018-01-27 12:14 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov; +Cc: LKML, kernel-janitors
In-Reply-To: <95f7f53b-fa1e-8270-ae4c-5b3d721a4831@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 12:56:25 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/input/keyboard/max7359_keypad.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
index cd44d22d8770..ba6a670a769e 100644
--- a/drivers/input/keyboard/max7359_keypad.c
+++ b/drivers/input/keyboard/max7359_keypad.c
@@ -184,10 +184,8 @@ static int max7359_probe(struct i2c_client *client,
keypad = devm_kzalloc(&client->dev, sizeof(struct max7359_keypad),
GFP_KERNEL);
- if (!keypad) {
- dev_err(&client->dev, "failed to allocate memory\n");
+ if (!keypad)
return -ENOMEM;
- }
input_dev = devm_input_allocate_device(&client->dev);
if (!input_dev) {
--
2.16.1
^ permalink raw reply related
* [PATCH 2/2] Input: max7359_keypad: Improve a size determination in max7359_probe()
From: SF Markus Elfring @ 2018-01-27 12:15 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov; +Cc: LKML, kernel-janitors
In-Reply-To: <95f7f53b-fa1e-8270-ae4c-5b3d721a4831@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 13:00:10 +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/input/keyboard/max7359_keypad.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/input/keyboard/max7359_keypad.c b/drivers/input/keyboard/max7359_keypad.c
index ba6a670a769e..7791250b4667 100644
--- a/drivers/input/keyboard/max7359_keypad.c
+++ b/drivers/input/keyboard/max7359_keypad.c
@@ -181,9 +181,7 @@ static int max7359_probe(struct i2c_client *client,
}
dev_dbg(&client->dev, "keys FIFO is 0x%02x\n", ret);
-
- keypad = devm_kzalloc(&client->dev, sizeof(struct max7359_keypad),
- GFP_KERNEL);
+ keypad = devm_kzalloc(&client->dev, sizeof(*keypad), GFP_KERNEL);
if (!keypad)
return -ENOMEM;
--
2.16.1
^ permalink raw reply related
* [PATCH 0/2] Input: matrix_keypad: Adjustments for two function implementations
From: SF Markus Elfring @ 2018-01-27 12:52 UTC (permalink / raw)
To: linux-input, David Rivshin, Dmitry Torokhov, Rob Herring
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 13:48:42 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete two error messages for a failed memory allocation
in matrix_keypad_parse_dt()
Improve a size determination in matrix_keypad_probe()
drivers/input/keyboard/matrix_keypad.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
--
2.16.1
^ permalink raw reply
* [PATCH 1/2] Input: matrix_keypad: Delete two error messages for a failed memory allocation in matrix_keypad_parse_dt()
From: SF Markus Elfring @ 2018-01-27 12:53 UTC (permalink / raw)
To: linux-input, David Rivshin, Dmitry Torokhov, Rob Herring
Cc: LKML, kernel-janitors
In-Reply-To: <106bffd0-28ed-7c33-1f32-ae84b40f52c7@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 13:35:02 +0100
Omit extra messages for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/input/keyboard/matrix_keypad.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 1f316d66e6f7..90238201a9cc 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -413,10 +413,8 @@ matrix_keypad_parse_dt(struct device *dev)
}
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
- if (!pdata) {
- dev_err(dev, "could not allocate memory for platform data\n");
+ if (!pdata)
return ERR_PTR(-ENOMEM);
- }
pdata->num_row_gpios = nrow = of_gpio_named_count(np, "row-gpios");
pdata->num_col_gpios = ncol = of_gpio_named_count(np, "col-gpios");
@@ -445,10 +443,8 @@ matrix_keypad_parse_dt(struct device *dev)
sizeof(unsigned int) *
(pdata->num_row_gpios + pdata->num_col_gpios),
GFP_KERNEL);
- if (!gpios) {
- dev_err(dev, "could not allocate memory for gpios\n");
+ if (!gpios)
return ERR_PTR(-ENOMEM);
- }
for (i = 0; i < pdata->num_row_gpios; i++)
gpios[i] = of_get_named_gpio(np, "row-gpios", i);
--
2.16.1
^ permalink raw reply related
* [PATCH 2/2] Input: matrix_keypad: Improve a size determination in matrix_keypad_probe()
From: SF Markus Elfring @ 2018-01-27 12:54 UTC (permalink / raw)
To: linux-input, David Rivshin, Dmitry Torokhov, Rob Herring
Cc: LKML, kernel-janitors
In-Reply-To: <106bffd0-28ed-7c33-1f32-ae84b40f52c7@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 13:43:16 +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/input/keyboard/matrix_keypad.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 90238201a9cc..16206a8a5f07 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -487,7 +487,7 @@ static int matrix_keypad_probe(struct platform_device *pdev)
return -EINVAL;
}
- keypad = kzalloc(sizeof(struct matrix_keypad), GFP_KERNEL);
+ keypad = kzalloc(sizeof(*keypad), GFP_KERNEL);
input_dev = input_allocate_device();
if (!keypad || !input_dev) {
err = -ENOMEM;
--
2.16.1
^ permalink raw reply related
* [PATCH] Input: imx_keypad: Delete an error message for a failed memory allocation in imx_keypad_probe()
From: SF Markus Elfring @ 2018-01-27 13:23 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Kees Cook; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 14:14:04 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/input/keyboard/imx_keypad.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index 25d61d8d4fc4..859f9c9f3aae 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -447,10 +447,8 @@ static int imx_keypad_probe(struct platform_device *pdev)
}
keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad), GFP_KERNEL);
- if (!keypad) {
- dev_err(&pdev->dev, "not enough memory for driver data\n");
+ if (!keypad)
return -ENOMEM;
- }
keypad->input_dev = input_dev;
keypad->irq = irq;
--
2.16.1
^ permalink raw reply related
* [PATCH] Input: gpio_keys: Delete an error message for a failed memory allocation in two functions
From: SF Markus Elfring @ 2018-01-27 13:55 UTC (permalink / raw)
To: linux-input, Arvind Yadav, Boris Brezillon, Dmitry Torokhov,
Greg Kroah-Hartman, Günter Röck, Jacek Anaszewski,
Joseph Lo, Linus Walleij, Stephen Lu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 14:42:19 +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 <elfring@users.sourceforge.net>
---
drivers/input/keyboard/gpio_keys.c | 4 +---
drivers/input/keyboard/gpio_keys_polled.c | 4 +---
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 87e613dc33b8..d12fccf923d2 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -757,10 +757,8 @@ static int gpio_keys_probe(struct platform_device *pdev)
size = sizeof(struct gpio_keys_drvdata) +
pdata->nbuttons * sizeof(struct gpio_button_data);
ddata = devm_kzalloc(dev, size, GFP_KERNEL);
- if (!ddata) {
- dev_err(dev, "failed to allocate state\n");
+ if (!ddata)
return -ENOMEM;
- }
ddata->keymap = devm_kcalloc(dev,
pdata->nbuttons, sizeof(ddata->keymap[0]),
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
index edc7262103b9..c79b1a75d036 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -253,10 +253,8 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
size = sizeof(struct gpio_keys_polled_dev) +
pdata->nbuttons * sizeof(struct gpio_keys_button_data);
bdev = devm_kzalloc(dev, size, GFP_KERNEL);
- if (!bdev) {
- dev_err(dev, "no memory for private data\n");
+ if (!bdev)
return -ENOMEM;
- }
poll_dev = devm_input_allocate_polled_device(dev);
if (!poll_dev) {
--
2.16.1
^ permalink raw reply related
* [PATCH] Input: adp5520-keys: Delete an error message for a failed memory allocation in adp5520_keys_probe()
From: SF Markus Elfring @ 2018-01-27 14:20 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Michael Hennerich; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 15:15:52 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/input/keyboard/adp5520-keys.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/input/keyboard/adp5520-keys.c b/drivers/input/keyboard/adp5520-keys.c
index f0b9b37bde58..72e01cb77881 100644
--- a/drivers/input/keyboard/adp5520-keys.c
+++ b/drivers/input/keyboard/adp5520-keys.c
@@ -91,10 +91,8 @@ static int adp5520_keys_probe(struct platform_device *pdev)
return -EINVAL;
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
- if (!dev) {
- dev_err(&pdev->dev, "failed to alloc memory\n");
+ if (!dev)
return -ENOMEM;
- }
input = devm_input_allocate_device(&pdev->dev);
if (!input)
--
2.16.1
^ permalink raw reply related
* [PATCH 0/2] Input-TurboGraFX: Adjustments for tgfx_attach()
From: SF Markus Elfring @ 2018-01-27 14:58 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Geliang Tang, Kees Cook
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 15:55:44 +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
Improve a size determination
drivers/input/joystick/turbografx.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
--
2.16.1
^ permalink raw reply
* [PATCH 1/2] Input: turbografx: Delete an error message for a failed memory allocation in tgfx_attach()
From: SF Markus Elfring @ 2018-01-27 14:59 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Geliang Tang, Kees Cook
Cc: LKML, kernel-janitors
In-Reply-To: <dfa75f58-43e5-dc80-a606-2914b980f6e7@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 15:43:38 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/input/joystick/turbografx.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index e2685753e460..454d4c032292 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -192,10 +192,8 @@ static void tgfx_attach(struct parport *pp)
}
tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL);
- if (!tgfx) {
- printk(KERN_ERR "turbografx.c: Not enough memory\n");
+ if (!tgfx)
goto err_unreg_pardev;
- }
mutex_init(&tgfx->sem);
tgfx->pd = pd;
--
2.16.1
^ permalink raw reply related
* [PATCH 2/2] Input: turbografx: Improve a size determination in tgfx_attach()
From: SF Markus Elfring @ 2018-01-27 15:00 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Geliang Tang, Kees Cook
Cc: LKML, kernel-janitors
In-Reply-To: <dfa75f58-43e5-dc80-a606-2914b980f6e7@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 15:46:24 +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/input/joystick/turbografx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index 454d4c032292..472bc438927e 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -191,7 +191,7 @@ static void tgfx_attach(struct parport *pp)
return;
}
- tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL);
+ tgfx = kzalloc(sizeof(*tgfx), GFP_KERNEL);
if (!tgfx)
goto err_unreg_pardev;
--
2.16.1
^ permalink raw reply related
* [PATCH 0/2] input/joystick/gamecon: Adjustments for gc_attach()
From: SF Markus Elfring @ 2018-01-27 16:12 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Gustavo A. R. Silva, Joe Perches,
Kees Cook
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 17:07:27 +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
Improve a size determination
drivers/input/joystick/gamecon.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
--
2.16.1
^ permalink raw reply
* [PATCH 1/2] Input: gamecon: Delete an error message for a failed memory allocation in gc_attach()
From: SF Markus Elfring @ 2018-01-27 16:14 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Gustavo A. R. Silva, Joe Perches,
Kees Cook
Cc: LKML, kernel-janitors
In-Reply-To: <e02726e3-2ee7-e690-a8ea-90a55f8fd0c2@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 16:27:11 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/input/joystick/gamecon.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index 2ffb2e8bdc3b..f6006383d30d 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -966,10 +966,8 @@ static void gc_attach(struct parport *pp)
}
gc = kzalloc(sizeof(struct gc), GFP_KERNEL);
- if (!gc) {
- pr_err("Not enough memory\n");
+ if (!gc)
goto err_unreg_pardev;
- }
mutex_init(&gc->mutex);
gc->pd = pd;
--
2.16.1
^ permalink raw reply related
* [PATCH 2/2] Input: gamecon: Improve a size determination in gc_attach()
From: SF Markus Elfring @ 2018-01-27 16:15 UTC (permalink / raw)
To: linux-input, Dmitry Torokhov, Gustavo A. R. Silva, Joe Perches,
Kees Cook
Cc: LKML, kernel-janitors
In-Reply-To: <e02726e3-2ee7-e690-a8ea-90a55f8fd0c2@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2018 16:30:58 +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/input/joystick/gamecon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index f6006383d30d..0e3d47ab9ab9 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -965,7 +965,7 @@ static void gc_attach(struct parport *pp)
return;
}
- gc = kzalloc(sizeof(struct gc), GFP_KERNEL);
+ gc = kzalloc(sizeof(*gc), GFP_KERNEL);
if (!gc)
goto err_unreg_pardev;
--
2.16.1
^ permalink raw reply related
* [PATCH 1/8] Input: mms114 - use smbus functions whenever possible
From: Andi Shyti @ 2018-01-29 11:33 UTC (permalink / raw)
To: Dmitry Torokhov, Simon Shields
Cc: linux-input, linux-kernel, Andi Shyti, Andi Shyti
In-Reply-To: <20180129113323.18961-1-andi.shyti@samsung.com>
The exchange of data to and from the mms114 touchscreen never
exceeds 256 bytes. In the worst case it goes up to 80 bytes in
the interrupt handler while reading the events.
Thus it's not needed to make use of custom read/write functions
for accessing the i2c. Replace, whenever possible, the use of
custom functions with the more standard smbus ones.
It's not possible only in one case, in the mms114_set_active()
function where the 'cache_mode_control' variable is updated
according to the value in the register 'MMS114_MODE_CONTROL'
register.
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
drivers/input/touchscreen/mms114.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index c54f4afe1103..0b8b1f0e8ba6 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -207,14 +207,15 @@ static irqreturn_t mms114_interrupt(int irq, void *dev_id)
}
mutex_unlock(&input_dev->mutex);
- packet_size = mms114_read_reg(data, MMS114_PACKET_SIZE);
+ packet_size = i2c_smbus_read_byte_data(data->client,
+ MMS114_PACKET_SIZE);
if (packet_size <= 0)
goto out;
touch_size = packet_size / MMS114_PACKET_NUM;
- error = __mms114_read_reg(data, MMS114_INFOMATION, packet_size,
- (u8 *)touch);
+ error = i2c_smbus_read_i2c_block_data(data->client, MMS114_INFOMATION,
+ packet_size, (u8 *)touch);
if (error < 0)
goto out;
@@ -254,7 +255,8 @@ static int mms114_get_version(struct mms114_data *data)
switch (data->type) {
case TYPE_MMS152:
- error = __mms114_read_reg(data, MMS152_FW_REV, 3, buf);
+ error = i2c_smbus_read_i2c_block_data(data->client,
+ MMS152_FW_REV, 3, buf);
if (error)
return error;
@@ -268,7 +270,8 @@ static int mms114_get_version(struct mms114_data *data)
break;
case TYPE_MMS114:
- error = __mms114_read_reg(data, MMS114_TSP_REV, 6, buf);
+ error = i2c_smbus_read_i2c_block_data(data->client,
+ MMS114_TSP_REV, 6, buf);
if (error)
return error;
@@ -300,30 +303,35 @@ static int mms114_setup_regs(struct mms114_data *data)
val = (props->max_x >> 8) & 0xf;
val |= ((props->max_y >> 8) & 0xf) << 4;
- error = mms114_write_reg(data, MMS114_XY_RESOLUTION_H, val);
+ error = i2c_smbus_write_byte_data(data->client,
+ MMS114_XY_RESOLUTION_H, val);
if (error < 0)
return error;
val = props->max_x & 0xff;
- error = mms114_write_reg(data, MMS114_X_RESOLUTION, val);
+ error = i2c_smbus_write_byte_data(data->client,
+ MMS114_X_RESOLUTION, val);
if (error < 0)
return error;
val = props->max_x & 0xff;
- error = mms114_write_reg(data, MMS114_Y_RESOLUTION, val);
+ error = i2c_smbus_write_byte_data(data->client,
+ MMS114_Y_RESOLUTION, val);
if (error < 0)
return error;
if (data->contact_threshold) {
- error = mms114_write_reg(data, MMS114_CONTACT_THRESHOLD,
- data->contact_threshold);
+ error = i2c_smbus_write_byte_data(data->client,
+ MMS114_CONTACT_THRESHOLD,
+ data->contact_threshold);
if (error < 0)
return error;
}
if (data->moving_threshold) {
- error = mms114_write_reg(data, MMS114_MOVING_THRESHOLD,
- data->moving_threshold);
+ error = i2c_smbus_write_byte_data(data->client,
+ MMS114_MOVING_THRESHOLD,
+ data->moving_threshold);
if (error < 0)
return error;
}
--
2.15.1
^ permalink raw reply related
* [PATCH 2/8] Input: mms114 - get read of custm i2c read/write functions
From: Andi Shyti @ 2018-01-29 11:33 UTC (permalink / raw)
To: Dmitry Torokhov, Simon Shields
Cc: linux-input, linux-kernel, Andi Shyti, Andi Shyti
In-Reply-To: <20180129113323.18961-1-andi.shyti@samsung.com>
The 'mms114_read_reg' and 'mms114_write_reg' are used when
reading or writing to the 'MMS114_MODE_CONTROL' register for
updating the 'cache_mode_control' variable.
Update the 'cache_mode_control' variable in the calling
mms114_set_active() function and get rid of all the custom i2c
read/write functions.
With this remove also the redundant sleep of MMS114_I2C_DELAY
(50us) between i2c operations. The waiting should to be handled
by the i2c driver.
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
drivers/input/touchscreen/mms114.c | 87 +++++---------------------------------
1 file changed, 10 insertions(+), 77 deletions(-)
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index 0b8b1f0e8ba6..94a97049d711 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -37,9 +37,6 @@
#define MMS152_FW_REV 0xE1
#define MMS152_COMPAT_GROUP 0xF2
-/* Minimum delay time is 50us between stop and start signal of i2c */
-#define MMS114_I2C_DELAY 50
-
/* 200ms needs after power on */
#define MMS114_POWERON_DELAY 200
@@ -83,76 +80,6 @@ struct mms114_touch {
u8 reserved[2];
} __packed;
-static int __mms114_read_reg(struct mms114_data *data, unsigned int reg,
- unsigned int len, u8 *val)
-{
- struct i2c_client *client = data->client;
- struct i2c_msg xfer[2];
- u8 buf = reg & 0xff;
- int error;
-
- if (reg <= MMS114_MODE_CONTROL && reg + len > MMS114_MODE_CONTROL)
- BUG();
-
- /* Write register: use repeated start */
- xfer[0].addr = client->addr;
- xfer[0].flags = I2C_M_TEN | I2C_M_NOSTART;
- xfer[0].len = 1;
- xfer[0].buf = &buf;
-
- /* Read data */
- xfer[1].addr = client->addr;
- xfer[1].flags = I2C_M_RD;
- xfer[1].len = len;
- xfer[1].buf = val;
-
- error = i2c_transfer(client->adapter, xfer, 2);
- if (error != 2) {
- dev_err(&client->dev,
- "%s: i2c transfer failed (%d)\n", __func__, error);
- return error < 0 ? error : -EIO;
- }
- udelay(MMS114_I2C_DELAY);
-
- return 0;
-}
-
-static int mms114_read_reg(struct mms114_data *data, unsigned int reg)
-{
- u8 val;
- int error;
-
- if (reg == MMS114_MODE_CONTROL)
- return data->cache_mode_control;
-
- error = __mms114_read_reg(data, reg, 1, &val);
- return error < 0 ? error : val;
-}
-
-static int mms114_write_reg(struct mms114_data *data, unsigned int reg,
- unsigned int val)
-{
- struct i2c_client *client = data->client;
- u8 buf[2];
- int error;
-
- buf[0] = reg & 0xff;
- buf[1] = val & 0xff;
-
- error = i2c_master_send(client, buf, 2);
- if (error != 2) {
- dev_err(&client->dev,
- "%s: i2c send failed (%d)\n", __func__, error);
- return error < 0 ? error : -EIO;
- }
- udelay(MMS114_I2C_DELAY);
-
- if (reg == MMS114_MODE_CONTROL)
- data->cache_mode_control = val;
-
- return 0;
-}
-
static void mms114_process_mt(struct mms114_data *data, struct mms114_touch *touch)
{
struct i2c_client *client = data->client;
@@ -231,19 +158,25 @@ static irqreturn_t mms114_interrupt(int irq, void *dev_id)
static int mms114_set_active(struct mms114_data *data, bool active)
{
- int val;
+ int val, err;
- val = mms114_read_reg(data, MMS114_MODE_CONTROL);
+ val = i2c_smbus_read_byte_data(data->client, MMS114_MODE_CONTROL);
if (val < 0)
return val;
- val &= ~MMS114_OPERATION_MODE_MASK;
+ val = data->cache_mode_control &= ~MMS114_OPERATION_MODE_MASK;
/* If active is false, sleep mode */
if (active)
val |= MMS114_ACTIVE;
- return mms114_write_reg(data, MMS114_MODE_CONTROL, val);
+ err = i2c_smbus_write_byte_data(data->client, MMS114_MODE_CONTROL, val);
+ if (err < 0)
+ return err;
+
+ data->cache_mode_control = val;
+
+ return 0;
}
static int mms114_get_version(struct mms114_data *data)
--
2.15.1
^ permalink raw reply related
* [PATCH 3/8] Input: mms114 - replace mdelay with msleep
From: Andi Shyti @ 2018-01-29 11:33 UTC (permalink / raw)
To: Dmitry Torokhov, Simon Shields
Cc: linux-input, linux-kernel, Andi Shyti, Andi Shyti
In-Reply-To: <20180129113323.18961-1-andi.shyti@samsung.com>
200ms seconds is a very long time to keep the CPU busy looping.
Use msleep instead.
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
drivers/input/touchscreen/mms114.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index 94a97049d711..fb4435ae506b 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -290,7 +290,7 @@ static int mms114_start(struct mms114_data *data)
return error;
}
- mdelay(MMS114_POWERON_DELAY);
+ msleep(MMS114_POWERON_DELAY);
error = mms114_setup_regs(data);
if (error < 0) {
--
2.15.1
^ permalink raw reply related
* [PATCH 4/8] Input: mms114 - remove unused variable
From: Andi Shyti @ 2018-01-29 11:33 UTC (permalink / raw)
To: Dmitry Torokhov, Simon Shields
Cc: linux-input, linux-kernel, Andi Shyti, Andi Shyti
In-Reply-To: <20180129113323.18961-1-andi.shyti@samsung.com>
'__packed' is not used anywhere, remove it.
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
drivers/input/touchscreen/mms114.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index fb4435ae506b..11dba8bb48e3 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -78,7 +78,7 @@ struct mms114_touch {
u8 width;
u8 strength;
u8 reserved[2];
-} __packed;
+};
static void mms114_process_mt(struct mms114_data *data, struct mms114_touch *touch)
{
--
2.15.1
^ permalink raw reply related
* [PATCH 5/8] Input: mms114 - use lower case for hexadecimal values
From: Andi Shyti @ 2018-01-29 11:33 UTC (permalink / raw)
To: Dmitry Torokhov, Simon Shields
Cc: linux-input, linux-kernel, Andi Shyti, Andi Shyti
In-Reply-To: <20180129113323.18961-1-andi.shyti@samsung.com>
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
drivers/input/touchscreen/mms114.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index 11dba8bb48e3..fdf23bc416af 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -20,7 +20,7 @@
/* Write only registers */
#define MMS114_MODE_CONTROL 0x01
-#define MMS114_OPERATION_MODE_MASK 0xE
+#define MMS114_OPERATION_MODE_MASK 0xe
#define MMS114_ACTIVE (1 << 1)
#define MMS114_XY_RESOLUTION_H 0x02
@@ -30,12 +30,12 @@
#define MMS114_MOVING_THRESHOLD 0x06
/* Read only registers */
-#define MMS114_PACKET_SIZE 0x0F
+#define MMS114_PACKET_SIZE 0x0f
#define MMS114_INFOMATION 0x10
-#define MMS114_TSP_REV 0xF0
+#define MMS114_TSP_REV 0xf0
-#define MMS152_FW_REV 0xE1
-#define MMS152_COMPAT_GROUP 0xF2
+#define MMS152_FW_REV 0xe1
+#define MMS152_COMPAT_GROUP 0xf2
/* 200ms needs after power on */
#define MMS114_POWERON_DELAY 200
--
2.15.1
^ permalink raw reply related
* [PATCH 6/8] Input: mms114 - Use BIT() macro instead of explicit shifting
From: Andi Shyti @ 2018-01-29 11:33 UTC (permalink / raw)
To: Dmitry Torokhov, Simon Shields
Cc: linux-input, linux-kernel, Andi Shyti, Andi Shyti
In-Reply-To: <20180129113323.18961-1-andi.shyti@samsung.com>
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
drivers/input/touchscreen/mms114.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index fdf23bc416af..d70c03adf148 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -21,7 +21,7 @@
/* Write only registers */
#define MMS114_MODE_CONTROL 0x01
#define MMS114_OPERATION_MODE_MASK 0xe
-#define MMS114_ACTIVE (1 << 1)
+#define MMS114_ACTIVE BIT(1)
#define MMS114_XY_RESOLUTION_H 0x02
#define MMS114_X_RESOLUTION 0x03
--
2.15.1
^ permalink raw reply related
* [PATCH 8/8] Input: mms114 - fix typo in definition
From: Andi Shyti @ 2018-01-29 11:33 UTC (permalink / raw)
To: Dmitry Torokhov, Simon Shields
Cc: linux-input, linux-kernel, Andi Shyti, Andi Shyti
In-Reply-To: <20180129113323.18961-1-andi.shyti@samsung.com>
It's 'MMS114_INFORMATION', not 'MMS114_INFOMATION'
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
---
drivers/input/touchscreen/mms114.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index 3230c92de1ed..5b609531b3aa 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -28,7 +28,7 @@
/* Read only registers */
#define MMS114_PACKET_SIZE 0x0f
-#define MMS114_INFOMATION 0x10
+#define MMS114_INFORMATION 0x10
#define MMS114_TSP_REV 0xf0
#define MMS152_FW_REV 0xe1
@@ -138,7 +138,7 @@ static irqreturn_t mms114_interrupt(int irq, void *dev_id)
touch_size = packet_size / MMS114_PACKET_NUM;
- error = i2c_smbus_read_i2c_block_data(data->client, MMS114_INFOMATION,
+ error = i2c_smbus_read_i2c_block_data(data->client, MMS114_INFORMATION,
packet_size, (u8 *)touch);
if (error < 0)
goto out;
--
2.15.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox