Message ID | 20231123193355.3400852-7-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers | show |
Series | pinctrl: Convert struct group_desc to use struct pingroup | expand |
Hi Andy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linusw-pinctrl/devel]
[also build test WARNING on linusw-pinctrl/for-next next-20231124]
[cannot apply to geert-renesas-drivers/renesas-pinctrl pinctrl-samsung/for-next linus/master v6.7-rc2]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/pinctrl-qcom-lpass-lpi-Remove-unused-member-in-struct-lpi_pingroup/20231124-043212
base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
patch link: https://lore.kernel.org/r/20231123193355.3400852-7-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v2 06/21] pinctrl: equilibrium: Convert to use struct pingroup
config: i386-randconfig-141-20231124 (https://download.01.org/0day-ci/archive/20231124/202311241401.ZPILPdov-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20231124/202311241401.ZPILPdov-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311241401.ZPILPdov-lkp@intel.com/
smatch warnings:
drivers/pinctrl/pinctrl-equilibrium.c:719 eqbr_build_groups() warn: unsigned 'grp->npins' is never less than zero.
vim +719 drivers/pinctrl/pinctrl-equilibrium.c
702
703 static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
704 {
705 struct device *dev = drvdata->dev;
706 struct device_node *node = dev->of_node;
707 unsigned int *pins, *pinmux, pin_id, pinmux_id;
708 struct pingroup group, *grp = &group;
709 struct device_node *np;
710 struct property *prop;
711 int j, err;
712
713 for_each_child_of_node(node, np) {
714 prop = of_find_property(np, "groups", NULL);
715 if (!prop)
716 continue;
717
718 grp->npins = of_property_count_u32_elems(np, "pins");
> 719 if (grp->npins < 0) {
720 dev_err(dev, "No pins in the group: %s\n", prop->name);
721 of_node_put(np);
722 return -EINVAL;
723 }
724 grp->name = prop->value;
725 pins = devm_kcalloc(dev, grp->npins, sizeof(*pins), GFP_KERNEL);
726 if (!pins) {
727 of_node_put(np);
728 return -ENOMEM;
729 }
730 grp->pins = pins;
731
732 pinmux = devm_kcalloc(dev, grp->npins, sizeof(*pinmux), GFP_KERNEL);
733 if (!pinmux) {
734 of_node_put(np);
735 return -ENOMEM;
736 }
737
738 for (j = 0; j < grp->npins; j++) {
739 if (of_property_read_u32_index(np, "pins", j, &pin_id)) {
740 dev_err(dev, "Group %s: Read intel pins id failed\n",
741 grp->name);
742 of_node_put(np);
743 return -EINVAL;
744 }
745 if (pin_id >= drvdata->pctl_desc.npins) {
746 dev_err(dev, "Group %s: Invalid pin ID, idx: %d, pin %u\n",
747 grp->name, j, pin_id);
748 of_node_put(np);
749 return -EINVAL;
750 }
751 pins[j] = pin_id;
752 if (of_property_read_u32_index(np, "pinmux", j, &pinmux_id)) {
753 dev_err(dev, "Group %s: Read intel pinmux id failed\n",
754 grp->name);
755 of_node_put(np);
756 return -EINVAL;
757 }
758 pinmux[j] = pinmux_id;
759 }
760
761 err = pinctrl_generic_add_group(drvdata->pctl_dev,
762 grp->name, grp->pins, grp->npins,
763 pinmux);
764 if (err < 0) {
765 dev_err(dev, "Failed to register group %s\n", grp->name);
766 of_node_put(np);
767 return err;
768 }
769 memset(&group, 0, sizeof(group));
770 pinmux = NULL;
771 }
772
773 return 0;
774 }
775
On Fri, Nov 24, 2023 at 09:19:45PM +0800, kernel test robot wrote: ... > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202311241401.ZPILPdov-lkp@intel.com/ > > smatch warnings: > drivers/pinctrl/pinctrl-equilibrium.c:719 eqbr_build_groups() warn: unsigned 'grp->npins' is never less than zero. Thank you for the report! ... > 718 grp->npins = of_property_count_u32_elems(np, "pins"); > > 719 if (grp->npins < 0) { > 720 dev_err(dev, "No pins in the group: %s\n", prop->name); > 721 of_node_put(np); > 722 return -EINVAL; > 723 } Surprisingly (to me) the _count_u32_elems() can return a negative error code... Fine, I redo a bit the code by introducing a new patch that will use err instead of ->npins (which sounds better approach anyway).
diff --git a/drivers/pinctrl/pinctrl-equilibrium.c b/drivers/pinctrl/pinctrl-equilibrium.c index 91157a2b949c..2165fe6833c9 100644 --- a/drivers/pinctrl/pinctrl-equilibrium.c +++ b/drivers/pinctrl/pinctrl-equilibrium.c @@ -705,7 +705,7 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata) struct device *dev = drvdata->dev; struct device_node *node = dev->of_node; unsigned int *pins, *pinmux, pin_id, pinmux_id; - struct group_desc group; + struct pingroup group, *grp = &group; struct device_node *np; struct property *prop; int j, err; @@ -715,54 +715,54 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata) if (!prop) continue; - group.num_pins = of_property_count_u32_elems(np, "pins"); - if (group.num_pins < 0) { + grp->npins = of_property_count_u32_elems(np, "pins"); + if (grp->npins < 0) { dev_err(dev, "No pins in the group: %s\n", prop->name); of_node_put(np); return -EINVAL; } - group.name = prop->value; - pins = devm_kcalloc(dev, group.num_pins, sizeof(*pins), GFP_KERNEL); + grp->name = prop->value; + pins = devm_kcalloc(dev, grp->npins, sizeof(*pins), GFP_KERNEL); if (!pins) { of_node_put(np); return -ENOMEM; } - group.pins = pins; + grp->pins = pins; - pinmux = devm_kcalloc(dev, group.num_pins, sizeof(*pinmux), GFP_KERNEL); + pinmux = devm_kcalloc(dev, grp->npins, sizeof(*pinmux), GFP_KERNEL); if (!pinmux) { of_node_put(np); return -ENOMEM; } - for (j = 0; j < group.num_pins; j++) { + for (j = 0; j < grp->npins; j++) { if (of_property_read_u32_index(np, "pins", j, &pin_id)) { dev_err(dev, "Group %s: Read intel pins id failed\n", - group.name); + grp->name); of_node_put(np); return -EINVAL; } if (pin_id >= drvdata->pctl_desc.npins) { dev_err(dev, "Group %s: Invalid pin ID, idx: %d, pin %u\n", - group.name, j, pin_id); + grp->name, j, pin_id); of_node_put(np); return -EINVAL; } pins[j] = pin_id; if (of_property_read_u32_index(np, "pinmux", j, &pinmux_id)) { dev_err(dev, "Group %s: Read intel pinmux id failed\n", - group.name); + grp->name); of_node_put(np); return -EINVAL; } pinmux[j] = pinmux_id; } - err = pinctrl_generic_add_group(drvdata->pctl_dev, group.name, - group.pins, group.num_pins, + err = pinctrl_generic_add_group(drvdata->pctl_dev, + grp->name, grp->pins, grp->npins, pinmux); if (err < 0) { - dev_err(dev, "Failed to register group %s\n", group.name); + dev_err(dev, "Failed to register group %s\n", grp->name); of_node_put(np); return err; }
The pin control header provides struct pingroup. Utilize it instead of open coded variants in the driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/pinctrl/pinctrl-equilibrium.c | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)