On 11/10/2014 10:45 PM, NeilBrown wrote:
On Mon, 10 Nov 2014 08:07:50 +0100 Lars-Peter Clausen <l...@metafoo.de> wrote:

On 11/10/2014 01:45 AM, NeilBrown wrote:
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index b6b0cb399599..613b61cee081 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -957,6 +957,16 @@ static int snd_soc_put_twl4030_opmode_enum_double(struct 
snd_kcontrol *kcontrol,
   {
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
+       struct snd_ctl_elem_value currentval;


snd_ctl_elem_value is a bit to big to be put onto the kernel stack. Just
using twl4030_read() should be fine.

That's a shame, it looked so neat....

Using twl4030_read forces i2c access and misses out on the regmap caching.

What do you think of this?

That looks good, but either snd_soc_kcontrol_component() instead of snd_kcontrol_chip() or just snd_soc_read(codec, ...


Thanks,
NeilBrown

diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index b6b0cb399599..bdb47a045aa5 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -957,6 +957,18 @@ static int snd_soc_put_twl4030_opmode_enum_double(struct 
snd_kcontrol *kcontrol,
  {
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
+       const struct soc_enum *e = &twl4030_op_modes_enum;
+       unsigned int reg_val;
+       int ret;
+
+       ret = snd_soc_component_read(snd_kcontrol_chip(kcontrol),
+                                    e->reg, &reg_val);
+       if (ret)
+               return ret;
+       if (ucontrol->value.enumerated.item[0] ==
+           ((reg_val >> e->shift_l) & e->mask))
+               /* no change requested, so do nothing */
+               return 0;

        if (twl4030->configured) {
                dev_err(codec->dev,


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to