ASoC: Move active copy of CODEC read and write into runtime structure
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 2 Dec 2010 16:15:29 +0000 (16:15 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 3 Dec 2010 12:18:17 +0000 (12:18 +0000)
We shouldn't be assigning to the driver structure (which really ought
to be const, further patch to follow) though there's unlikely to be any
actual problem except in the unlikely case that two devices with the
same driver but different bus types appear in the same system.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
include/sound/soc.h
sound/soc/soc-cache.c
sound/soc/soc-core.c

index 4a9195c5ef2d4a534ff050f6696a99d07cb09ac8..714a70441bf2a5230929ffe4500413c7ea5b0844 100644 (file)
@@ -476,6 +476,8 @@ struct snd_soc_codec {
        void *control_data; /* codec control (i2c/3wire) data */
        hw_write_t hw_write;
        unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int);
+       unsigned int (*read)(struct snd_soc_codec *, unsigned int);
+       int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
        void *reg_cache;
        const struct snd_soc_cache_ops *cache_ops;
        struct mutex cache_rw_mutex;
index 514398463f7d27ea08fdf367b5d98b32bef359ab..78b25e8c03f6ed20767ab08dfceac7a30bc5f8cb 100644 (file)
@@ -728,8 +728,8 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
                return -EINVAL;
        }
 
-       codec->driver->write = io_types[i].write;
-       codec->driver->read = io_types[i].read;
+       codec->write = io_types[i].write;
+       codec->read = io_types[i].read;
 
        switch (control) {
        case SND_SOC_CUSTOM:
index 20dcc978588fcc2273803255b28c859cc983b41b..5720dbcefbc465329fe6a975aa597ca153a1f9f2 100644 (file)
@@ -2077,7 +2077,7 @@ unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg)
 {
        unsigned int ret;
 
-       ret = codec->driver->read(codec, reg);
+       ret = codec->read(codec, reg);
        dev_dbg(codec->dev, "read %x => %x\n", reg, ret);
        trace_snd_soc_reg_read(codec, reg, ret);
 
@@ -2090,7 +2090,7 @@ unsigned int snd_soc_write(struct snd_soc_codec *codec,
 {
        dev_dbg(codec->dev, "write %x = %x\n", reg, val);
        trace_snd_soc_reg_write(codec, reg, val);
-       return codec->driver->write(codec, reg, val);
+       return codec->write(codec, reg, val);
 }
 EXPORT_SYMBOL_GPL(snd_soc_write);
 
@@ -3448,6 +3448,8 @@ int snd_soc_register_codec(struct device *dev,
 
        INIT_LIST_HEAD(&codec->dapm.widgets);
        INIT_LIST_HEAD(&codec->dapm.paths);
+       codec->write = codec_drv->write;
+       codec->read = codec_drv->read;
        codec->dapm.bias_level = SND_SOC_BIAS_OFF;
        codec->dapm.dev = dev;
        codec->dapm.codec = codec;