All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 2098/9357] drivers/pinctrl/stm32/pinctrl-stm32.c:1530:23: warning: Local variable 'np' shadows outer variable [shadowVariable]
@ 2022-05-06  3:46 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2022-05-06  3:46 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: kbuild-all, Linux Memory Management List, Fabien Dessenne

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   632a8c88e339fe86ae6e420a24dfc641d4dd0ab5
commit: bb949ed9b16ba4575c76f7be55d4279e35ddccc1 [2098/9357] pinctrl: stm32: Switch to use for_each_gpiochip_node() helper
compiler: arm-linux-gnueabi-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout bb949ed9b16ba4575c76f7be55d4279e35ddccc1
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


cppcheck warnings: (new ones prefixed by >>)
>> drivers/pinctrl/stm32/pinctrl-stm32.c:1530:23: warning: Local variable 'np' shadows outer variable [shadowVariable]
     struct device_node *np = to_of_node(child);
                         ^
   drivers/pinctrl/stm32/pinctrl-stm32.c:1420:22: note: Shadowed declaration
    struct device_node *np = pdev->dev.of_node;
                        ^
   drivers/pinctrl/stm32/pinctrl-stm32.c:1530:23: note: Shadow variable
     struct device_node *np = to_of_node(child);
                         ^

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

   drivers/pinctrl/stm32/pinctrl-stm32.c:543:39: warning: Parameter 'reserved_maps' can be declared with const [constParameter]
     struct pinctrl_map **map, unsigned *reserved_maps,
                                         ^

