aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-02-17 07:16:56 -0500
committerMark Brown <broonie@linaro.org>2014-02-17 20:30:25 -0500
commit0c2d6964562835501280409cac5d4ee28e07e8c2 (patch)
treed00f9a8e13c5211f6759ac59642f8928b5c4a67d
parentf96a5d3f1c09ce85ac1a90d733ca3585b9f2f70a (diff)
ASoC: adav80x: Split SPI and I2C code into different modules
There are a few known (minor) problems with having the support code for both I2C and SPI in the same module: * We need to be extra careful to make sure to not build the driver into the kernel if one of the subsystems is build as a module (Currently only I2C can be build as a module). * The module init path error handling is rather ugly. E.g. what should be done if either the SPI or the I2C driver fails to register. Most drivers that implement SPI and I2C in the same module currently fallback to undefined behavior in that case. Splitting the the driver into two modules, one for each bus, allows the registration of the other bus drive to continue without problems if one of them fails. This patch splits the ADAV80X driver into 3 modules. One core module that implements the device logic, but is independent of the bus method used. And one module for SPI and I2C each that registers the drivers and sets up the regmap struct for the bus. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/blackfin/Kconfig3
-rw-r--r--sound/soc/codecs/Kconfig11
-rw-r--r--sound/soc/codecs/Makefile4
-rw-r--r--sound/soc/codecs/adav801.c53
-rw-r--r--sound/soc/codecs/adav803.c50
-rw-r--r--sound/soc/codecs/adav80x.c117
-rw-r--r--sound/soc/codecs/adav80x.h7
7 files changed, 133 insertions, 112 deletions
diff --git a/sound/soc/blackfin/Kconfig b/sound/soc/blackfin/Kconfig
index 54f74f8cbb75..18abd884d84f 100644
--- a/sound/soc/blackfin/Kconfig
+++ b/sound/soc/blackfin/Kconfig
@@ -47,7 +47,8 @@ config SND_SOC_BFIN_EVAL_ADAV80X
47 tristate "Support for the EVAL-ADAV80X boards on Blackfin eval boards" 47 tristate "Support for the EVAL-ADAV80X boards on Blackfin eval boards"
48 depends on SND_BF5XX_I2S && (SPI_MASTER || I2C) 48 depends on SND_BF5XX_I2S && (SPI_MASTER || I2C)
49 select SND_BF5XX_SOC_I2S 49 select SND_BF5XX_SOC_I2S
50 select SND_SOC_ADAV80X 50 select SND_SOC_ADAV801 if SPI_MASTER
51 select SND_SOC_ADAV803 if I2C
51 help 52 help
52 Say Y if you want to add support for the Analog Devices EVAL-ADAV801 or 53 Say Y if you want to add support for the Analog Devices EVAL-ADAV801 or
53 EVAL-ADAV803 board connected to one of the Blackfin evaluation boards 54 EVAL-ADAV803 board connected to one of the Blackfin evaluation boards
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 983d087aa92a..9556321c7b8b 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -20,7 +20,8 @@ config SND_SOC_ALL_CODECS
20 select SND_SOC_AD1980 if SND_SOC_AC97_BUS 20 select SND_SOC_AD1980 if SND_SOC_AC97_BUS
21 select SND_SOC_AD73311 21 select SND_SOC_AD73311
22 select SND_SOC_ADAU1373 if I2C 22 select SND_SOC_ADAU1373 if I2C
23 select SND_SOC_ADAV80X if SND_SOC_I2C_AND_SPI 23 select SND_SOC_ADAV801 if SPI_MASTER
24 select SND_SOC_ADAV803 if I2C
24 select SND_SOC_ADAU1701 if I2C 25 select SND_SOC_ADAU1701 if I2C
25 select SND_SOC_ADS117X 26 select SND_SOC_ADS117X
26 select SND_SOC_AK4104 if SPI_MASTER 27 select SND_SOC_AK4104 if SPI_MASTER
@@ -198,6 +199,14 @@ config SND_SOC_ADAU1373
198config SND_SOC_ADAV80X 199config SND_SOC_ADAV80X
199 tristate 200 tristate
200 201
202config SND_SOC_ADAV801
203 tristate
204 select SND_SOC_ADAV80X
205
206config SND_SOC_ADAV803
207 tristate
208 select SND_SOC_ADAV80X
209
201config SND_SOC_ADS117X 210config SND_SOC_ADS117X
202 tristate 211 tristate
203 212
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index bc126764a44d..1b2c6eca863f 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -8,6 +8,8 @@ snd-soc-ad73311-objs := ad73311.o
8snd-soc-adau1701-objs := adau1701.o 8snd-soc-adau1701-objs := adau1701.o
9snd-soc-adau1373-objs := adau1373.o 9snd-soc-adau1373-objs := adau1373.o
10snd-soc-adav80x-objs := adav80x.o 10snd-soc-adav80x-objs := adav80x.o
11snd-soc-adav801-objs := adav801.o
12snd-soc-adav803-objs := adav803.o
11snd-soc-ads117x-objs := ads117x.o 13snd-soc-ads117x-objs := ads117x.o
12snd-soc-ak4104-objs := ak4104.o 14snd-soc-ak4104-objs := ak4104.o
13snd-soc-ak4535-objs := ak4535.o 15snd-soc-ak4535-objs := ak4535.o
@@ -139,6 +141,8 @@ obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o
139obj-$(CONFIG_SND_SOC_ADAU1373) += snd-soc-adau1373.o 141obj-$(CONFIG_SND_SOC_ADAU1373) += snd-soc-adau1373.o
140obj-$(CONFIG_SND_SOC_ADAU1701) += snd-soc-adau1701.o 142obj-$(CONFIG_SND_SOC_ADAU1701) += snd-soc-adau1701.o
141obj-$(CONFIG_SND_SOC_ADAV80X) += snd-soc-adav80x.o 143obj-$(CONFIG_SND_SOC_ADAV80X) += snd-soc-adav80x.o
144obj-$(CONFIG_SND_SOC_ADAV801) += snd-soc-adav801.o
145obj-$(CONFIG_SND_SOC_ADAV803) += snd-soc-adav803.o
142obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o 146obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o
143obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o 147obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o
144obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o 148obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o
diff --git a/sound/soc/codecs/adav801.c b/sound/soc/codecs/adav801.c
new file mode 100644
index 000000000000..790fce33ab10
--- /dev/null
+++ b/sound/soc/codecs/adav801.c
@@ -0,0 +1,53 @@
1/*
2 * ADAV801 audio driver
3 *
4 * Copyright 2014 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2.
7 */
8
9#include <linux/module.h>
10#include <linux/spi/spi.h>
11#include <linux/regmap.h>
12
13#include <sound/soc.h>
14
15#include "adav80x.h"
16
17static const struct spi_device_id adav80x_spi_id[] = {
18 { "adav801", 0 },
19 { }
20};
21MODULE_DEVICE_TABLE(spi, adav80x_spi_id);
22
23static int adav80x_spi_probe(struct spi_device *spi)
24{
25 struct regmap_config config;
26
27 config = adav80x_regmap_config;
28 config.read_flag_mask = 0x01;
29
30 return adav80x_bus_probe(&spi->dev, devm_regmap_init_spi(spi, &config));
31}
32
33static int adav80x_spi_remove(struct spi_device *spi)
34{
35 snd_soc_unregister_codec(&spi->dev);
36 return 0;
37}
38
39static struct spi_driver adav80x_spi_driver = {
40 .driver = {
41 .name = "adav801",
42 .owner = THIS_MODULE,
43 },
44 .probe = adav80x_spi_probe,
45 .remove = adav80x_spi_remove,
46 .id_table = adav80x_spi_id,
47};
48module_spi_driver(adav80x_spi_driver);
49
50MODULE_DESCRIPTION("ASoC ADAV801 driver");
51MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
52MODULE_AUTHOR("Yi Li <yi.li@analog.com>>");
53MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/adav803.c b/sound/soc/codecs/adav803.c
new file mode 100644
index 000000000000..66d9fce34e62
--- /dev/null
+++ b/sound/soc/codecs/adav803.c
@@ -0,0 +1,50 @@
1/*
2 * ADAV803 audio driver
3 *
4 * Copyright 2014 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2.
7 */
8
9#include <linux/module.h>
10#include <linux/i2c.h>
11#include <linux/regmap.h>
12
13#include <sound/soc.h>
14
15#include "adav80x.h"
16
17static const struct i2c_device_id adav803_id[] = {
18 { "adav803", 0 },
19 { }
20};
21MODULE_DEVICE_TABLE(i2c, adav803_id);
22
23static int adav803_probe(struct i2c_client *client,
24 const struct i2c_device_id *id)
25{
26 return adav80x_bus_probe(&client->dev,
27 devm_regmap_init_i2c(client, &adav80x_regmap_config));
28}
29
30static int adav803_remove(struct i2c_client *client)
31{
32 snd_soc_unregister_codec(&client->dev);
33 return 0;
34}
35
36static struct i2c_driver adav803_driver = {
37 .driver = {
38 .name = "adav803",
39 .owner = THIS_MODULE,
40 },
41 .probe = adav803_probe,
42 .remove = adav803_remove,
43 .id_table = adav803_id,
44};
45module_i2c_driver(adav803_driver);
46
47MODULE_DESCRIPTION("ASoC ADAV803 driver");
48MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
49MODULE_AUTHOR("Yi Li <yi.li@analog.com>>");
50MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c
index a4bd051c5430..09d560962e8d 100644
--- a/sound/soc/codecs/adav80x.c
+++ b/sound/soc/codecs/adav80x.c
@@ -8,17 +8,15 @@
8 * Licensed under the GPL-2 or later. 8 * Licensed under the GPL-2 or later.
9 */ 9 */
10 10
11#include <linux/init.h>
12#include <linux/module.h> 11#include <linux/module.h>