-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ASoC: ssm2602: 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 driver to continue without problems if one of them fails. This patch splits the ssm2602 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. While we are at it also cleanup the include section of the ssm2602 driver and remove unneeded includes. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
- Loading branch information
Lars-Peter Clausen
authored and
Mark Brown
committed
Feb 18, 2014
1 parent
f75ac2d
commit c924dc6
Showing
7 changed files
with
148 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* SSM2602/SSM2603/SSM2604 I2C audio driver | ||
* | ||
* Copyright 2014 Analog Devices Inc. | ||
* | ||
* Licensed under the GPL-2. | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/i2c.h> | ||
#include <linux/regmap.h> | ||
|
||
#include <sound/soc.h> | ||
|
||
#include "ssm2602.h" | ||
|
||
/* | ||
* ssm2602 2 wire address is determined by GPIO5 | ||
* state during powerup. | ||
* low = 0x1a | ||
* high = 0x1b | ||
*/ | ||
static int ssm2602_i2c_probe(struct i2c_client *client, | ||
const struct i2c_device_id *id) | ||
{ | ||
return ssm2602_probe(&client->dev, id->driver_data, | ||
devm_regmap_init_i2c(client, &ssm2602_regmap_config)); | ||
} | ||
|
||
static int ssm2602_i2c_remove(struct i2c_client *client) | ||
{ | ||
snd_soc_unregister_codec(&client->dev); | ||
return 0; | ||
} | ||
|
||
static const struct i2c_device_id ssm2602_i2c_id[] = { | ||
{ "ssm2602", SSM2602 }, | ||
{ "ssm2603", SSM2602 }, | ||
{ "ssm2604", SSM2604 }, | ||
{ } | ||
}; | ||
MODULE_DEVICE_TABLE(i2c, ssm2602_i2c_id); | ||
|
||
static struct i2c_driver ssm2602_i2c_driver = { | ||
.driver = { | ||
.name = "ssm2602", | ||
.owner = THIS_MODULE, | ||
}, | ||
.probe = ssm2602_i2c_probe, | ||
.remove = ssm2602_i2c_remove, | ||
.id_table = ssm2602_i2c_id, | ||
}; | ||
module_i2c_driver(ssm2602_i2c_driver); | ||
|
||
MODULE_DESCRIPTION("ASoC SSM2602/SSM2603/SSM2604 I2C driver"); | ||
MODULE_AUTHOR("Cliff Cai"); | ||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* SSM2602 SPI audio driver | ||
* | ||
* Copyright 2014 Analog Devices Inc. | ||
* | ||
* Licensed under the GPL-2. | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/spi/spi.h> | ||
#include <linux/regmap.h> | ||
|
||
#include <sound/soc.h> | ||
|
||
#include "ssm2602.h" | ||
|
||
static int ssm2602_spi_probe(struct spi_device *spi) | ||
{ | ||
return ssm2602_probe(&spi->dev, SSM2602, | ||
devm_regmap_init_spi(spi, &ssm2602_regmap_config)); | ||
} | ||
|
||
static int ssm2602_spi_remove(struct spi_device *spi) | ||
{ | ||
snd_soc_unregister_codec(&spi->dev); | ||
return 0; | ||
} | ||
|
||
static struct spi_driver ssm2602_spi_driver = { | ||
.driver = { | ||
.name = "ssm2602", | ||
.owner = THIS_MODULE, | ||
}, | ||
.probe = ssm2602_spi_probe, | ||
.remove = ssm2602_spi_remove, | ||
}; | ||
module_spi_driver(ssm2602_spi_driver); | ||
|
||
MODULE_DESCRIPTION("ASoC SSM2602 SPI driver"); | ||
MODULE_AUTHOR("Cliff Cai"); | ||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.