ASoC: tlv320adcx140: Register a callback to disable the regulator_disable

The driver should register a callback that will deal with the disabling
when it fails to probe.

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Link: https://lore.kernel.org/r/20220510053031.1685337-1-zheyuma97@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Zheyu Ma 2022-05-10 13:30:31 +08:00 committed by Mark Brown
parent 5118da41c7
commit e1c9f68aa2
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 11 additions and 0 deletions

View File

@ -1083,6 +1083,13 @@ static const struct of_device_id tlv320adcx140_of_match[] = {
MODULE_DEVICE_TABLE(of, tlv320adcx140_of_match); MODULE_DEVICE_TABLE(of, tlv320adcx140_of_match);
#endif #endif
static void adcx140_disable_regulator(void *arg)
{
struct adcx140_priv *adcx140 = arg;
regulator_disable(adcx140->supply_areg);
}
static int adcx140_i2c_probe(struct i2c_client *i2c) static int adcx140_i2c_probe(struct i2c_client *i2c)
{ {
struct adcx140_priv *adcx140; struct adcx140_priv *adcx140;
@ -1112,6 +1119,10 @@ static int adcx140_i2c_probe(struct i2c_client *i2c)
dev_err(adcx140->dev, "Failed to enable areg\n"); dev_err(adcx140->dev, "Failed to enable areg\n");
return ret; return ret;
} }
ret = devm_add_action_or_reset(&i2c->dev, adcx140_disable_regulator, adcx140);
if (ret)
return ret;
} }
adcx140->regmap = devm_regmap_init_i2c(i2c, &adcx140_i2c_regmap); adcx140->regmap = devm_regmap_init_i2c(i2c, &adcx140_i2c_regmap);