ASoC: Automatically determine control_data for soc-cache users
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 12 Aug 2010 09:59:15 +0000 (10:59 +0100)
committerLiam Girdwood <lrg@slimlogic.co.uk>
Thu, 12 Aug 2010 13:02:06 +0000 (14:02 +0100)
Since the provision of a struct device for the CODEC is now mandatory
we can use container_of() to locate the struct i2c_client and struct
spi_device for relevant devices, removing the need to manually set it
in each driver.

A further patch will automate selection of the control type based on
the bus_type of the struct device, further reducing the amount of
driver code required.

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

index 83cd8ed944bf9daf2660eac523e688b97d5d6056..b856177ea281ea8bcd1cb383c1afa83e9e643cc6 100644 (file)
@@ -584,11 +584,19 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
 #endif
                if (io_types[i].i2c_read)
                        codec->hw_read = io_types[i].i2c_read;
+
+               codec->control_data = container_of(codec->dev,
+                                                  struct i2c_client,
+                                                  dev);
                break;
 
        case SND_SOC_SPI:
                if (io_types[i].spi_write)
                        codec->hw_write = io_types[i].spi_write;
+
+               codec->control_data = container_of(codec->dev,
+                                                  struct spi_device,
+                                                  dev);
                break;
        }