Commit 092eba93 authored by Xiubo Li's avatar Xiubo Li Committed by Mark Brown

ASoC: io: New signature for snd_soc_codec_set_cache_io()

Now that all users have been converted to regmap and the config.reg_bits
and config.val_bits can be setted by each user through regmap core API.
So these two params are redundant here.

Since the only control type that left is SND_SOC_REGMAP, so remove it. Drop
the control params and add struct regmap *regmap to simplify the code.
Signed-off-by: default avatarXiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 5d6be5aa
...@@ -354,10 +354,6 @@ typedef int (*hw_write_t)(void *,const char* ,int); ...@@ -354,10 +354,6 @@ typedef int (*hw_write_t)(void *,const char* ,int);
extern struct snd_ac97_bus_ops *soc_ac97_ops; extern struct snd_ac97_bus_ops *soc_ac97_ops;
enum snd_soc_control_type {
SND_SOC_REGMAP,
};
enum snd_soc_pcm_subclass { enum snd_soc_pcm_subclass {
SND_SOC_PCM_CLASS_PCM = 0, SND_SOC_PCM_CLASS_PCM = 0,
SND_SOC_PCM_CLASS_BE = 1, SND_SOC_PCM_CLASS_BE = 1,
...@@ -404,8 +400,7 @@ int snd_soc_codec_readable_register(struct snd_soc_codec *codec, ...@@ -404,8 +400,7 @@ int snd_soc_codec_readable_register(struct snd_soc_codec *codec,
int snd_soc_codec_writable_register(struct snd_soc_codec *codec, int snd_soc_codec_writable_register(struct snd_soc_codec *codec,
unsigned int reg); unsigned int reg);
int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
int addr_bits, int data_bits, struct regmap *regmap);
enum snd_soc_control_type control);
int snd_soc_cache_sync(struct snd_soc_codec *codec); int snd_soc_cache_sync(struct snd_soc_codec *codec);
int snd_soc_cache_init(struct snd_soc_codec *codec); int snd_soc_cache_init(struct snd_soc_codec *codec);
int snd_soc_cache_exit(struct snd_soc_codec *codec); int snd_soc_cache_exit(struct snd_soc_codec *codec);
......
...@@ -1327,8 +1327,7 @@ static int pm860x_probe(struct snd_soc_codec *codec) ...@@ -1327,8 +1327,7 @@ static int pm860x_probe(struct snd_soc_codec *codec)
pm860x->codec = codec; pm860x->codec = codec;
codec->control_data = pm860x->regmap; ret = snd_soc_codec_set_cache_io(codec, pm860x->regmap);
ret = snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP);
if (ret) if (ret)
return ret; return ret;
......
...@@ -138,9 +138,8 @@ static int cq93vc_probe(struct snd_soc_codec *codec) ...@@ -138,9 +138,8 @@ static int cq93vc_probe(struct snd_soc_codec *codec)
struct davinci_vc *davinci_vc = codec->dev->platform_data; struct davinci_vc *davinci_vc = codec->dev->platform_data;
davinci_vc->cq93vc.codec = codec; davinci_vc->cq93vc.codec = codec;
codec->control_data = davinci_vc->regmap;
snd_soc_codec_set_cache_io(codec, 32, 32, SND_SOC_REGMAP); snd_soc_codec_set_cache_io(codec, davinci_vc->regmap);
/* Off, with power on */ /* Off, with power on */
cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY); cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
......
...@@ -614,8 +614,8 @@ static int mc13783_probe(struct snd_soc_codec *codec) ...@@ -614,8 +614,8 @@ static int mc13783_probe(struct snd_soc_codec *codec)
struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec);
int ret; int ret;
codec->control_data = dev_get_regmap(codec->dev->parent, NULL); ret = snd_soc_codec_set_cache_io(codec,
ret = snd_soc_codec_set_cache_io(codec, 8, 24, SND_SOC_REGMAP); dev_get_regmap(codec->dev->parent, NULL));
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
return ret; return ret;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <linux/regmap.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/initval.h> #include <sound/initval.h>
...@@ -209,8 +210,9 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream, ...@@ -209,8 +210,9 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream,
static int si476x_codec_probe(struct snd_soc_codec *codec) static int si476x_codec_probe(struct snd_soc_codec *codec)
{ {
codec->control_data = dev_get_regmap(codec->dev->parent, NULL); struct regmap *regmap = dev_get_regmap(codec->dev->parent, NULL);
return snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP);
return snd_soc_codec_set_cache_io(codec, regmap);
} }
static struct snd_soc_dai_ops si476x_dai_ops = { static struct snd_soc_dai_ops si476x_dai_ops = {
......
...@@ -122,7 +122,6 @@ struct tlv320dac33_priv { ...@@ -122,7 +122,6 @@ struct tlv320dac33_priv {
unsigned int uthr; unsigned int uthr;
enum dac33_state state; enum dac33_state state;
enum snd_soc_control_type control_type;
void *control_data; void *control_data;
}; };
......
...@@ -1758,9 +1758,7 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec) ...@@ -1758,9 +1758,7 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec)
struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec);
int ret; int ret;
codec->control_data = priv->core.arizona->regmap; ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap);
ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
if (ret != 0) if (ret != 0)
return ret; return ret;
......
...@@ -1588,10 +1588,9 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec) ...@@ -1588,10 +1588,9 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec)
struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec); struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec);
int ret; int ret;
codec->control_data = priv->core.arizona->regmap;
priv->core.arizona->dapm = &codec->dapm; priv->core.arizona->dapm = &codec->dapm;
ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP); ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap);
if (ret != 0) if (ret != 0)
return ret; return ret;
......
...@@ -1505,9 +1505,7 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec) ...@@ -1505,9 +1505,7 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec)
if (ret != 0) if (ret != 0)
return ret; return ret;
codec->control_data = wm8350->regmap; snd_soc_codec_set_cache_io(codec, wm8350->regmap);
snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
/* Put the codec into reset if it wasn't already */ /* Put the codec into reset if it wasn't already */
wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA);
......
...@@ -1310,10 +1310,9 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec) ...@@ -1310,10 +1310,9 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec)
snd_soc_codec_set_drvdata(codec, priv); snd_soc_codec_set_drvdata(codec, priv);
priv->wm8400 = wm8400; priv->wm8400 = wm8400;
codec->control_data = wm8400->regmap;
priv->codec = codec; priv->codec = codec;
snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP); snd_soc_codec_set_cache_io(codec, wm8400->regmap);
ret = devm_regulator_bulk_get(wm8400->dev, ret = devm_regulator_bulk_get(wm8400->dev,
ARRAY_SIZE(power), &power[0]); ARRAY_SIZE(power), &power[0]);
......
...@@ -3985,9 +3985,8 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -3985,9 +3985,8 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
int ret, i; int ret, i;
wm8994->hubs.codec = codec; wm8994->hubs.codec = codec;
codec->control_data = control->regmap;
snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP); snd_soc_codec_set_cache_io(codec, control->regmap);
mutex_init(&wm8994->accdet_lock); mutex_init(&wm8994->accdet_lock);
INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap, INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap,
......
...@@ -1052,9 +1052,7 @@ static int wm8997_codec_probe(struct snd_soc_codec *codec) ...@@ -1052,9 +1052,7 @@ static int wm8997_codec_probe(struct snd_soc_codec *codec)
struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec); struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec);
int ret; int ret;
codec->control_data = priv->core.arizona->regmap; ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap);
ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
if (ret != 0) if (ret != 0)
return ret; return ret;
......
...@@ -1139,7 +1139,7 @@ static int soc_probe_codec(struct snd_soc_card *card, ...@@ -1139,7 +1139,7 @@ static int soc_probe_codec(struct snd_soc_card *card,
/* Set the default I/O up try regmap */ /* Set the default I/O up try regmap */
if (dev_get_regmap(codec->dev, NULL)) if (dev_get_regmap(codec->dev, NULL))
snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP); snd_soc_codec_set_cache_io(codec, NULL);
if (driver->probe) { if (driver->probe) {
ret = driver->probe(codec); ret = driver->probe(codec);
......
...@@ -69,9 +69,7 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg) ...@@ -69,9 +69,7 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg)
* snd_soc_codec_set_cache_io: Set up standard I/O functions. * snd_soc_codec_set_cache_io: Set up standard I/O functions.
* *
* @codec: CODEC to configure. * @codec: CODEC to configure.
* @addr_bits: Number of bits of register address data. * @map: Register map to write to
* @data_bits: Number of bits of data per register.
* @control: Control bus used.
* *
* Register formats are frequently shared between many I2C and SPI * Register formats are frequently shared between many I2C and SPI
* devices. In order to promote code reuse the ASoC core provides * devices. In order to promote code reuse the ASoC core provides
...@@ -85,41 +83,36 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg) ...@@ -85,41 +83,36 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg)
* volatile registers. * volatile registers.
*/ */
int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
int addr_bits, int data_bits, struct regmap *regmap)
enum snd_soc_control_type control)
{ {
int ret; int ret;
/* Device has made its own regmap arrangements */
if (!regmap)
codec->control_data = dev_get_regmap(codec->dev, NULL);
else
codec->control_data = regmap;
if (IS_ERR(codec->control_data))
return PTR_ERR(codec->control_data);
codec->write = hw_write; codec->write = hw_write;
codec->read = hw_read; codec->read = hw_read;
switch (control) { ret = regmap_get_val_bytes(codec->control_data);
case SND_SOC_REGMAP: /* Errors are legitimate for non-integer byte
/* Device has made its own regmap arrangements */ * multiples */
codec->using_regmap = true; if (ret > 0)
if (!codec->control_data) codec->val_bytes = ret;
codec->control_data = dev_get_regmap(codec->dev, NULL);
codec->using_regmap = true;
if (codec->control_data) {
ret = regmap_get_val_bytes(codec->control_data);
/* Errors are legitimate for non-integer byte
* multiples */
if (ret > 0)
codec->val_bytes = ret;
}
break;
default:
return -EINVAL;
}
return PTR_ERR_OR_ZERO(codec->control_data); return 0;
} }
EXPORT_SYMBOL_GPL(snd_soc_codec_set_cache_io); EXPORT_SYMBOL_GPL(snd_soc_codec_set_cache_io);
#else #else
int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
int addr_bits, int data_bits, struct regmap *regmap)
enum snd_soc_control_type control)
{ {
return -ENOTSUPP; return -ENOTSUPP;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment