Skip to contentSkip to conversation

pinctrl: imx: do not implicitly set pin regs to -1

PATCH In review Stefan Agner 4 participants 10 messages Feb 6, 2015 – Mar 9, 2015

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

PATCH 1/1 pinctrl: imx: do not implicitly set pin regs to -1

Commit 3dac1918a491 ("pinctrl: imx: detect uninitialized pins") needs the values in struct imx_pin_reg to be -1. This has been done in a rather unorthodox way by setting the memory to 0xff using memset... Use a proper for loop to initialize the whole array with -1.

---
 drivers/pinctrl/freescale/pinctrl-imx.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx.c +6 -2
index 52f2b94..95041b6 100644
@@ -645,7 +645,7 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 {
 	struct imx_pinctrl *ipctl;
 	struct resource *res;
-	int ret;
+	int ret, i;
 
 	if (!info || !info->pins || !info->npins) {
 		dev_err(&pdev->dev, "wrong pinctrl info\n");
@@ -662,7 +662,11 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 				      info->npins, GFP_KERNEL);
 	if (!info->pin_regs)
 		return -ENOMEM;
-	memset(info->pin_regs, 0xff, sizeof(*info->pin_regs) * info->npins);
+
+	for (i = 0; i < info->npins; i++) {
+		info->pin_regs[i].mux_reg = -1;
+		info->pin_regs[i].conf_reg = -1;
+	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	ipctl->base = devm_ioremap_resource(&pdev->dev, res);
Signature · 1 line
2.2.2
Acked-by on v1 1/1
#1 lore raw

Hallo Stefan,

drivers/pinctrl/freescale/pinctrl-imx.c int imx_pinctrl_probe(struct platform_device *pdev, · line 669

Quoted 6 lines · Stefan Agner
drivers/pinctrl/freescale/pinctrl-imx.c +5 -1
-	memset(info->pin_regs, 0xff, sizeof(*info->pin_regs) * info->npins);
+
+	for (i = 0; i < info->npins; i++) {
+		info->pin_regs[i].mux_reg = -1;
+		info->pin_regs[i].conf_reg = -1;
+	}

looks definitely better. Just out of interest, did you check if it changes the generated code?

Thanks
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#2 lore raw
Quoted 11 lines · Uwe Kleine-K?nig

Hallo Stefan,

drivers/pinctrl/freescale/pinctrl-imx.c int imx_pinctrl_probe(struct platform_device *pdev, · line 669

Quoted 6 lines · Stefan Agner
drivers/pinctrl/freescale/pinctrl-imx.c +5 -1
-	memset(info->pin_regs, 0xff, sizeof(*info->pin_regs) * info->npins);
+
+	for (i = 0; i < info->npins; i++) {
+		info->pin_regs[i].mux_reg = -1;
+		info->pin_regs[i].conf_reg = -1;
+	}

looks definitely better. Just out of interest, did you check if it changes the generated code?

Just checked quickly, before it branched to memset. The object file is 24 bytes larger. I guess memset might be a bit faster due to optimized memory access. But not worth for some error handling relevant initialization code IMHO...

--
Stefan

#4 lore raw

Hello Shawn

Quoted 9 lines · Shawn Guo
Quoted 6 lines · Stefan Agner

Commit 3dac1918a491 ("pinctrl: imx: detect uninitialized pins") needs the values in struct imx_pin_reg to be -1. This has been done in a rather unorthodox way by setting the memory to 0xff using memset... Use a proper for loop to initialize the whole array with -1.

too late. This patch is part of 4.0-rc1 (4ff0f034e95d).

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#5 lore raw
Quoted 9 lines · Uwe Kleine-K?nig

Hello Shawn

Quoted 6 lines · Shawn Guo
Quoted 5 lines · Stefan Agner

Commit 3dac1918a491 ("pinctrl: imx: detect uninitialized pins") needs the values in struct imx_pin_reg to be -1. This has been done in a rather unorthodox way by setting the memory to 0xff using memset... Use a proper for loop to initialize the whole array with -1.

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

too late. This patch is part of 4.0-rc1 (4ff0f034e95d).

This is not the same patch. The patch you are mentioning is actually fixing a bug introduce in the change where we set -1 for uninitialized pins. This patch is solving the weird assignment of the initial value...

--
Stefan

#6 lore raw

Hello,

Quoted 8 lines · Stefan Agner
Quoted 7 lines · Uwe Kleine-K?nig
Quoted 6 lines · Shawn Guo
Quoted 5 lines · Stefan Agner

Commit 3dac1918a491 ("pinctrl: imx: detect uninitialized pins") needs the values in struct imx_pin_reg to be -1. This has been done in a rather unorthodox way by setting the memory to 0xff using memset... Use a proper for loop to initialize the whole array with -1.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

too late. This patch is part of 4.0-rc1 (4ff0f034e95d).

This is not the same patch. The patch you are mentioning is actually fixing a bug introduce in the change where we set -1 for uninitialized pins. This patch is solving the weird assignment of the initial value...

ah right.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#7 lore raw
Quoted 13 lines · Uwe Kleine-K?nig

Hello,

Quoted 10 lines · Stefan Agner
Quoted 9 lines · Uwe Kleine-K?nig
Quoted 8 lines · Shawn Guo
Quoted 6 lines · Stefan Agner

Commit 3dac1918a491 ("pinctrl: imx: detect uninitialized pins") needs the values in struct imx_pin_reg to be -1. This has been done in a rather unorthodox way by setting the memory to 0xff using memset... Use a proper for loop to initialize the whole array with -1.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

too late. This patch is part of 4.0-rc1 (4ff0f034e95d).

This is not the same patch. The patch you are mentioning is actually fixing a bug introduce in the change where we set -1 for uninitialized pins. This patch is solving the weird assignment of the initial value...

ah right.

Do you generally agree to that change?

@Linus Walleij, anything holding this patch back from getting merged?

--
Stefan

#8 lore raw
Quoted 3 lines · Stefan Agner

Do you generally agree to that change?

@Linus Walleij, anything holding this patch back from getting merged?

Nothing apart from me being overloaded.

Merged now, thanks.

Yours,
Linus Walleij

#9 lore raw
In reply to Stefan Agner
Quoted 6 lines · Stefan Agner

Commit 3dac1918a491 ("pinctrl: imx: detect uninitialized pins") needs the values in struct imx_pin_reg to be -1. This has been done in a rather unorthodox way by setting the memory to 0xff using memset... Use a proper for loop to initialize the whole array with -1.

Patch applied with the ACKs.

Yours,
Linus Walleij