Skip to content

Commit a6a2f50

Browse files
luyunlineswincomputingLinus Walleij
authored andcommitted
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: 5b797bc ("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>
1 parent 657cbf9 commit a6a2f50

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/pinctrl/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ config PINCTRL_EIC7700
211211
depends on ARCH_ESWIN || COMPILE_TEST
212212
select PINMUX
213213
select GENERIC_PINCONF
214+
select REGULATOR
215+
select REGULATOR_FIXED_VOLTAGE
214216
help
215217
This driver support for the pin controller in ESWIN's EIC7700 SoC,
216218
which supports pin multiplexing, pin configuration,and rgmii voltage

drivers/pinctrl/pinctrl-eic7700.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ static int eic7700_pinctrl_probe(struct platform_device *pdev)
634634
return PTR_ERR(pc->base);
635635

636636
regulator = devm_regulator_get(dev, "vrgmii");
637-
if (IS_ERR_OR_NULL(regulator)) {
637+
if (IS_ERR(regulator)) {
638638
return dev_err_probe(dev, PTR_ERR(regulator),
639639
"failed to get vrgmii regulator\n");
640640
}

0 commit comments

Comments
 (0)