aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-io.c
diff options
context:
space:
mode:
authorXiubo Li <Li.Xiubo@freescale.com>2014-03-11 00:43:21 -0400
committerMark Brown <broonie@linaro.org>2014-03-11 05:59:06 -0400
commit092eba937d948a76ff55825922eff4df010f6a17 (patch)
tree9ceee6b8bb67ec90bdb1d1f4dd812e3dfba8547d /sound/soc/soc-io.c
parent5d6be5aa6becc750c5c2aa0ef8f7209ce19aa328 (diff)
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: Xiubo Li <Li.Xiubo@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/soc-io.c')
-rw-r--r--sound/soc/soc-io.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c
index 18353f111b6a..8aa086996866 100644
--- a/sound/soc/soc-io.c
+++ b/sound/soc/soc-io.c
@@ -69,9 +69,7 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg)
69 * snd_soc_codec_set_cache_io: Set up standard I/O functions. 69 * snd_soc_codec_set_cache_io: Set up standard I/O functions.
70 * 70 *
71 * @codec: CODEC to configure. 71 * @codec: CODEC to configure.
72 * @addr_bits: Number of bits of register address data. 72 * @map: Register map to write to
73 * @data_bits: Number of bits of data per register.
74 * @control: Control bus used.
75 * 73 *
76 * Register formats are frequently shared between many I2C and SPI 74 * Register formats are frequently shared between many I2C and SPI
77 * devices. In order to promote code reuse the ASoC core provides 75 * 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 * volatile registers. 83 * volatile registers.
86 */ 84 */
87int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, 85int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
88 int addr_bits, int data_bits, 86 struct regmap *regmap)
89 enum snd_soc_control_type control)
90{ 87{
91 int ret; 88 int ret;
92 89
90 /* Device has made its own regmap arrangements */
91 if (!regmap)
92 codec->control_data = dev_get_regmap(codec->dev, NULL);
93 else
94 codec->control_data = regmap;
95
96 if (IS_ERR(codec->control_data))
97 return PTR_ERR(codec->control_data);
98
93 codec->write = hw_write; 99 codec->write = hw_write;
94 codec->read = hw_read; 100 codec->read = hw_read;
95 101
96 switch (control) { 102 ret = regmap_get_val_bytes(codec->control_data);
97 case SND_SOC_REGMAP: 103 /* Errors are legitimate for non-integer byte
98 /* Device has made its own regmap arrangements */ 104 * multiples */
99 codec->using_regmap = true; 105 if (ret > 0)
100 if (!codec->control_data) 106 codec->val_bytes = ret;
101 codec->control_data = dev_get_regmap(codec->dev, NULL); 107
102 108 codec->using_regmap = true;
103 if (codec->control_data) {
104 ret = regmap_get_val_bytes(codec->control_data);
105 /* Errors are legitimate for non-integer byte
106 * multiples */
107 if (ret > 0)
108 codec->val_bytes = ret;
109 }
110 break;
111
112 default:
113 return -EINVAL;
114 }
115 109
116 return PTR_ERR_OR_ZERO(codec->control_data); 110 return 0;
117} 111}
118EXPORT_SYMBOL_GPL(snd_soc_codec_set_cache_io); 112EXPORT_SYMBOL_GPL(snd_soc_codec_set_cache_io);
119#else 113#else
120int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, 114int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
121 int addr_bits, int data_bits, 115 struct regmap *regmap)
122 enum snd_soc_control_type control)
123{ 116{
124 return -ENOTSUPP; 117 return -ENOTSUPP;
125} 118}