pinctrl: eswin: Fix regulator error check and Kconfig dependency
authorYulin Lu <luyulin@eswincomputing.com>
Wed, 3 Sep 2025 09:19:15 +0000 (17:19 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 8 Sep 2025 12:23:51 +0000 (14:23 +0200)
commita6a2f50ab1721343ee2d5d2be888709aa886e3aa
tree816946b5a2eda0470665d5619e2a3ec620470fc8
parent657cbf9b24ba9bd35acd86160f115bfd93038229
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>
drivers/pinctrl/Kconfig
drivers/pinctrl/pinctrl-eic7700.c