pinctrl: tegra: Use correct offset for pin group
Subsystems (3)
PATCH 1/1 pinctrl: tegra: Use correct offset for pin group
Function tegra_pinctrl_gpio_request_enable() and tegra_pinctrl_gpio_disable_free() uses pin offset instead of group offset, causing the driver to use wrong offset to enable gpio.
Add a helper function tegra_pinctrl_get_group() to parse the pin group and determine correct offset.
--- drivers/pinctrl/tegra/pinctrl-tegra.c | 33 +++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-)
drivers/pinctrl/tegra/pinctrl-tegra.c +31 -2
@@ -275,6 +275,29 @@ static int tegra_pinctrl_set_mux(struct pinctrl_dev *pctldev,return 0 ; } +static struct tegra_pingroup *tegra_pinctrl_get_group (struct pinctrl_dev *pctldev, +unsigned int offset) +{ +struct tegra_pmx *pmx =pinctrl_dev_get_drvdata (pctldev); +struct tegra_pingroup *g; +unsigned int group, num_pins, j; +const unsigned int *pins; +int ret; + +for (group =0 ; group < pmx->soc->ngroups; ++group) { + ret =tegra_pinctrl_get_group_pins (pctldev, group, &pins, &num_pins); +if (ret <0 ) +continue ; +for (j =0 ; j < num_pins; j++) { +if (offset == pins[j]) +return &pmx->soc->groups[group]; + } + } + +dev_err (pctldev->dev,"Pingroup not found for pin %u\n" , offset); +return NULL ; +} +static int tegra_pinctrl_gpio_request_enable (struct pinctrl_dev *pctldev,struct pinctrl_gpio_range *range,unsigned int offset)
@@ -286,7 +309,10 @@ static int tegra_pinctrl_gpio_request_enable(struct pinctrl_dev *pctldev,if (!pmx->soc->sfsel_in_mux)return 0 ; - group = &pmx->soc->groups[offset]; + group =tegra_pinctrl_get_group (pctldev, offset); + +if (!group) +return -EINVAL ;if (group->mux_reg <0 || group->sfsel_bit <0 )return -EINVAL ;
@@ -309,7 +335,10 @@ static void tegra_pinctrl_gpio_disable_free(struct pinctrl_dev *pctldev,if (!pmx->soc->sfsel_in_mux)return ; - group = &pmx->soc->groups[offset]; + group =tegra_pinctrl_get_group (pctldev, offset); + +if (!group) +return -EINVAL ;if (group->mux_reg <0 || group->sfsel_bit <0 )return ;
Signature · 1 line
2.17.1
Quoted 10 lines · Prathamesh Shete
Function
tegra_pinctrl_gpio_request_enable()andtegra_pinctrl_gpio_disable_free()uses pin offset instead of group offset, causing the driver to use wrong offset to enable gpio.Add a helper function
tegra_pinctrl_get_group()to parse the pin group and determine correct offset.Signed-off-by Kartik K <[email protected]>Signed-off-by Prathamesh Shete <[email protected]>
Patch applied.
Yours,
Linus Walleij
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Prathamesh,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on tegra/for-next]
[also build test ERROR on v5.15-rc7 next-20211026]
[cannot apply to linusw-pinctrl/devel]
[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]
url: https://github.com/0day-ci/linux/commits/Prathamesh-Shete/pinctrl-tegra-Use-correct-offset-for-pin-group/20211025-191234 base: https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-next config: arm64-randconfig-r035-20211025 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project a461fa64bb37cffd73f683c74f6b0780379fc2ca)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/2fc9d61e0fb127a2e51e51cf0c2c6f2a9528cb37
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Prathamesh-Shete/pinctrl-tegra-Use-correct-offset-for-pin-group/20211025-191234 git checkout 2fc9d61e0fb127a2e51e51cf0c2c6f2a9528cb37
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/pinctrl/tegra/pinctrl-tegra.c:293:12: error: returning 'const struct tegra_pingroup *' from a function with result type 'struct tegra_pingroup *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
return &pmx->soc->groups[group];
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/pinctrl/tegra/pinctrl-tegra.c:282:25: warning: unused variable 'g' [-Wunused-variable]
struct tegra_pingroup *g;
^
>> drivers/pinctrl/tegra/pinctrl-tegra.c:341:3: error: void function 'tegra_pinctrl_gpio_disable_free' should not return a value [-Wreturn-type]
return -EINVAL;
^ ~~~~~~~1 warning and 2 errors generated.
vim +293 drivers/pinctrl/tegra/pinctrl-tegra.c
277
278 static struct tegra_pingroup *tegra_pinctrl_get_group(struct pinctrl_dev *pctldev,
279 unsigned int offset)
280 {
281 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
282 struct tegra_pingroup *g;
283 unsigned int group, num_pins, j;
284 const unsigned int *pins;
285 int ret;
286
287 for (group = 0; group < pmx->soc->ngroups; ++group) {
288 ret = tegra_pinctrl_get_group_pins(pctldev, group, &pins, &num_pins);
289 if (ret < 0)
290 continue;
291 for (j = 0; j < num_pins; j++) {
292 if (offset == pins[j])
> 293 return &pmx->soc->groups[group];
294 }
295 }
296
297 dev_err(pctldev->dev, "Pingroup not found for pin %u\n", offset);
298 return NULL;
299 }
300
301 static int tegra_pinctrl_gpio_request_enable(struct pinctrl_dev *pctldev,
302 struct pinctrl_gpio_range *range,
303 unsigned int offset)
304 {
305 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
306 const struct tegra_pingroup *group;
307 u32 value;
308
309 if (!pmx->soc->sfsel_in_mux)
310 return 0;
311
312 group = tegra_pinctrl_get_group(pctldev, offset);
313
314 if (!group)
315 return -EINVAL;
316
317 if (group->mux_reg < 0 || group->sfsel_bit < 0)
318 return -EINVAL;
319
320 value = pmx_readl(pmx, group->mux_bank, group->mux_reg);
321 value &= ~BIT(group->sfsel_bit);
322 pmx_writel(pmx, value, group->mux_bank, group->mux_reg);
323
324 return 0;
325 }
326
327 static void tegra_pinctrl_gpio_disable_free(struct pinctrl_dev *pctldev,
328 struct pinctrl_gpio_range *range,
329 unsigned int offset)
330 {
331 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
332 const struct tegra_pingroup *group;
333 u32 value;
334
335 if (!pmx->soc->sfsel_in_mux)
336 return;
337
338 group = tegra_pinctrl_get_group(pctldev, offset);
339
340 if (!group)
> 341 return -EINVAL; 342
343 if (group->mux_reg < 0 || group->sfsel_bit < 0)
344 return;
345
346 value = pmx_readl(pmx, group->mux_bank, group->mux_reg);
347 value |= BIT(group->sfsel_bit);
348 pmx_writel(pmx, value, group->mux_bank, group->mux_reg);
349 }
350
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Prathamesh,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on tegra/for-next]
[also build test WARNING on v5.15-rc7 next-20211026]
[cannot apply to linusw-pinctrl/devel]
[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]
url: https://github.com/0day-ci/linux/commits/Prathamesh-Shete/pinctrl-tegra-Use-correct-offset-for-pin-group/20211025-191234 base: https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-next config: arm-multi_v7_defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/2fc9d61e0fb127a2e51e51cf0c2c6f2a9528cb37
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Prathamesh-Shete/pinctrl-tegra-Use-correct-offset-for-pin-group/20211025-191234 git checkout 2fc9d61e0fb127a2e51e51cf0c2c6f2a9528cb37
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
drivers/pinctrl/tegra/pinctrl-tegra.c: In function 'tegra_pinctrl_get_group':
>> drivers/pinctrl/tegra/pinctrl-tegra.c:293:40: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
293 | return &pmx->soc->groups[group];
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/pinctrl/tegra/pinctrl-tegra.c:282:32: warning: unused variable 'g' [-Wunused-variable]
282 | struct tegra_pingroup *g;
| ^
drivers/pinctrl/tegra/pinctrl-tegra.c: In function 'tegra_pinctrl_gpio_disable_free':
drivers/pinctrl/tegra/pinctrl-tegra.c:341:24: error: 'return' with a value, in function returning void [-Werror=return-type]
341 | return -EINVAL;
| ^ drivers/pinctrl/tegra/pinctrl-tegra.c:327:13: note: declared here
327 | static void tegra_pinctrl_gpio_disable_free(struct pinctrl_dev *pctldev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/const +293 drivers/pinctrl/tegra/pinctrl-tegra.c
277
278 static struct tegra_pingroup *tegra_pinctrl_get_group(struct pinctrl_dev *pctldev,
279 unsigned int offset)
280 {
281 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
282 struct tegra_pingroup *g;
283 unsigned int group, num_pins, j;
284 const unsigned int *pins;
285 int ret;
286
287 for (group = 0; group < pmx->soc->ngroups; ++group) {
288 ret = tegra_pinctrl_get_group_pins(pctldev, group, &pins, &num_pins);
289 if (ret < 0)
290 continue;
291 for (j = 0; j < num_pins; j++) {
292 if (offset == pins[j])
> 293 return &pmx->soc->groups[group];
294 }
295 }
296
297 dev_err(pctldev->dev, "Pingroup not found for pin %u\n", offset);
298 return NULL;
299 }
300
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Prathamesh,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on tegra/for-next]
[also build test ERROR on v5.15-rc7 next-20211026]
[cannot apply to linusw-pinctrl/devel]
[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]
url: https://github.com/0day-ci/linux/commits/Prathamesh-Shete/pinctrl-tegra-Use-correct-offset-for-pin-group/20211025-191234 base: https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-next config: arm-allyesconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/2fc9d61e0fb127a2e51e51cf0c2c6f2a9528cb37
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Prathamesh-Shete/pinctrl-tegra-Use-correct-offset-for-pin-group/20211025-191234 git checkout 2fc9d61e0fb127a2e51e51cf0c2c6f2a9528cb37
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/pinctrl/tegra/pinctrl-tegra.c: In function 'tegra_pinctrl_get_group':
>> drivers/pinctrl/tegra/pinctrl-tegra.c:293:40: error: return discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
293 | return &pmx->soc->groups[group];
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/pinctrl/tegra/pinctrl-tegra.c:282:32: error: unused variable 'g' [-Werror=unused-variable]
282 | struct tegra_pingroup *g;
| ^
drivers/pinctrl/tegra/pinctrl-tegra.c: In function 'tegra_pinctrl_gpio_disable_free':
drivers/pinctrl/tegra/pinctrl-tegra.c:341:24: error: 'return' with a value, in function returning void [-Werror=return-type]
341 | return -EINVAL;
| ^ drivers/pinctrl/tegra/pinctrl-tegra.c:327:13: note: declared here
327 | static void tegra_pinctrl_gpio_disable_free(struct pinctrl_dev *pctldev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
vim +/const +293 drivers/pinctrl/tegra/pinctrl-tegra.c
277
278 static struct tegra_pingroup *tegra_pinctrl_get_group(struct pinctrl_dev *pctldev,
279 unsigned int offset)
280 {
281 struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
> 282 struct tegra_pingroup *g;
283 unsigned int group, num_pins, j;
284 const unsigned int *pins;
285 int ret;
286
287 for (group = 0; group < pmx->soc->ngroups; ++group) {
288 ret = tegra_pinctrl_get_group_pins(pctldev, group, &pins, &num_pins);
289 if (ret < 0)
290 continue;
291 for (j = 0; j < num_pins; j++) {
292 if (offset == pins[j])
> 293 return &pmx->soc->groups[group]; 294 }
295 }
296
297 dev_err(pctldev->dev, "Pingroup not found for pin %u\n", offset);
298 return NULL;
299 }
300
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org