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

ASoC: cs42l51: Improve error handling in cs42l51_remove()

When disabling a regulator fails while the device goes away, there is
little we can do and the machine is probably in enough trouble that any
action we'd want to take fails anyhow.

The return value used to be passed on in cs42l51_i2c_remove() (i.e. the
i2c device remove callback). But the i2c core ignores the error code
(apart from emitting a generic warning) and removes the device anyhow.

So return 0 unconditionally in cs42l51_i2c_remove(), and instead of
returning the error code to the upper layer emit a more helpful warning
message. After that nobody is interested any more in the actual error
code, so let cs42l51_remove() return void.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20220110071832.306185-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Uwe Kleine-König and committed by
Mark Brown
73d4c313 74cc53cf

+12 -5
+3 -1
sound/soc/codecs/cs42l51-i2c.c
··· 31 31 32 32 static int cs42l51_i2c_remove(struct i2c_client *i2c) 33 33 { 34 - return cs42l51_remove(&i2c->dev); 34 + cs42l51_remove(&i2c->dev); 35 + 36 + return 0; 35 37 } 36 38 37 39 static const struct dev_pm_ops cs42l51_pm_ops = {
+8 -3
sound/soc/codecs/cs42l51.c
··· 793 793 } 794 794 EXPORT_SYMBOL_GPL(cs42l51_probe); 795 795 796 - int cs42l51_remove(struct device *dev) 796 + void cs42l51_remove(struct device *dev) 797 797 { 798 798 struct cs42l51_private *cs42l51 = dev_get_drvdata(dev); 799 + int ret; 799 800 800 801 gpiod_set_value_cansleep(cs42l51->reset_gpio, 1); 801 802 802 - return regulator_bulk_disable(ARRAY_SIZE(cs42l51->supplies), 803 - cs42l51->supplies); 803 + ret = regulator_bulk_disable(ARRAY_SIZE(cs42l51->supplies), 804 + cs42l51->supplies); 805 + if (ret) 806 + dev_warn(dev, "Failed to disable all regulators (%pe)\n", 807 + ERR_PTR(ret)); 808 + 804 809 } 805 810 EXPORT_SYMBOL_GPL(cs42l51_remove); 806 811
+1 -1
sound/soc/codecs/cs42l51.h
··· 13 13 14 14 extern const struct regmap_config cs42l51_regmap; 15 15 int cs42l51_probe(struct device *dev, struct regmap *regmap); 16 - int cs42l51_remove(struct device *dev); 16 + void cs42l51_remove(struct device *dev); 17 17 int __maybe_unused cs42l51_suspend(struct device *dev); 18 18 int __maybe_unused cs42l51_resume(struct device *dev); 19 19 extern const struct of_device_id cs42l51_of_match[];