Skip to content

Commit

Permalink
ASoC: sta32x: Move resource allocation and release to the correspondi…
Browse files Browse the repository at this point in the history
…ng callback functions

This patch includes below small fixes:

1. Move sta32x_set_bias_level() from sta32x_i2c_remove() to sta32x_remove().
2. Remove a redundant regulator_bulk_free() call in sta32x_i2c_remove(),
   as we will call regulator_bulk_free() in sta32x_remove().
3. Remove unneeded snd_soc_codec_set_drvdata(codec, NULL) in sta32x_i2c_remove.
   The i2c core will set the clientdata to NULL.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Johannes Stezenbach <js@sig21.net>
Acked-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed Aug 18, 2011
1 parent 3f61293 commit e3d73c1
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions sound/soc/codecs/sta32x.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ static int sta32x_remove(struct snd_soc_codec *codec)
{
struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);

sta32x_set_bias_level(codec, SND_SOC_BIAS_OFF);
regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);
regulator_bulk_free(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);

Expand Down Expand Up @@ -871,18 +872,8 @@ static __devinit int sta32x_i2c_probe(struct i2c_client *i2c,
static __devexit int sta32x_i2c_remove(struct i2c_client *client)
{
struct sta32x_priv *sta32x = i2c_get_clientdata(client);
struct snd_soc_codec *codec = sta32x->codec;

if (codec)
sta32x_set_bias_level(codec, SND_SOC_BIAS_OFF);

regulator_bulk_free(ARRAY_SIZE(sta32x->supplies), sta32x->supplies);

if (codec) {
snd_soc_unregister_codec(&client->dev);
snd_soc_codec_set_drvdata(codec, NULL);
}

snd_soc_unregister_codec(&client->dev);
kfree(sta32x);
return 0;
}
Expand Down

0 comments on commit e3d73c1

Please sign in to comment.