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

mfd: stmpe: Only disable the regulators if they are enabled

In stmpe_probe(), if some regulator_enable() calls fail, probing continues
and there is only a dev_warn().

So, if stmpe_probe() is called the regulator may not be enabled. It is
cleaner to test it before calling regulator_disable() in the remove
function.

Fixes: 9c9e321455fb ("mfd: stmpe: add optional regulators")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/8de3aaf297931d655b9ad6aed548f4de8b85425a.1686998575.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Christophe JAILLET and committed by
Lee Jones
104d32bd e0cbc202

+2 -2
+2 -2
drivers/mfd/stmpe.c
··· 1485 1485 1486 1486 void stmpe_remove(struct stmpe *stmpe) 1487 1487 { 1488 - if (!IS_ERR(stmpe->vio)) 1488 + if (!IS_ERR(stmpe->vio) && regulator_is_enabled(stmpe->vio)) 1489 1489 regulator_disable(stmpe->vio); 1490 - if (!IS_ERR(stmpe->vcc)) 1490 + if (!IS_ERR(stmpe->vcc) && regulator_is_enabled(stmpe->vcc)) 1491 1491 regulator_disable(stmpe->vcc); 1492 1492 1493 1493 __stmpe_disable(stmpe, STMPE_BLOCK_ADC);