Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pinctrl: eswin: Fix regulator error check and Kconfig dependency

Smatch reported the following warning in eic7700_pinctrl_probe():

drivers/pinctrl/pinctrl-eic7700.c:638 eic7700_pinctrl_probe()
warn: passing zero to 'PTR_ERR'

The root cause is that devm_regulator_get() may return NULL when
CONFIG_REGULATOR is disabled. In such case, IS_ERR_OR_NULL() triggers
PTR_ERR(NULL) which evaluates to 0, leading to passing a success code
as an error.

However, this driver cannot work without a regulator. To fix this:

- Change the check from IS_ERR_OR_NULL() to IS_ERR()
- Update Kconfig to explicitly select REGULATOR and
REGULATOR_FIXED_VOLTAGE, ensuring that the regulator framework is
always available.

This resolves the Smatch warning and enforces the correct dependency.

Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: 5b797bcc00ef ("pinctrl: eswin: Add EIC7700 pinctrl driver")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-gpio/aKRGiZ-fai0bv0tG@stanley.mountain/
Signed-off-by: Yulin Lu <luyulin@eswincomputing.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Yulin Lu and committed by
Linus Walleij
a6a2f50a 657cbf9b

+3 -1
+2
drivers/pinctrl/Kconfig
··· 211 211 depends on ARCH_ESWIN || COMPILE_TEST 212 212 select PINMUX 213 213 select GENERIC_PINCONF 214 + select REGULATOR 215 + select REGULATOR_FIXED_VOLTAGE 214 216 help 215 217 This driver support for the pin controller in ESWIN's EIC7700 SoC, 216 218 which supports pin multiplexing, pin configuration,and rgmii voltage
+1 -1
drivers/pinctrl/pinctrl-eic7700.c
··· 634 634 return PTR_ERR(pc->base); 635 635 636 636 regulator = devm_regulator_get(dev, "vrgmii"); 637 - if (IS_ERR_OR_NULL(regulator)) { 637 + if (IS_ERR(regulator)) { 638 638 return dev_err_probe(dev, PTR_ERR(regulator), 639 639 "failed to get vrgmii regulator\n"); 640 640 }