pinctrl: stm32: Unshadow np variable in stm32_pctl_probe()
Subsystems (4)
PATCH 1/1 pinctrl: stm32: Unshadow np variable in stm32_pctl_probe()
The np variable is used globally for stm32_pctl_probe() and in one of its code branches. cppcheck is not happy with that:
pinctrl-stm32.c:1530:23: warning: Local variable 'np' shadows outer variable [shadowVariable]
Instead of simply renaming one of the variables convert some code to use a device pointer directly.
--- drivers/pinctrl/stm32/pinctrl-stm32.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/pinctrl/stm32/pinctrl-stm32.c +9 -12
@@ -1364,8 +1364,9 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnodereturn err; } -static struct irq_domain *stm32_pctrl_get_irq_domain (struct device_node *np) +static struct irq_domain *stm32_pctrl_get_irq_domain (struct platform_device *pdev) { +struct device_node *np = pdev->dev.of_node;struct device_node *parent;struct irq_domain *domain;
@@ -1482,23 +1483,19 @@ static int stm32_pctrl_create_pins_tab(struct stm32_pinctrl *pctl,int stm32_pctl_probe (struct platform_device *pdev) { -struct device_node *np = pdev->dev.of_node; +const struct stm32_pinctrl_match_data *match_data;struct fwnode_handle *child; -const struct of_device_id *match;struct device *dev = &pdev->dev;struct stm32_pinctrl *pctl;struct pinctrl_pin_desc *pins;int i, ret, hwlock_id;unsigned int banks; -if (!np) -return -EINVAL ; - - match =of_match_device (dev->driver->of_match_table, dev); -if (!match || !match->data) + match_data =device_get_match_data (dev); +if (!match_data)return -EINVAL ; -if (!of_find_property (np,"pins-are-numbered" ,NULL )) { +if (!device_property_present (dev,"pins-are-numbered" )) {dev_err (dev,"only support pins-are-numbered format\n" );return -EINVAL ; }
@@ -1510,7 +1507,7 @@ int stm32_pctl_probe(struct platform_device *pdev)platform_set_drvdata (pdev, pctl);/* check for IRQ controller (may require deferred probe) */ - pctl->domain =stm32_pctrl_get_irq_domain (np); + pctl->domain =stm32_pctrl_get_irq_domain (pdev);if (IS_ERR (pctl->domain))return PTR_ERR (pctl->domain);
@@ -1526,10 +1523,10 @@ int stm32_pctl_probe(struct platform_device *pdev)spin_lock_init (&pctl->irqmux_lock); pctl->dev = dev; - pctl->match_data = match->data; + pctl->match_data = match_data;/* get optional package information */ -if (!of_property_read_u32 (np,"st,package" , &pctl->pkg)) +if (!device_property_read_u32 (dev,"st,package" , &pctl->pkg))dev_dbg (pctl->dev,"package detected: %x\n" , pctl->pkg); pctl->pins = devm_kcalloc(pctl->dev, pctl->match_data->npins,
Signature · 1 line
2.35.1
Hi Andy
Thank you for the patch.
Will this patch be applied in Linus pinctrl tree, or in the gpio-intel tree before being merged (linux-next) in the pinctrl tree?
BR
Fabien
Quoted 11 lines · Andy Shevchenko
The np variable is used globally for
stm32_pctl_probe()and in one of its code branches. cppcheck is not happy with that:pinctrl-stm32.c:1530:23: warning: Local variable 'np' shadows outer variable [shadowVariable]
Instead of simply renaming one of the variables convert some code to use a device pointer directly.
Fixes bb949ed9b16b ("pinctrl: stm32: Switch to use for_each_gpiochip_node() helper")Reported-by kernel test robot <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Quoted 59 lines
--- drivers/pinctrl/stm32/pinctrl-stm32.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)drivers/pinctrl/stm32/pinctrl-stm32.c +7
-10@@ -1364,8 +1364,9 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnodereturn err; } -static struct irq_domain *stm32_pctrl_get_irq_domain (struct device_node *np) +static struct irq_domain *stm32_pctrl_get_irq_domain (struct platform_device *pdev) { +struct device_node *np = pdev->dev.of_node;struct device_node *parent;struct irq_domain *domain;@@ -1482,23 +1483,19 @@ static int stm32_pctrl_create_pins_tab(struct stm32_pinctrl *pctl,int stm32_pctl_probe (struct platform_device *pdev) { -struct device_node *np = pdev->dev.of_node; +const struct stm32_pinctrl_match_data *match_data;struct fwnode_handle *child; -const struct of_device_id *match;struct device *dev = &pdev->dev;struct stm32_pinctrl *pctl;struct pinctrl_pin_desc *pins;int i, ret, hwlock_id;unsigned int banks; -if (!np) -return -EINVAL ; - - match =of_match_device (dev->driver->of_match_table, dev); -if (!match || !match->data) + match_data =device_get_match_data (dev); +if (!match_data)return -EINVAL ; -if (!of_find_property (np,"pins-are-numbered" ,NULL )) { +if (!device_property_present (dev,"pins-are-numbered" )) {dev_err (dev,"only support pins-are-numbered format\n" );return -EINVAL ; }@@ -1510,7 +1507,7 @@ int stm32_pctl_probe(struct platform_device *pdev)platform_set_drvdata (pdev, pctl);/* check for IRQ controller (may require deferred probe) */ - pctl->domain =stm32_pctrl_get_irq_domain (np); + pctl->domain =stm32_pctrl_get_irq_domain (pdev);if (IS_ERR (pctl->domain))return PTR_ERR (pctl->domain);@@ -1526,10 +1523,10 @@ int stm32_pctl_probe(struct platform_device *pdev)spin_lock_init (&pctl->irqmux_lock);
drivers/pinctrl/stm32/pinctrl-stm32.c int stm32_pctl_probe(struct platform_device *pdev) · line 1532
Quoted 10 lines
drivers/pinctrl/stm32/pinctrl-stm32.c +2
-2pctl->dev = dev; - pctl->match_data = match->data; + pctl->match_data = match_data;/* get optional package information */ -if (!of_property_read_u32 (np,"st,package" , &pctl->pkg)) +if (!device_property_read_u32 (dev,"st,package" , &pctl->pkg))dev_dbg (pctl->dev,"package detected: %x\n" , pctl->pkg); pctl->pins = devm_kcalloc(pctl->dev, pctl->match_data->npins,
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 7 lines · Fabien DESSENNE
Hi Andy
Thank you for the patch.
Will this patch be applied in Linus pinctrl tree, or in the gpio-intel tree before being merged (linux-next) in the pinctrl tree?
I believe the pin control tree is a primary here, while applying to GPIO tree won't harm. But I maintain neither of them :-)
Quoted 6 lines · Andy Shevchenko
Quoted 5 lines
The np variable is used globally for
stm32_pctl_probe()and in one of its code branches. cppcheck is not happy with that:pinctrl-stm32.c:1530:23: warning: Local variable 'np' shadows outer variable [shadowVariable]
Quoted 8 lines
Quoted 6 lines
Instead of simply renaming one of the variables convert some code to use a device pointer directly.
Fixes bb949ed9b16b ("pinctrl: stm32: Switch to use for_each_gpiochip_node() helper")Reported-by kernel test robot <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Fabien Dessenne <[email protected]>
Thanks!
Signature · 9 lines
With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 11 lines · Andy Shevchenko
The np variable is used globally for
stm32_pctl_probe()and in one of its code branches. cppcheck is not happy with that:pinctrl-stm32.c:1530:23: warning: Local variable 'np' shadows outer variable [shadowVariable]
Instead of simply renaming one of the variables convert some code to use a device pointer directly.
Fixes bb949ed9b16b ("pinctrl: stm32: Switch to use for_each_gpiochip_node() helper")Reported-by kernel test robot <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Patch applied!
Yours,
Linus Walleij