Skip to content

Commit 772d445

Browse files
diandersbroonie
authored andcommitted
ASoC: rt5682: Properly turn off regulators if wrong device ID
When I booted up on a board that had a slightly different codec stuffed on it, I got this message at bootup: rt5682 9-001a: Device with ID register 6749 is not rt5682 That's normal/expected, but what wasn't normal was the splat that I got after: WARNING: CPU: 7 PID: 176 at drivers/regulator/core.c:2151 _regulator_put+0x150/0x158 pc : _regulator_put+0x150/0x158 ... Call trace: _regulator_put+0x150/0x158 regulator_bulk_free+0x48/0x70 devm_regulator_bulk_release+0x20/0x2c release_nodes+0x1cc/0x244 devres_release_all+0x44/0x60 really_probe+0x17c/0x378 ... This is because the error paths don't turn off the regulator. Let's fix that. Fixes: 0ddce71 ("ASoC: rt5682: add rt5682 codec driver") Fixes: 87b42ab ("ASoC: rt5682: Implement remove callback") Signed-off-by: Douglas Anderson <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/20210811081751.v2.1.I4a1d9aa5d99e05aeee15c2768db600158d76cab8@changeid Signed-off-by: Mark Brown <[email protected]>
1 parent eb7ab74 commit 772d445

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sound/soc/codecs/rt5682-i2c.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ static struct snd_soc_dai_driver rt5682_dai[] = {
117117
},
118118
};
119119

120+
static void rt5682_i2c_disable_regulators(void *data)
121+
{
122+
struct rt5682_priv *rt5682 = data;
123+
124+
regulator_bulk_disable(ARRAY_SIZE(rt5682->supplies), rt5682->supplies);
125+
}
126+
120127
static int rt5682_i2c_probe(struct i2c_client *i2c,
121128
const struct i2c_device_id *id)
122129
{
@@ -157,6 +164,11 @@ static int rt5682_i2c_probe(struct i2c_client *i2c,
157164
return ret;
158165
}
159166

167+
ret = devm_add_action_or_reset(&i2c->dev, rt5682_i2c_disable_regulators,
168+
rt5682);
169+
if (ret)
170+
return ret;
171+
160172
ret = regulator_bulk_enable(ARRAY_SIZE(rt5682->supplies),
161173
rt5682->supplies);
162174
if (ret) {
@@ -285,7 +297,6 @@ static int rt5682_i2c_remove(struct i2c_client *client)
285297
struct rt5682_priv *rt5682 = i2c_get_clientdata(client);
286298

287299
rt5682_i2c_shutdown(client);
288-
regulator_bulk_disable(ARRAY_SIZE(rt5682->supplies), rt5682->supplies);
289300

290301
return 0;
291302
}

0 commit comments

Comments
 (0)