pinctrl: eswin: Fix regulator error check and Kconfig dependency
Subsystems (2)
PATCH 1/1 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.
--- drivers/pinctrl/Kconfig | 2 ++ drivers/pinctrl/pinctrl-eic7700.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/Kconfig +2 -0
@@ -211,6 +211,8 @@ config PINCTRL_EIC7700 depends on ARCH_ESWIN || COMPILE_TEST select PINMUX select GENERIC_PINCONF + select REGULATOR + select REGULATOR_FIXED_VOLTAGE help This driver support for the pin controller in ESWIN's EIC7700 SoC, which supports pin multiplexing, pin configuration,and rgmii voltage
drivers/pinctrl/pinctrl-eic7700.c +1 -1
@@ -634,7 +634,7 @@ static int eic7700_pinctrl_probe(struct platform_device *pdev)return PTR_ERR (pc->base); regulator =devm_regulator_get (dev,"vrgmii" ); -if (IS_ERR_OR_NULL (regulator)) { +if (IS_ERR (regulator)) {return dev_err_probe (dev,PTR_ERR (regulator),"failed to get vrgmii regulator\n" ); }
Signature · 1 line
2.25.1
Quoted 12 lines · Yulin Lu
Smatch reported the following warning in
eic7700_pinctrl_probe():
drivers/pinctrl/pinctrl-eic7700.c:638eic7700_pinctrl_probe()
warn: passing zero to 'PTR_ERR'The root cause is that
devm_regulator_get()may return NULL whenCONFIG_REGULATORis disabled. In such case,IS_ERR_OR_NULL()triggersPTR_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:
Quoted 8 lines
- Change the check from
IS_ERR_OR_NULL()toIS_ERR()
- UpdateKconfigto explicitly select REGULATOR andREGULATOR_FIXED_VOLTAGE, ensuring that the regulator framework is always available.This resolves the Smatch warning and enforces the correct dependency.
Suggested-by Dan Carpenter <[email protected]>
Wrong tag. Didn't Dan give you proper way to attribute reported? See submitting-patches. You need Reported-by with Closes.
Best regards,
Krzysztof