Skip to content

Commit

Permalink
ASoC: cx20442: fix regression by adding back .read/.write
Browse files Browse the repository at this point in the history
commit 39b5a0f ("ASoC: cx20442: don't use reg_cache")
removed .read/.write from driver, but it might breaks non-regmap
driver, because ALSA SoC framework might call it.

To fix this regression, this patch back .read/.write.
and also this patch uses cx20442 internal reg_cache
which is needed for .read/.write.

Signed-off-by: Kuninori Morimoto <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
morimoto authored and broonie committed Jan 16, 2018
1 parent 39b5a0f commit 3c89724
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions sound/soc/codecs/cx20442.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
struct cx20442_priv {
struct tty_struct *tty;
struct regulator *por;
u8 reg_cache;
};

#define CX20442_PM 0x0
Expand Down Expand Up @@ -88,6 +89,17 @@ static const struct snd_soc_dapm_route cx20442_audio_map[] = {
{"ADC", NULL, "Input Mixer"},
};

static unsigned int cx20442_read_reg_cache(struct snd_soc_codec *codec,
unsigned int reg)
{
struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec);

if (reg >= 1)
return -EINVAL;

return cx20442->reg_cache;
}

enum v253_vls {
V253_VLS_NONE = 0,
V253_VLS_T,
Expand All @@ -112,8 +124,6 @@ enum v253_vls {
V253_VLS_TEST,
};

#if 0
/* FIXME : these function will be re-used */
static int cx20442_pm_to_v253_vls(u8 value)
{
switch (value & ~(1 << CX20442_AGC)) {
Expand Down Expand Up @@ -147,20 +157,19 @@ static int cx20442_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value)
{
struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec);
u8 *reg_cache = codec->reg_cache;
int vls, vsp, old, len;
char buf[18];

if (reg >= codec->driver->reg_cache_size)
if (reg >= 1)
return -EINVAL;

/* tty and write pointers required for talking to the modem
* are expected to be set by the line discipline initialization code */
if (!cx20442->tty || !cx20442->tty->ops->write)
return -EIO;

old = reg_cache[reg];
reg_cache[reg] = value;
old = cx20442->reg_cache;
cx20442->reg_cache = value;

vls = cx20442_pm_to_v253_vls(value);
if (vls < 0)
Expand Down Expand Up @@ -190,7 +199,6 @@ static int cx20442_write(struct snd_soc_codec *codec, unsigned int reg,

return 0;
}
#endif

/*
* Line discpline related code
Expand Down Expand Up @@ -384,12 +392,12 @@ static int cx20442_codec_remove(struct snd_soc_codec *codec)
return 0;
}

static const u8 cx20442_reg;

static const struct snd_soc_codec_driver cx20442_codec_dev = {
.probe = cx20442_codec_probe,
.remove = cx20442_codec_remove,
.set_bias_level = cx20442_set_bias_level,
.read = cx20442_read_reg_cache,
.write = cx20442_write,

.component_driver = {
.dapm_widgets = cx20442_dapm_widgets,
Expand Down

0 comments on commit 3c89724

Please sign in to comment.