Skip to contentSkip to conversation

Pinctrl-ADI GPIO2: Adjustments for two function implementations

PATCH In review SF Markus Elfring 2 participants 5 messages Dec 20, 2017 – Dec 21, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Pinctrl-ADI GPIO2: Adjustments for two function implementations

From: Markus Elfring <[email protected]>
Date: Wed, 20 Dec 2017 12:52:42 +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 two functions Improve a size determination in two functions

 drivers/pinctrl/pinctrl-adi2.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
Signature · 1 line
2.15.1
#1 lore raw

PATCH 1/2 pinctrl: adi2: Delete an error message for a failed memory allocation in two functions

From: Markus Elfring <[email protected]>
Date: Wed, 20 Dec 2017 12:32:10 +0100

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

---
 drivers/pinctrl/pinctrl-adi2.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/pinctrl/pinctrl-adi2.c +2 -6
index 56aa181084ac..aefaf5855089 100644
@@ -830,10 +830,8 @@ static int adi_gpio_pint_probe(struct platform_device *pdev)
 	struct gpio_pint *pint;
 
 	pint = devm_kzalloc(dev, sizeof(struct gpio_pint), GFP_KERNEL);
-	if (!pint) {
-		dev_err(dev, "Memory alloc failed\n");
+	if (!pint)
 		return -ENOMEM;
-	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	pint->base = devm_ioremap_resource(dev, res);
@@ -946,10 +944,8 @@ static int adi_gpio_probe(struct platform_device *pdev)
 		return -EINVAL;
 
 	port = devm_kzalloc(dev, sizeof(struct gpio_port), GFP_KERNEL);
-	if (!port) {
-		dev_err(dev, "Memory alloc failed\n");
+	if (!port)
 		return -ENOMEM;
-	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	port->base = devm_ioremap_resource(dev, res);
Signature · 1 line
2.15.1
#2 lore raw

Re: [PATCH 1/2] pinctrl: adi2: Delete an error message for a failed memory allocation in two functions

Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 20 Dec 2017 12:32:10 +0100

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Patch applied.

Yours,
Linus Walleij

#3 lore raw

PATCH 2/2 pinctrl: adi2: Improve a size determination in two functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 20 Dec 2017 12:38:53 +0100

Replace the specification of data structures by variable references as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

---
 drivers/pinctrl/pinctrl-adi2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/pinctrl-adi2.c +2 -3
index aefaf5855089..094a451db2a2 100644
@@ -827,9 +827,8 @@ static int adi_gpio_pint_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct resource *res;
-	struct gpio_pint *pint;
+	struct gpio_pint *pint = devm_kzalloc(dev, sizeof(*pint), GFP_KERNEL);
 
-	pint = devm_kzalloc(dev, sizeof(struct gpio_pint), GFP_KERNEL);
 	if (!pint)
 		return -ENOMEM;
 
@@ -943,7 +942,7 @@ static int adi_gpio_probe(struct platform_device *pdev)
 	if (!pdata)
 		return -EINVAL;
 
-	port = devm_kzalloc(dev, sizeof(struct gpio_port), GFP_KERNEL);
+	port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
 	if (!port)
 		return -ENOMEM;
 
Signature · 1 line
2.15.1
#4 lore raw

Re: [PATCH 2/2] pinctrl: adi2: Improve a size determination in two functions

Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 20 Dec 2017 12:38:53 +0100

Replace the specification of data structures by variable references as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

Patch applied.

Yours,
Linus Walleij