Skip to content

Commit

Permalink
ASoC: si476x: Convert SI476X codec to use regmap
Browse files Browse the repository at this point in the history
The latest radio and MFD drivers for SI476X radio chips use regmap API
to provide access to the registers and allow for caching of their
values when the actual chip is powered off. Convert the codec driver
to do the same, so it would not loose the settings when the radio
driver powers the chip down.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Andrey Smirnov authored and Mark Brown committed Mar 4, 2013
1 parent 6dbe51c commit d686500
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions sound/soc/codecs/si476x.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,23 @@ static unsigned int si476x_codec_read(struct snd_soc_codec *codec,
unsigned int reg)
{
int err;
unsigned int val;
struct si476x_core *core = codec->control_data;

si476x_core_lock(core);
err = si476x_core_cmd_get_property(core, reg);
if (!si476x_core_is_powered_up(core))
regcache_cache_only(core->regmap, true);

err = regmap_read(core->regmap, reg, &val);

if (!si476x_core_is_powered_up(core))
regcache_cache_only(core->regmap, false);
si476x_core_unlock(core);

return err;
if (err < 0)
return err;

return val;
}

static int si476x_codec_write(struct snd_soc_codec *codec,
Expand All @@ -61,7 +71,13 @@ static int si476x_codec_write(struct snd_soc_codec *codec,
struct si476x_core *core = codec->control_data;

si476x_core_lock(core);
err = si476x_core_cmd_set_property(core, reg, val);
if (!si476x_core_is_powered_up(core))
regcache_cache_only(core->regmap, true);

err = regmap_write(core->regmap, reg, val);

if (!si476x_core_is_powered_up(core))
regcache_cache_only(core->regmap, false);
si476x_core_unlock(core);

return err;
Expand Down

0 comments on commit d686500

Please sign in to comment.