2018-02-02 17:31:59

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/2] I2C-DaVinci: Adjustments for davinci_i2c_probe()

From: Markus Elfring <[email protected]>
Date: Fri, 2 Feb 2018 18:16:14 +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/i2c/busses/i2c-davinci.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

--
2.16.1



2018-02-02 17:35:18

by Grygorii Strashko

[permalink] [raw]
Subject: Re: [PATCH 0/2] I2C-DaVinci: Adjustments for davinci_i2c_probe()



On 02/02/2018 11:20 AM, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Fri, 2 Feb 2018 18:16:14 +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/i2c/busses/i2c-davinci.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>

Reviewed-by: Grygorii Strashko <[email protected]>

--
regards,
-grygorii

2018-02-02 17:35:47

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/2] i2c-davinci: Delete an error message for a failed memory allocation in davinci_i2c_probe()

From: Markus Elfring <[email protected]>
Date: Fri, 2 Feb 2018 18:00:20 +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/i2c/busses/i2c-davinci.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index cb24a3ffdfa2..71a9c29b3981 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -784,10 +784,8 @@ static int davinci_i2c_probe(struct platform_device *pdev)

dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_i2c_dev),
GFP_KERNEL);
- if (!dev) {
- dev_err(&pdev->dev, "Memory allocation failed\n");
+ if (!dev)
return -ENOMEM;
- }

init_completion(&dev->cmd_complete);
#ifdef CONFIG_CPU_FREQ
--
2.16.1


2018-02-02 17:36:32

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/2] i2c-davinci: Improve a size determination in davinci_i2c_probe()

From: Markus Elfring <[email protected]>
Date: Fri, 2 Feb 2018 18:02:49 +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/i2c/busses/i2c-davinci.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 71a9c29b3981..1702b1d1b000 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -782,8 +782,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
return irq;
}

- dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_i2c_dev),
- GFP_KERNEL);
+ dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
if (!dev)
return -ENOMEM;

--
2.16.1