pinctrl: imx: do not implicitly set pin regs to -1
Subsystems (4)
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
@@ -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
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/ |
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
Quoted 6 lines · Stefan Agner
Commit
3dac1918a491("pinctrl: imx: detect uninitialized pins") needs the values in structimx_pin_regto be -1. This has been done in a rather unorthodox way by setting the memory to0xffusing memset... Use a proper for loop to initialize the whole array with -1.Signed-off-by Stefan Agner <[email protected]>
Hello Shawn
Quoted 9 lines · Shawn Guo
Quoted 6 lines · Stefan Agner
Commit
3dac1918a491("pinctrl: imx: detect uninitialized pins") needs the values in structimx_pin_regto be -1. This has been done in a rather unorthodox way by setting the memory to0xffusing memset... Use a proper for loop to initialize the whole array with -1.Signed-off-by Stefan Agner <[email protected]>Acked-by Shawn Guo <[email protected]>
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/ |
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 structimx_pin_regto be -1. This has been done in a rather unorthodox way by setting the memory to0xffusing memset... Use a proper for loop to initialize the whole array with -1.
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Stefan Agner <[email protected]>Acked-by Shawn Guo <[email protected]>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
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 structimx_pin_regto be -1. This has been done in a rather unorthodox way by setting the memory to0xffusing 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
Signed-off-by Stefan Agner <[email protected]>Acked-by Shawn Guo <[email protected]>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/ |
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 structimx_pin_regto be -1. This has been done in a rather unorthodox way by setting the memory to0xffusing memset... Use a proper for loop to initialize the whole array with -1.Signed-off-by Stefan Agner <[email protected]>
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Acked-by Shawn Guo <[email protected]>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
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
Quoted 6 lines · Stefan Agner
Commit
3dac1918a491("pinctrl: imx: detect uninitialized pins") needs the values in structimx_pin_regto be -1. This has been done in a rather unorthodox way by setting the memory to0xffusing memset... Use a proper for loop to initialize the whole array with -1.Signed-off-by Stefan Agner <[email protected]>
Patch applied with the ACKs.
Yours,
Linus Walleij