2018-01-24 16:34:59

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/3] Input-apbps2: Adjustments for two function implementations

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jan 2018 17:30:12 +0100

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Delete an error message for a failed memory allocation
Improve a size determination
Fix typos in a comment

drivers/input/serio/apbps2.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

--
2.16.1



2018-01-24 16:37:13

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/3] Input: apbps2: Delete an error message for a failed memory allocation in apbps2_of_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jan 2018 16:43: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 <[email protected]>
---
drivers/input/serio/apbps2.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/serio/apbps2.c b/drivers/input/serio/apbps2.c
index 45d4e08ca4f8..9b75c4e1bc13 100644
--- a/drivers/input/serio/apbps2.c
+++ b/drivers/input/serio/apbps2.c
@@ -140,10 +140,8 @@ static int apbps2_of_probe(struct platform_device *ofdev)
struct resource *res;

priv = devm_kzalloc(&ofdev->dev, sizeof(*priv), GFP_KERNEL);
- if (!priv) {
- dev_err(&ofdev->dev, "memory allocation failed\n");
+ if (!priv)
return -ENOMEM;
- }

/* Find Device Address */
res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
--
2.16.1


2018-01-24 16:37:30

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/3] Input: apbps2: Improve a size determination in apbps2_of_probe()

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jan 2018 17:15:39 +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.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/input/serio/apbps2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/serio/apbps2.c b/drivers/input/serio/apbps2.c
index 9b75c4e1bc13..a1c64df3b6cb 100644
--- a/drivers/input/serio/apbps2.c
+++ b/drivers/input/serio/apbps2.c
@@ -170,7 +170,7 @@ static int apbps2_of_probe(struct platform_device *ofdev)
/* Set reload register to core freq in kHz/10 */
iowrite32be(freq_hz / 10000, &priv->regs->reload);

- priv->io = kzalloc(sizeof(struct serio), GFP_KERNEL);
+ priv->io = kzalloc(sizeof(*priv->io), GFP_KERNEL);
if (!priv->io)
return -ENOMEM;

--
2.16.1


2018-01-24 16:38:13

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 3/3] Input: apbps2: Fix typos in a comment

From: Markus Elfring <[email protected]>
Date: Wed, 24 Jan 2018 17:21:18 +0100

Adjust two words in this description.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/input/serio/apbps2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/serio/apbps2.c b/drivers/input/serio/apbps2.c
index a1c64df3b6cb..baa93bad993c 100644
--- a/drivers/input/serio/apbps2.c
+++ b/drivers/input/serio/apbps2.c
@@ -117,7 +117,7 @@ static int apbps2_open(struct serio *io)
while ((ioread32be(&priv->regs->status) & APBPS2_STATUS_DR) && --limit)
tmp = ioread32be(&priv->regs->data);

- /* Enable reciever and it's interrupt */
+ /* Enable receiver and its interrupt */
iowrite32be(APBPS2_CTRL_RE | APBPS2_CTRL_RI, &priv->regs->ctrl);

return 0;
--
2.16.1