linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Pinctrl-ADI GPIO2: Adjustments for two function implementations
@ 2017-12-20 12:00 SF Markus Elfring
  2017-12-20 12:01 ` [PATCH 1/2] pinctrl: adi2: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
  2017-12-20 12:02 ` [PATCH 2/2] pinctrl: adi2: Improve a size determination " SF Markus Elfring
  0 siblings, 2 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-12-20 12:00 UTC (permalink / raw)
  To: linux-gpio, Linus Walleij, Sonic Zhang; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.15.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] pinctrl: adi2: Delete an error message for a failed memory allocation in two functions
  2017-12-20 12:00 [PATCH 0/2] Pinctrl-ADI GPIO2: Adjustments for two function implementations SF Markus Elfring
@ 2017-12-20 12:01 ` SF Markus Elfring
  2017-12-21  9:22   ` Linus Walleij
  2017-12-20 12:02 ` [PATCH 2/2] pinctrl: adi2: Improve a size determination " SF Markus Elfring
  1 sibling, 1 reply; 5+ messages in thread
From: SF Markus Elfring @ 2017-12-20 12:01 UTC (permalink / raw)
  To: linux-gpio, Linus Walleij, Sonic Zhang; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pinctrl/pinctrl-adi2.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-adi2.c b/drivers/pinctrl/pinctrl-adi2.c
index 56aa181084ac..aefaf5855089 100644
--- a/drivers/pinctrl/pinctrl-adi2.c
+++ b/drivers/pinctrl/pinctrl-adi2.c
@@ -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);
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] pinctrl: adi2: Improve a size determination in two functions
  2017-12-20 12:00 [PATCH 0/2] Pinctrl-ADI GPIO2: Adjustments for two function implementations SF Markus Elfring
  2017-12-20 12:01 ` [PATCH 1/2] pinctrl: adi2: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
@ 2017-12-20 12:02 ` SF Markus Elfring
  2017-12-21  9:23   ` Linus Walleij
  1 sibling, 1 reply; 5+ messages in thread
From: SF Markus Elfring @ 2017-12-20 12:02 UTC (permalink / raw)
  To: linux-gpio, Linus Walleij, Sonic Zhang; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pinctrl/pinctrl-adi2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-adi2.c b/drivers/pinctrl/pinctrl-adi2.c
index aefaf5855089..094a451db2a2 100644
--- a/drivers/pinctrl/pinctrl-adi2.c
+++ b/drivers/pinctrl/pinctrl-adi2.c
@@ -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;
 
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] pinctrl: adi2: Delete an error message for a failed memory allocation in two functions
  2017-12-20 12:01 ` [PATCH 1/2] pinctrl: adi2: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
@ 2017-12-21  9:22   ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2017-12-21  9:22 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-gpio, Sonic Zhang, LKML, kernel-janitors

On Wed, Dec 20, 2017 at 1:01 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch applied.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] pinctrl: adi2: Improve a size determination in two functions
  2017-12-20 12:02 ` [PATCH 2/2] pinctrl: adi2: Improve a size determination " SF Markus Elfring
@ 2017-12-21  9:23   ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2017-12-21  9:23 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-gpio, Sonic Zhang, LKML, kernel-janitors

On Wed, Dec 20, 2017 at 1:02 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch applied.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-12-21  9:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-20 12:00 [PATCH 0/2] Pinctrl-ADI GPIO2: Adjustments for two function implementations SF Markus Elfring
2017-12-20 12:01 ` [PATCH 1/2] pinctrl: adi2: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2017-12-21  9:22   ` Linus Walleij
2017-12-20 12:02 ` [PATCH 2/2] pinctrl: adi2: Improve a size determination " SF Markus Elfring
2017-12-21  9:23   ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).