vim +/np +1530 drivers/pinctrl/stm32/pinctrl-stm32.c

  1417	
  1418	int stm32_pctl_probe(struct platform_device *pdev)
  1419	{
  1420		struct device_node *np = pdev->dev.of_node;
  1421		struct fwnode_handle *child;
  1422		const struct of_device_id *match;
  1423		struct device *dev = &pdev->dev;
  1424		struct stm32_pinctrl *pctl;
  1425		struct pinctrl_pin_desc *pins;
  1426		int i, ret, hwlock_id;
  1427		unsigned int banks;
  1428	
  1429		if (!np)
  1430			return -EINVAL;
  1431	
  1432		match = of_match_device(dev->driver->of_match_table, dev);
  1433		if (!match || !match->data)
  1434			return -EINVAL;
  1435	
  1436		if (!of_find_property(np, "pins-are-numbered", NULL)) {
  1437			dev_err(dev, "only support pins-are-numbered format\n");
  1438			return -EINVAL;
  1439		}
  1440	
  1441		pctl = devm_kzalloc(dev, sizeof(*pctl), GFP_KERNEL);
  1442		if (!pctl)
  1443			return -ENOMEM;
  1444	
  1445		platform_set_drvdata(pdev, pctl);
  1446	
  1447		/* check for IRQ controller (may require deferred probe) */
  1448		pctl->domain = stm32_pctrl_get_irq_domain(np);
  1449		if (IS_ERR(pctl->domain))
  1450			return PTR_ERR(pctl->domain);
  1451	
  1452		/* hwspinlock is optional */
  1453		hwlock_id = of_hwspin_lock_get_id(pdev->dev.of_node, 0);
  1454		if (hwlock_id < 0) {
  1455			if (hwlock_id == -EPROBE_DEFER)
  1456				return hwlock_id;
  1457		} else {
  1458			pctl->hwlock = hwspin_lock_request_specific(hwlock_id);
  1459		}
  1460	
  1461		spin_lock_init(&pctl->irqmux_lock);
  1462	
  1463		pctl->dev = dev;
  1464		pctl->match_data = match->data;
  1465	
  1466		/*  get optional package information */
  1467		if (!of_property_read_u32(np, "st,package", &pctl->pkg))
  1468			dev_dbg(pctl->dev, "package detected: %x\n", pctl->pkg);
  1469	
  1470		pctl->pins = devm_kcalloc(pctl->dev, pctl->match_data->npins,
  1471					  sizeof(*pctl->pins), GFP_KERNEL);
  1472		if (!pctl->pins)
  1473			return -ENOMEM;
  1474	
  1475		ret = stm32_pctrl_create_pins_tab(pctl, pctl->pins);
  1476		if (ret)
  1477			return ret;
  1478	
  1479		ret = stm32_pctrl_build_state(pdev);
  1480		if (ret) {
  1481			dev_err(dev, "build state failed: %d\n", ret);
  1482			return -EINVAL;
  1483		}
  1484	
  1485		if (pctl->domain) {
  1486			ret = stm32_pctrl_dt_setup_irq(pdev, pctl);
  1487			if (ret)
  1488				return ret;
  1489		}
  1490	
  1491		pins = devm_kcalloc(&pdev->dev, pctl->npins, sizeof(*pins),
  1492				    GFP_KERNEL);
  1493		if (!pins)
  1494			return -ENOMEM;
  1495	
  1496		for (i = 0; i < pctl->npins; i++)
  1497			pins[i] = pctl->pins[i].pin;
  1498	
  1499		pctl->pctl_desc.name = dev_name(&pdev->dev);
  1500		pctl->pctl_desc.owner = THIS_MODULE;
  1501		pctl->pctl_desc.pins = pins;
  1502		pctl->pctl_desc.npins = pctl->npins;
  1503		pctl->pctl_desc.link_consumers = true;
  1504		pctl->pctl_desc.confops = &stm32_pconf_ops;
  1505		pctl->pctl_desc.pctlops = &stm32_pctrl_ops;
  1506		pctl->pctl_desc.pmxops = &stm32_pmx_ops;
  1507		pctl->dev = &pdev->dev;
  1508	
  1509		pctl->pctl_dev = devm_pinctrl_register(&pdev->dev, &pctl->pctl_desc,
  1510						       pctl);
  1511	
  1512		if (IS_ERR(pctl->pctl_dev)) {
  1513			dev_err(&pdev->dev, "Failed pinctrl registration\n");
  1514			return PTR_ERR(pctl->pctl_dev);
  1515		}
  1516	
  1517		banks = gpiochip_node_count(dev);
  1518		if (!banks) {
  1519			dev_err(dev, "at least one GPIO bank is required\n");
  1520			return -EINVAL;
  1521		}
  1522		pctl->banks = devm_kcalloc(dev, banks, sizeof(*pctl->banks),
  1523				GFP_KERNEL);
  1524		if (!pctl->banks)
  1525			return -ENOMEM;
  1526	
  1527		i = 0;
  1528		for_each_gpiochip_node(dev, child) {
  1529			struct stm32_gpio_bank *bank = &pctl->banks[i];
> 1530			struct device_node *np = to_of_node(child);
  1531	
  1532			bank->rstc = of_reset_control_get_exclusive(np, NULL);
  1533			if (PTR_ERR(bank->rstc) == -EPROBE_DEFER) {
  1534				fwnode_handle_put(child);
  1535				return -EPROBE_DEFER;
  1536			}
  1537	
  1538			bank->clk = of_clk_get_by_name(np, NULL);
  1539			if (IS_ERR(bank->clk)) {
  1540				if (PTR_ERR(bank->clk) != -EPROBE_DEFER)
  1541					dev_err(dev, "failed to get clk (%ld)\n", PTR_ERR(bank->clk));
  1542				fwnode_handle_put(child);
  1543				return PTR_ERR(bank->clk);
  1544			}
  1545			i++;
  1546		}
  1547	
  1548		for_each_gpiochip_node(dev, child) {
  1549			ret = stm32_gpiolib_register_bank(pctl, child);
  1550			if (ret) {
  1551				fwnode_handle_put(child);
  1552				return ret;
  1553			}
  1554	
  1555			pctl->nbanks++;
  1556		}
  1557	
  1558		dev_info(dev, "Pinctrl STM32 initialized\n");
  1559	
  1560		return 0;
  1561	}
  1562	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-06  3:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-06  3:46 [linux-next:master 2098/9357] drivers/pinctrl/stm32/pinctrl-stm32.c:1530:23: warning: Local variable 'np' shadows outer variable [shadowVariable] kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.