Skip to contentSkip to conversation

gpio-stmpe: Adjustments for two function implementations

PATCH In review SF Markus Elfring 2 participants 9 messages Jan 12, 2018 – Jan 16, 2018

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

cover gpio-stmpe: Adjustments for two function implementations

From: Markus Elfring <[email protected]>
Date: Fri, 12 Jan 2018 20:58:42 +0100

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

Markus Elfring (4):
Use seq_putc() in stmpe_dbg_show()
Improve a size determination in stmpe_gpio_probe()
Move an assignment in stmpe_gpio_probe()
Delete an unnecessary variable initialisation in stmpe_gpio_probe()

 drivers/gpio/gpio-stmpe.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
Signature · 1 line
2.15.1
#1 lore raw

PATCH 1/4 gpio-stmpe: Use seq_putc() in stmpe_dbg_show()

From: Markus Elfring <[email protected]>
Date: Fri, 12 Jan 2018 19:30:50 +0100

A single character (line break) should be put into a sequence. Thus use the corresponding function "seq_putc".

This issue was detected by using the Coccinelle software.

---
 drivers/gpio/gpio-stmpe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-stmpe.c +1 -1
index e3d048e65339..79858c6ad31a 100644
@@ -350,7 +350,7 @@ static void stmpe_dbg_show(struct seq_file *s, struct gpio_chip *gc)
 
 	for (i = 0; i < gc->ngpio; i++, gpio++) {
 		stmpe_dbg_show_one(s, gc, i, gpio);
-		seq_printf(s, "\n");
+		seq_putc(s, '\n');
 	}
 }
 
Signature · 1 line
2.15.1
#2 lore raw

Re: [PATCH 1/4] gpio-stmpe: Use seq_putc() in stmpe_dbg_show()

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 Jan 2018 19:30:50 +0100

A single character (line break) should be put into a sequence. Thus use the corresponding function "seq_putc".

This issue was detected by using the Coccinelle software.

Patch applied.

Yours,
Linus Walleij

#3 lore raw

PATCH 2/4 gpio-stmpe: Improve a size determination in stmpe_gpio_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 Jan 2018 19:36:29 +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.

---
 drivers/gpio/gpio-stmpe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-stmpe.c +1 -1
index 79858c6ad31a..2cf30dcba82a 100644
@@ -437,7 +437,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq(pdev, 0);
 
-	stmpe_gpio = kzalloc(sizeof(struct stmpe_gpio), GFP_KERNEL);
+	stmpe_gpio = kzalloc(sizeof(*stmpe_gpio), GFP_KERNEL);
 	if (!stmpe_gpio)
 		return -ENOMEM;
 
Signature · 1 line
2.15.1
#4 lore raw

Re: [PATCH 2/4] gpio-stmpe: Improve a size determination in stmpe_gpio_probe()

Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 Jan 2018 19:36:29 +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.

Patch applied.

Yours,
Linus Walleij

#5 lore raw

PATCH 3/4 gpio-stmpe: Move an assignment in stmpe_gpio_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 Jan 2018 20:44:15 +0100

Move the assignment for the local variable "irq" so that its setting will only be performed directly before it is checked by this function.

---
 drivers/gpio/gpio-stmpe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/gpio-stmpe.c +1 -2
index 2cf30dcba82a..d51e27eb1c59 100644
@@ -435,8 +435,6 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
 	int ret;
 	int irq = 0;
 
-	irq = platform_get_irq(pdev, 0);
-
 	stmpe_gpio = kzalloc(sizeof(*stmpe_gpio), GFP_KERNEL);
 	if (!stmpe_gpio)
 		return -ENOMEM;
@@ -459,6 +457,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
 	if (stmpe_gpio->norequest_mask)
 		stmpe_gpio->chip.irq.need_valid_mask = true;
 
+	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		dev_info(&pdev->dev,
 			"device configured in no-irq mode: "
Signature · 1 line
2.15.1
#6 lore raw

Re: [PATCH 3/4] gpio-stmpe: Move an assignment in stmpe_gpio_probe()

Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 Jan 2018 20:44:15 +0100

Move the assignment for the local variable "irq" so that its setting will only be performed directly before it is checked by this function.

Patch applied.

Yours,
Linus Walleij

#7 lore raw

PATCH 4/4 gpio-stmpe: Delete an unnecessary variable initialisation in stmpe_gpio_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 Jan 2018 20:48:40 +0100

The local variable "irq" will eventually be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.

---
 drivers/gpio/gpio-stmpe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/gpio-stmpe.c +1 -2
index d51e27eb1c59..d9f370bf460d 100644
@@ -432,8 +432,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev)
 	struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
 	struct device_node *np = pdev->dev.of_node;
 	struct stmpe_gpio *stmpe_gpio;
-	int ret;
-	int irq = 0;
+	int ret, irq;
 
 	stmpe_gpio = kzalloc(sizeof(*stmpe_gpio), GFP_KERNEL);
 	if (!stmpe_gpio)
Signature · 1 line
2.15.1
#8 lore raw

Re: [PATCH 4/4] gpio-stmpe: Delete an unnecessary variable initialisation in stmpe_gpio_probe()

Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 12 Jan 2018 20:48:40 +0100

The local variable "irq" will eventually be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.

Patch applied.

Yours,
Linus Walleij