aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/soc-topology.h13
-rw-r--r--sound/soc/codecs/88pm860x-codec.c28
-rw-r--r--sound/soc/codecs/ab8500-codec.c7
-rw-r--r--sound/soc/codecs/adau1373.c21
-rw-r--r--sound/soc/codecs/alc5623.c7
-rw-r--r--sound/soc/codecs/alc5632.c7
-rw-r--r--sound/soc/codecs/cs42l52.c7
-rw-r--r--sound/soc/codecs/cs42l56.c21
-rw-r--r--sound/soc/codecs/cs42l73.c14
-rw-r--r--sound/soc/codecs/da7210.c22
-rw-r--r--sound/soc/codecs/da7213.c15
-rw-r--r--sound/soc/codecs/da9055.c15
-rw-r--r--sound/soc/codecs/jz4740.c7
-rw-r--r--sound/soc/codecs/max9768.c7
-rw-r--r--sound/soc/codecs/max98088.c23
-rw-r--r--sound/soc/codecs/max98090.c42
-rw-r--r--sound/soc/codecs/max98095.c35
-rw-r--r--sound/soc/codecs/max9850.c7
-rw-r--r--sound/soc/codecs/max9877.c14
-rw-r--r--sound/soc/codecs/rt5631.c7
-rw-r--r--sound/soc/codecs/rt5640.c7
-rw-r--r--sound/soc/codecs/rt5645.c7
-rw-r--r--sound/soc/codecs/rt5651.c7
-rw-r--r--sound/soc/codecs/rt5670.c7
-rw-r--r--sound/soc/codecs/rt5677.c7
-rw-r--r--sound/soc/codecs/sgtl5000.c7
-rw-r--r--sound/soc/codecs/ssm2602.c7
-rw-r--r--sound/soc/codecs/tas2552.c15
-rw-r--r--sound/soc/codecs/tas2552.h2
-rw-r--r--sound/soc/codecs/tas5086.c10
-rw-r--r--sound/soc/codecs/tpa6130a2.c14
-rw-r--r--sound/soc/codecs/twl4030.c7
-rw-r--r--sound/soc/codecs/uda1380.c14
-rw-r--r--sound/soc/codecs/wm8350.c7
-rw-r--r--sound/soc/codecs/wm8400.c5
-rw-r--r--sound/soc/codecs/wm8737.c7
-rw-r--r--sound/soc/codecs/wm8753.c7
-rw-r--r--sound/soc/codecs/wm8961.c7
-rw-r--r--sound/soc/codecs/wm8962.c14
-rw-r--r--sound/soc/codecs/wm8990.c5
-rw-r--r--sound/soc/codecs/wm8991.c52
-rw-r--r--sound/soc/codecs/wm8993.c7
-rw-r--r--sound/soc/codecs/wm9081.c7
-rw-r--r--sound/soc/codecs/wm9090.c21
-rw-r--r--sound/soc/codecs/wm9713.c7
-rw-r--r--sound/soc/codecs/wm_hubs.c7
-rw-r--r--sound/soc/soc-topology.c120
-rw-r--r--sound/soc/tegra/tegra20_das.c23
-rw-r--r--sound/soc/tegra/tegra20_i2s.c23
-rw-r--r--sound/soc/tegra/tegra20_spdif.c47
-rw-r--r--sound/soc/tegra/tegra30_ahub.c80
-rw-r--r--sound/soc/tegra/tegra30_i2s.c23
52 files changed, 357 insertions, 542 deletions
diff --git a/include/sound/soc-topology.h b/include/sound/soc-topology.h
index 427bc41df3ae..086cd7ff6ddc 100644
--- a/include/sound/soc-topology.h
+++ b/include/sound/soc-topology.h
@@ -89,6 +89,13 @@ struct snd_soc_tplg_kcontrol_ops {
89 struct snd_ctl_elem_info *uinfo); 89 struct snd_ctl_elem_info *uinfo);
90}; 90};
91 91
92/* Bytes ext operations, for TLV byte controls */
93struct snd_soc_tplg_bytes_ext_ops {
94 u32 id;
95 int (*get)(unsigned int __user *bytes, unsigned int size);
96 int (*put)(const unsigned int __user *bytes, unsigned int size);
97};
98
92/* 99/*
93 * DAPM widget event handlers - used to map handlers onto widgets. 100 * DAPM widget event handlers - used to map handlers onto widgets.
94 */ 101 */
@@ -136,9 +143,13 @@ struct snd_soc_tplg_ops {
136 int (*manifest)(struct snd_soc_component *, 143 int (*manifest)(struct snd_soc_component *,
137 struct snd_soc_tplg_manifest *); 144 struct snd_soc_tplg_manifest *);
138 145
139 /* bespoke kcontrol handlers available for binding */ 146 /* vendor specific kcontrol handlers available for binding */
140 const struct snd_soc_tplg_kcontrol_ops *io_ops; 147 const struct snd_soc_tplg_kcontrol_ops *io_ops;
141 int io_ops_count; 148 int io_ops_count;
149
150 /* vendor specific bytes ext handlers available for binding */
151 const struct snd_soc_tplg_bytes_ext_ops *bytes_ext_ops;
152 int bytes_ext_ops_count;
142}; 153};
143 154
144#ifdef CONFIG_SND_SOC_TOPOLOGY 155#ifdef CONFIG_SND_SOC_TOPOLOGY
diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c
index 4d91a6aa696b..e8bed6b0c9db 100644
--- a/sound/soc/codecs/88pm860x-codec.c
+++ b/sound/soc/codecs/88pm860x-codec.c
@@ -156,33 +156,29 @@ static const DECLARE_TLV_DB_SCALE(dpga_tlv, -9450, 150, 1);
156static const DECLARE_TLV_DB_SCALE(adc_tlv, -900, 300, 0); 156static const DECLARE_TLV_DB_SCALE(adc_tlv, -900, 300, 0);
157 157
158/* {-23, -17, -13.5, -11, -9, -6, -3, 0}dB */ 158/* {-23, -17, -13.5, -11, -9, -6, -3, 0}dB */
159static const unsigned int mic_tlv[] = { 159static const DECLARE_TLV_DB_RANGE(mic_tlv,
160 TLV_DB_RANGE_HEAD(5),
161 0, 0, TLV_DB_SCALE_ITEM(-2300, 0, 0), 160 0, 0, TLV_DB_SCALE_ITEM(-2300, 0, 0),
162 1, 1, TLV_DB_SCALE_ITEM(-1700, 0, 0), 161 1, 1, TLV_DB_SCALE_ITEM(-1700, 0, 0),
163 2, 2, TLV_DB_SCALE_ITEM(-1350, 0, 0), 162 2, 2, TLV_DB_SCALE_ITEM(-1350, 0, 0),
164 3, 3, TLV_DB_SCALE_ITEM(-1100, 0, 0), 163 3, 3, TLV_DB_SCALE_ITEM(-1100, 0, 0),
165 4, 7, TLV_DB_SCALE_ITEM(-900, 300, 0), 164 4, 7, TLV_DB_SCALE_ITEM(-900, 300, 0)
166}; 165);
167 166
168/* {0, 0, 0, -6, 0, 6, 12, 18}dB */ 167/* {0, 0, 0, -6, 0, 6, 12, 18}dB */
169static const unsigned int aux_tlv[] = { 168static const DECLARE_TLV_DB_RANGE(aux_tlv,
170 TLV_DB_RANGE_HEAD(2),
171 0, 2, TLV_DB_SCALE_ITEM(0, 0, 0), 169 0, 2, TLV_DB_SCALE_ITEM(0, 0, 0),
172 3, 7, TLV_DB_SCALE_ITEM(-600, 600, 0), 170 3, 7, TLV_DB_SCALE_ITEM(-600, 600, 0)
173}; 171);
174 172
175/* {-16, -13, -10, -7, -5.2, -3,3, -2.2, 0}dB, mute instead of -16dB */ 173/* {-16, -13, -10, -7, -5.2, -3,3, -2.2, 0}dB, mute instead of -16dB */
176static const unsigned int out_tlv[] = { 174static const DECLARE_TLV_DB_RANGE(out_tlv,
177 TLV_DB_RANGE_HEAD(4),
178 0, 3, TLV_DB_SCALE_ITEM(-1600, 300, 1), 175 0, 3, TLV_DB_SCALE_ITEM(-1600, 300, 1),
179 4, 4, TLV_DB_SCALE_ITEM(-520, 0, 0), 176 4, 4, TLV_DB_SCALE_ITEM(-520, 0, 0),
180 5, 5, TLV_DB_SCALE_ITEM(-330, 0, 0), 177 5, 5, TLV_DB_SCALE_ITEM(-330, 0, 0),
181 6, 7, TLV_DB_SCALE_ITEM(-220, 220, 0), 178 6, 7, TLV_DB_SCALE_ITEM(-220, 220, 0)
182}; 179);
183 180
184static const unsigned int st_tlv[] = { 181static const DECLARE_TLV_DB_RANGE(st_tlv,
185 TLV_DB_RANGE_HEAD(8),
186 0, 1, TLV_DB_SCALE_ITEM(-12041, 602, 0), 182 0, 1, TLV_DB_SCALE_ITEM(-12041, 602, 0),
187 2, 3, TLV_DB_SCALE_ITEM(-11087, 250, 0), 183 2, 3, TLV_DB_SCALE_ITEM(-11087, 250, 0),
188 4, 5, TLV_DB_SCALE_ITEM(-10643, 158, 0), 184 4, 5, TLV_DB_SCALE_ITEM(-10643, 158, 0),
@@ -190,8 +186,8 @@ static const unsigned int st_tlv[] = {
190 8, 9, TLV_DB_SCALE_ITEM(-10133, 92, 0), 186 8, 9, TLV_DB_SCALE_ITEM(-10133, 92, 0),
191 10, 13, TLV_DB_SCALE_ITEM(-9958, 70, 0), 187 10, 13, TLV_DB_SCALE_ITEM(-9958, 70, 0),
192 14, 17, TLV_DB_SCALE_ITEM(-9689, 53, 0), 188 14, 17, TLV_DB_SCALE_ITEM(-9689, 53, 0),
193 18, 271, TLV_DB_SCALE_ITEM(-9484, 37, 0), 189 18, 271, TLV_DB_SCALE_ITEM(-9484, 37, 0)
194}; 190);
195 191
196/* Sidetone Gain = M * 2^(-5-N) */ 192/* Sidetone Gain = M * 2^(-5-N) */
197struct st_gain { 193struct st_gain {
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c
index c7d243db010a..affb192238a4 100644
--- a/sound/soc/codecs/ab8500-codec.c
+++ b/sound/soc/codecs/ab8500-codec.c
@@ -1335,11 +1335,10 @@ static DECLARE_TLV_DB_SCALE(dax_dig_gain_tlv, -6300, 100, 1);
1335static DECLARE_TLV_DB_SCALE(hs_ear_dig_gain_tlv, -100, 100, 1); 1335static DECLARE_TLV_DB_SCALE(hs_ear_dig_gain_tlv, -100, 100, 1);
1336/* -1dB = Mute */ 1336/* -1dB = Mute */
1337 1337
1338static const unsigned int hs_gain_tlv[] = { 1338static const DECLARE_TLV_DB_RANGE(hs_gain_tlv,
1339 TLV_DB_RANGE_HEAD(2),
1340 0, 3, TLV_DB_SCALE_ITEM(-3200, 400, 0), 1339 0, 3, TLV_DB_SCALE_ITEM(-3200, 400, 0),
1341 4, 15, TLV_DB_SCALE_ITEM(-1800, 200, 0), 1340 4, 15, TLV_DB_SCALE_ITEM(-1800, 200, 0)
1342}; 1341);
1343 1342
1344static DECLARE_TLV_DB_SCALE(mic_gain_tlv, 0, 100, 0); 1343static DECLARE_TLV_DB_SCALE(mic_gain_tlv, 0, 100, 0);
1345 1344
diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c
index 6c96860f46de..fe1353a797b9 100644
--- a/sound/soc/codecs/adau1373.c
+++ b/sound/soc/codecs/adau1373.c
@@ -320,13 +320,12 @@ static const struct reg_default adau1373_reg_defaults[] = {
320 { ADAU1373_DIGEN, 0x00 }, 320 { ADAU1373_DIGEN, 0x00 },
321}; 321};
322 322
323static const unsigned int adau1373_out_tlv[] = { 323static const DECLARE_TLV_DB_RANGE(adau1373_out_tlv,
324 TLV_DB_RANGE_HEAD(4),
325 0, 7, TLV_DB_SCALE_ITEM(-7900, 400, 1), 324 0, 7, TLV_DB_SCALE_ITEM(-7900, 400, 1),
326 8, 15, TLV_DB_SCALE_ITEM(-4700, 300, 0), 325 8, 15, TLV_DB_SCALE_ITEM(-4700, 300, 0),
327 16, 23, TLV_DB_SCALE_ITEM(-2300, 200, 0), 326 16, 23, TLV_DB_SCALE_ITEM(-2300, 200, 0),
328 24, 31, TLV_DB_SCALE_ITEM(-700, 100, 0), 327 24, 31, TLV_DB_SCALE_ITEM(-700, 100, 0)
329}; 328);
330 329
331static const DECLARE_TLV_DB_MINMAX(adau1373_digital_tlv, -9563, 0); 330static const DECLARE_TLV_DB_MINMAX(adau1373_digital_tlv, -9563, 0);
332static const DECLARE_TLV_DB_SCALE(adau1373_in_pga_tlv, -1300, 100, 1); 331static const DECLARE_TLV_DB_SCALE(adau1373_in_pga_tlv, -1300, 100, 1);
@@ -381,12 +380,11 @@ static const char *adau1373_bass_hpf_cutoff_text[] = {
381 "158Hz", "232Hz", "347Hz", "520Hz", 380 "158Hz", "232Hz", "347Hz", "520Hz",
382}; 381};
383 382
384static const unsigned int adau1373_bass_tlv[] = { 383static const DECLARE_TLV_DB_RANGE(adau1373_bass_tlv,
385 TLV_DB_RANGE_HEAD(3),
386 0, 2, TLV_DB_SCALE_ITEM(-600, 600, 1), 384 0, 2, TLV_DB_SCALE_ITEM(-600, 600, 1),
387 3, 4, TLV_DB_SCALE_ITEM(950, 250, 0), 385 3, 4, TLV_DB_SCALE_ITEM(950, 250, 0),
388 5, 7, TLV_DB_SCALE_ITEM(1400, 150, 0), 386 5, 7, TLV_DB_SCALE_ITEM(1400, 150, 0)
389}; 387);
390 388
391static SOC_ENUM_SINGLE_DECL(adau1373_bass_lpf_cutoff_enum, 389static SOC_ENUM_SINGLE_DECL(adau1373_bass_lpf_cutoff_enum,
392 ADAU1373_BASS1, 5, adau1373_bass_lpf_cutoff_text); 390 ADAU1373_BASS1, 5, adau1373_bass_lpf_cutoff_text);
@@ -414,11 +412,10 @@ static SOC_ENUM_SINGLE_DECL(adau1373_3d_level_enum,
414static SOC_ENUM_SINGLE_DECL(adau1373_3d_cutoff_enum, 412static SOC_ENUM_SINGLE_DECL(adau1373_3d_cutoff_enum,
415 ADAU1373_3D_CTRL1, 0, adau1373_3d_cutoff_text); 413 ADAU1373_3D_CTRL1, 0, adau1373_3d_cutoff_text);
416 414
417static const unsigned int adau1373_3d_tlv[] = { 415static const DECLARE_TLV_DB_RANGE(adau1373_3d_tlv,
418 TLV_DB_RANGE_HEAD(2),
419 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 416 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
420 1, 7, TLV_DB_LINEAR_ITEM(-1800, -120), 417 1, 7, TLV_DB_LINEAR_ITEM(-1800, -120)
421}; 418);
422 419
423static const char *adau1373_lr_mux_text[] = { 420static const char *adau1373_lr_mux_text[] = {
424 "Mute", 421 "Mute",
diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c
index cf99c4e90acc..d2e3a3ef7499 100644
--- a/sound/soc/codecs/alc5623.c
+++ b/sound/soc/codecs/alc5623.c
@@ -82,12 +82,11 @@ static int amp_mixer_event(struct snd_soc_dapm_widget *w,
82static const DECLARE_TLV_DB_SCALE(vol_tlv, -3450, 150, 0); 82static const DECLARE_TLV_DB_SCALE(vol_tlv, -3450, 150, 0);
83static const DECLARE_TLV_DB_SCALE(hp_tlv, -4650, 150, 0); 83static const DECLARE_TLV_DB_SCALE(hp_tlv, -4650, 150, 0);
84static const DECLARE_TLV_DB_SCALE(adc_rec_tlv, -1650, 150, 0); 84static const DECLARE_TLV_DB_SCALE(adc_rec_tlv, -1650, 150, 0);
85static const unsigned int boost_tlv[] = { 85static const DECLARE_TLV_DB_RANGE(boost_tlv,
86 TLV_DB_RANGE_HEAD(3),
87 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 86 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
88 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), 87 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
89 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0), 88 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0)
90}; 89);
91static const DECLARE_TLV_DB_SCALE(dig_tlv, 0, 600, 0); 90static const DECLARE_TLV_DB_SCALE(dig_tlv, 0, 600, 0);
92 91
93static const struct snd_kcontrol_new alc5621_vol_snd_controls[] = { 92static const struct snd_kcontrol_new alc5621_vol_snd_controls[] = {
diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c
index ef6de511dc7e..4d3ba33eb6f9 100644
--- a/sound/soc/codecs/alc5632.c
+++ b/sound/soc/codecs/alc5632.c
@@ -146,11 +146,10 @@ static const DECLARE_TLV_DB_SCALE(vol_tlv, -3450, 150, 0);
146static const DECLARE_TLV_DB_SCALE(hp_tlv, -4650, 150, 0); 146static const DECLARE_TLV_DB_SCALE(hp_tlv, -4650, 150, 0);
147/* -16.5db min scale, 1.5db steps, no mute */ 147/* -16.5db min scale, 1.5db steps, no mute */
148static const DECLARE_TLV_DB_SCALE(adc_rec_tlv, -1650, 150, 0); 148static const DECLARE_TLV_DB_SCALE(adc_rec_tlv, -1650, 150, 0);
149static const unsigned int boost_tlv[] = { 149static const DECLARE_TLV_DB_RANGE(boost_tlv,
150 TLV_DB_RANGE_HEAD(2),
151 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0), 150 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0),
152 1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0), 151 1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0)
153}; 152);
154/* 0db min scale, 6 db steps, no mute */ 153/* 0db min scale, 6 db steps, no mute */
155static const DECLARE_TLV_DB_SCALE(dig_tlv, 0, 600, 0); 154static const DECLARE_TLV_DB_SCALE(dig_tlv, 0, 600, 0);
156/* 0db min scalem 0.75db steps, no mute */ 155/* 0db min scalem 0.75db steps, no mute */
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index b256424d3f9a..47b97fcefb0b 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -145,11 +145,10 @@ static DECLARE_TLV_DB_SCALE(mix_tlv, -50, 50, 0);
145 145
146static DECLARE_TLV_DB_SCALE(beep_tlv, -56, 200, 0); 146static DECLARE_TLV_DB_SCALE(beep_tlv, -56, 200, 0);
147 147
148static const unsigned int limiter_tlv[] = { 148static const DECLARE_TLV_DB_RANGE(limiter_tlv,
149 TLV_DB_RANGE_HEAD(2),
150 0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0), 149 0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0),
151 3, 7, TLV_DB_SCALE_ITEM(-1200, 300, 0), 150 3, 7, TLV_DB_SCALE_ITEM(-1200, 300, 0)
152}; 151);
153 152
154static const char * const cs42l52_adca_text[] = { 153static const char * const cs42l52_adca_text[] = {
155 "Input1A", "Input2A", "Input3A", "Input4A", "PGA Input Left"}; 154 "Input1A", "Input2A", "Input3A", "Input4A", "PGA Input Left"};
diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c
index 52fe7a5ac408..7cd5f769bb61 100644
--- a/sound/soc/codecs/cs42l56.c
+++ b/sound/soc/codecs/cs42l56.c
@@ -140,21 +140,18 @@ static DECLARE_TLV_DB_SCALE(tone_tlv, -1050, 150, 0);
140static DECLARE_TLV_DB_SCALE(preamp_tlv, 0, 1000, 0); 140static DECLARE_TLV_DB_SCALE(preamp_tlv, 0, 1000, 0);
141static DECLARE_TLV_DB_SCALE(pga_tlv, -600, 50, 0); 141static DECLARE_TLV_DB_SCALE(pga_tlv, -600, 50, 0);
142 142
143static const unsigned int ngnb_tlv[] = { 143static const DECLARE_TLV_DB_RANGE(ngnb_tlv,
144 TLV_DB_RANGE_HEAD(2),
145 0, 1, TLV_DB_SCALE_ITEM(-8200, 600, 0), 144 0, 1, TLV_DB_SCALE_ITEM(-8200, 600, 0),
146 2, 5, TLV_DB_SCALE_ITEM(-7600, 300, 0), 145 2, 5, TLV_DB_SCALE_ITEM(-7600, 300, 0)
147}; 146);
148static const unsigned int ngb_tlv[] = { 147static const DECLARE_TLV_DB_RANGE(ngb_tlv,
149 TLV_DB_RANGE_HEAD(2),
150 0, 2, TLV_DB_SCALE_ITEM(-6400, 600, 0), 148 0, 2, TLV_DB_SCALE_ITEM(-6400, 600, 0),
151 3, 7, TLV_DB_SCALE_ITEM(-4600, 300, 0), 149 3, 7, TLV_DB_SCALE_ITEM(-4600, 300, 0)
152}; 150);
153static const unsigned int alc_tlv[] = { 151static const DECLARE_TLV_DB_RANGE(alc_tlv,
154 TLV_DB_RANGE_HEAD(2),
155 0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0), 152 0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0),
156 3, 7, TLV_DB_SCALE_ITEM(-1200, 300, 0), 153 3, 7, TLV_DB_SCALE_ITEM(-1200, 300, 0)
157}; 154);
158 155
159static const char * const beep_config_text[] = { 156static const char * const beep_config_text[] = {
160 "Off", "Single", "Multiple", "Continuous" 157 "Off", "Single", "Multiple", "Continuous"
diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c
index a8f468689d26..42a8fd4e1f9b 100644
--- a/sound/soc/codecs/cs42l73.c
+++ b/sound/soc/codecs/cs42l73.c
@@ -161,11 +161,10 @@ static bool cs42l73_readable_register(struct device *dev, unsigned int reg)
161 } 161 }
162} 162}
163 163
164static const unsigned int hpaloa_tlv[] = { 164static const DECLARE_TLV_DB_RANGE(hpaloa_tlv,
165 TLV_DB_RANGE_HEAD(2),
166 0, 13, TLV_DB_SCALE_ITEM(-7600, 200, 0), 165 0, 13, TLV_DB_SCALE_ITEM(-7600, 200, 0),
167 14, 75, TLV_DB_SCALE_ITEM(-4900, 100, 0), 166 14, 75, TLV_DB_SCALE_ITEM(-4900, 100, 0)
168}; 167);
169 168
170static DECLARE_TLV_DB_SCALE(adc_boost_tlv, 0, 2500, 0); 169static DECLARE_TLV_DB_SCALE(adc_boost_tlv, 0, 2500, 0);
171 170
@@ -175,11 +174,10 @@ static DECLARE_TLV_DB_SCALE(ipd_tlv, -9600, 100, 0);
175 174
176static DECLARE_TLV_DB_SCALE(micpga_tlv, -600, 50, 0); 175static DECLARE_TLV_DB_SCALE(micpga_tlv, -600, 50, 0);
177 176
178static const unsigned int limiter_tlv[] = { 177static const DECLARE_TLV_DB_RANGE(limiter_tlv,
179 TLV_DB_RANGE_HEAD(2),
180 0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0), 178 0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0),
181 3, 7, TLV_DB_SCALE_ITEM(-1200, 300, 0), 179 3, 7, TLV_DB_SCALE_ITEM(-1200, 300, 0)
182}; 180);
183 181
184static const DECLARE_TLV_DB_SCALE(attn_tlv, -6300, 100, 1); 182static const DECLARE_TLV_DB_SCALE(attn_tlv, -6300, 100, 1);
185 183
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c
index c7b3e927c606..7dc52fe67c80 100644
--- a/sound/soc/codecs/da7210.c
+++ b/sound/soc/codecs/da7210.c
@@ -267,33 +267,29 @@ enum clk_src {
267 * 267 *
268 * Reserved area are considered as "mute". 268 * Reserved area are considered as "mute".
269 */ 269 */
270static const unsigned int hp_out_tlv[] = { 270static const DECLARE_TLV_DB_RANGE(hp_out_tlv,
271 TLV_DB_RANGE_HEAD(2),
272 0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), 271 0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
273 /* -54 dB to +15 dB */ 272 /* -54 dB to +15 dB */
274 0x11, 0x3f, TLV_DB_SCALE_ITEM(-5400, 150, 0), 273 0x11, 0x3f, TLV_DB_SCALE_ITEM(-5400, 150, 0)
275}; 274);
276 275
277static const unsigned int lineout_vol_tlv[] = { 276static const DECLARE_TLV_DB_RANGE(lineout_vol_tlv,
278 TLV_DB_RANGE_HEAD(2),
279 0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), 277 0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
280 /* -54dB to 15dB */ 278 /* -54dB to 15dB */
281 0x11, 0x3f, TLV_DB_SCALE_ITEM(-5400, 150, 0) 279 0x11, 0x3f, TLV_DB_SCALE_ITEM(-5400, 150, 0)
282}; 280);
283 281
284static const unsigned int mono_vol_tlv[] = { 282static const DECLARE_TLV_DB_RANGE(mono_vol_tlv,
285 TLV_DB_RANGE_HEAD(2),
286 0x0, 0x2, TLV_DB_SCALE_ITEM(-1800, 0, 1), 283 0x0, 0x2, TLV_DB_SCALE_ITEM(-1800, 0, 1),
287 /* -18dB to 6dB */ 284 /* -18dB to 6dB */
288 0x3, 0x7, TLV_DB_SCALE_ITEM(-1800, 600, 0) 285 0x3, 0x7, TLV_DB_SCALE_ITEM(-1800, 600, 0)
289}; 286);
290 287
291static const unsigned int aux1_vol_tlv[] = { 288static const DECLARE_TLV_DB_RANGE(aux1_vol_tlv,
292 TLV_DB_RANGE_HEAD(2),
293 0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), 289 0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
294 /* -48dB to 21dB */ 290 /* -48dB to 21dB */
295 0x11, 0x3f, TLV_DB_SCALE_ITEM(-4800, 150, 0) 291 0x11, 0x3f, TLV_DB_SCALE_ITEM(-4800, 150, 0)
296}; 292);
297 293
298static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0); 294static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0);
299static const DECLARE_TLV_DB_SCALE(adc_eq_master_gain_tlv, -1800, 600, 1); 295static const DECLARE_TLV_DB_SCALE(adc_eq_master_gain_tlv, -1800, 600, 1);
diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c
index 47fc3bec8a9c..a9c86efb3187 100644
--- a/sound/soc/codecs/da7213.c
+++ b/sound/soc/codecs/da7213.c
@@ -28,27 +28,24 @@
28 28
29 29
30/* Gain and Volume */ 30/* Gain and Volume */
31static const unsigned int aux_vol_tlv[] = { 31static const DECLARE_TLV_DB_RANGE(aux_vol_tlv,
32 TLV_DB_RANGE_HEAD(2),
33 /* -54dB */ 32 /* -54dB */
34 0x0, 0x11, TLV_DB_SCALE_ITEM(-5400, 0, 0), 33 0x0, 0x11, TLV_DB_SCALE_ITEM(-5400, 0, 0),
35 /* -52.5dB to 15dB */ 34 /* -52.5dB to 15dB */
36 0x12, 0x3f, TLV_DB_SCALE_ITEM(-5250, 150, 0) 35 0x12, 0x3f, TLV_DB_SCALE_ITEM(-5250, 150, 0)
37}; 36);
38 37
39static const unsigned int digital_gain_tlv[] = { 38static const DECLARE_TLV_DB_RANGE(digital_gain_tlv,
40 TLV_DB_RANGE_HEAD(2),
41 0x0, 0x07, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), 39 0x0, 0x07, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
42 /* -78dB to 12dB */ 40 /* -78dB to 12dB */
43 0x08, 0x7f, TLV_DB_SCALE_ITEM(-7800, 75, 0) 41 0x08, 0x7f, TLV_DB_SCALE_ITEM(-7800, 75, 0)
44}; 42);
45 43
46static const unsigned int alc_analog_gain_tlv[] = { 44static const DECLARE_TLV_DB_RANGE(alc_analog_gain_tlv,
47 TLV_DB_RANGE_HEAD(2),
48 0x0, 0x0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), 45 0x0, 0x0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
49 /* 0dB to 36dB */ 46 /* 0dB to 36dB */
50 0x01, 0x07, TLV_DB_SCALE_ITEM(0, 600, 0) 47 0x01, 0x07, TLV_DB_SCALE_ITEM(0, 600, 0)
51}; 48);
52 49
53static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -600, 600, 0); 50static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -600, 600, 0);
54static const DECLARE_TLV_DB_SCALE(mixin_gain_tlv, -450, 150, 0); 51static const DECLARE_TLV_DB_SCALE(mixin_gain_tlv, -450, 150, 0);
diff --git a/sound/soc/codecs/da9055.c b/sound/soc/codecs/da9055.c
index 19635d830b47..0b2ede8db978 100644
--- a/sound/soc/codecs/da9055.c
+++ b/sound/soc/codecs/da9055.c
@@ -289,26 +289,23 @@ enum clk_src {
289 289
290/* Gain and Volume */ 290/* Gain and Volume */
291 291
292static const unsigned int aux_vol_tlv[] = { 292static const DECLARE_TLV_DB_RANGE(aux_vol_tlv,
293 TLV_DB_RANGE_HEAD(2),
294 0x0, 0x10, TLV_DB_SCALE_ITEM(-5400, 0, 0), 293 0x0, 0x10, TLV_DB_SCALE_ITEM(-5400, 0, 0),
295 /* -54dB to 15dB */ 294 /* -54dB to 15dB */
296 0x11, 0x3f, TLV_DB_SCALE_ITEM(-5400, 150, 0) 295 0x11, 0x3f, TLV_DB_SCALE_ITEM(-5400, 150, 0)
297}; 296);
298 297
299static const unsigned int digital_gain_tlv[] = { 298static const DECLARE_TLV_DB_RANGE(digital_gain_tlv,
300 TLV_DB_RANGE_HEAD(2),
301 0x0, 0x07, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), 299 0x0, 0x07, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
302 /* -78dB to 12dB */ 300 /* -78dB to 12dB */
303 0x08, 0x7f, TLV_DB_SCALE_ITEM(-7800, 75, 0) 301 0x08, 0x7f, TLV_DB_SCALE_ITEM(-7800, 75, 0)
304}; 302);
305 303
306static const unsigned int alc_analog_gain_tlv[] = { 304static const DECLARE_TLV_DB_RANGE(alc_analog_gain_tlv,
307 TLV_DB_RANGE_HEAD(2),
308 0x0, 0x0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1), 305 0x0, 0x0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
309 /* 0dB to 36dB */ 306 /* 0dB to 36dB */
310 0x01, 0x07, TLV_DB_SCALE_ITEM(0, 600, 0) 307 0x01, 0x07, TLV_DB_SCALE_ITEM(0, 600, 0)
311}; 308);
312 309
313static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -600, 600, 0); 310static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -600, 600, 0);
314static const DECLARE_TLV_DB_SCALE(mixin_gain_tlv, -450, 150, 0); 311static const DECLARE_TLV_DB_SCALE(mixin_gain_tlv, -450, 150, 0);
diff --git a/sound/soc/codecs/jz4740.c b/sound/soc/codecs/jz4740.c
index 9363fdbca9cd..1f5ab99956ed 100644
--- a/sound/soc/codecs/jz4740.c
+++ b/sound/soc/codecs/jz4740.c
@@ -78,11 +78,10 @@ struct jz4740_codec {
78 struct regmap *regmap; 78 struct regmap *regmap;
79}; 79};
80 80
81static const unsigned int jz4740_mic_tlv[] = { 81static const DECLARE_TLV_DB_RANGE(jz4740_mic_tlv,
82 TLV_DB_RANGE_HEAD(2),
83 0, 2, TLV_DB_SCALE_ITEM(0, 600, 0), 82 0, 2, TLV_DB_SCALE_ITEM(0, 600, 0),
84 3, 3, TLV_DB_SCALE_ITEM(2000, 0, 0), 83 3, 3, TLV_DB_SCALE_ITEM(2000, 0, 0)
85}; 84);
86 85
87static const DECLARE_TLV_DB_SCALE(jz4740_out_tlv, 0, 200, 0); 86static const DECLARE_TLV_DB_SCALE(jz4740_out_tlv, 0, 200, 0);
88static const DECLARE_TLV_DB_SCALE(jz4740_in_tlv, -3450, 150, 0); 87static const DECLARE_TLV_DB_SCALE(jz4740_in_tlv, -3450, 150, 0);
diff --git a/sound/soc/codecs/max9768.c b/sound/soc/codecs/max9768.c
index bd41128c6f0b..5b82e26cd5d1 100644
--- a/sound/soc/codecs/max9768.c
+++ b/sound/soc/codecs/max9768.c
@@ -63,8 +63,7 @@ static int max9768_set_gpio(struct snd_kcontrol *kcontrol,
63 return 0; 63 return 0;
64} 64}
65 65
66static const unsigned int volume_tlv[] = { 66static const DECLARE_TLV_DB_RANGE(volume_tlv,
67 TLV_DB_RANGE_HEAD(43),
68 0, 0, TLV_DB_SCALE_ITEM(-16150, 0, 0), 67 0, 0, TLV_DB_SCALE_ITEM(-16150, 0, 0),
69 1, 1, TLV_DB_SCALE_ITEM(-9280, 0, 0), 68 1, 1, TLV_DB_SCALE_ITEM(-9280, 0, 0),
70 2, 2, TLV_DB_SCALE_ITEM(-9030, 0, 0), 69 2, 2, TLV_DB_SCALE_ITEM(-9030, 0, 0),
@@ -107,8 +106,8 @@ static const unsigned int volume_tlv[] = {
107 51, 57, TLV_DB_SCALE_ITEM(290, 50, 0), 106 51, 57, TLV_DB_SCALE_ITEM(290, 50, 0),
108 58, 58, TLV_DB_SCALE_ITEM(650, 0, 0), 107 58, 58, TLV_DB_SCALE_ITEM(650, 0, 0),
109 59, 62, TLV_DB_SCALE_ITEM(700, 60, 0), 108 59, 62, TLV_DB_SCALE_ITEM(700, 60, 0),
110 63, 63, TLV_DB_SCALE_ITEM(950, 0, 0), 109 63, 63, TLV_DB_SCALE_ITEM(950, 0, 0)
111}; 110);
112 111
113static const struct snd_kcontrol_new max9768_volume[] = { 112static const struct snd_kcontrol_new max9768_volume[] = {
114 SOC_SINGLE_TLV("Playback Volume", MAX9768_VOL, 0, 63, 0, volume_tlv), 113 SOC_SINGLE_TLV("Playback Volume", MAX9768_VOL, 0, 63, 0, volume_tlv),
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
index 2c2df1790fd3..20dcc496d39c 100644
--- a/sound/soc/codecs/max98088.c
+++ b/sound/soc/codecs/max98088.c
@@ -425,29 +425,26 @@ static int max98088_mic2pre_get(struct snd_kcontrol *kcontrol,
425 return 0; 425 return 0;
426} 426}
427 427
428static const unsigned int max98088_micboost_tlv[] = { 428static const DECLARE_TLV_DB_RANGE(max98088_micboost_tlv,
429 TLV_DB_RANGE_HEAD(2), 429 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0),
430 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0), 430 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0)
431 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0), 431);
432};
433 432
434static const unsigned int max98088_hp_tlv[] = { 433static const DECLARE_TLV_DB_RANGE(max98088_hp_tlv,
435 TLV_DB_RANGE_HEAD(5),
436 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0), 434 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0),
437 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0), 435 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0),
438 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0), 436 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0),
439 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0), 437 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0),
440 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0), 438 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0)
441}; 439);
442 440
443static const unsigned int max98088_spk_tlv[] = { 441static const DECLARE_TLV_DB_RANGE(max98088_spk_tlv,
444 TLV_DB_RANGE_HEAD(5),
445 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0), 442 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0),
446 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0), 443 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0),
447 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0), 444 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0),
448 22, 27, TLV_DB_SCALE_ITEM(100, 100, 0), 445 22, 27, TLV_DB_SCALE_ITEM(100, 100, 0),
449 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0), 446 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0)
450}; 447);
451 448
452static const struct snd_kcontrol_new max98088_snd_controls[] = { 449static const struct snd_kcontrol_new max98088_snd_controls[] = {
453 450
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index cdf534e7a285..584aab83e478 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -293,22 +293,20 @@ static int max98090_reset(struct max98090_priv *max98090)
293 return ret; 293 return ret;
294} 294}
295 295
296static const unsigned int max98090_micboost_tlv[] = { 296static const DECLARE_TLV_DB_RANGE(max98090_micboost_tlv,
297 TLV_DB_RANGE_HEAD(2),
298 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0), 297 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0),
299 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0), 298 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0)
300}; 299);
301 300
302static const DECLARE_TLV_DB_SCALE(max98090_mic_tlv, 0, 100, 0); 301static const DECLARE_TLV_DB_SCALE(max98090_mic_tlv, 0, 100, 0);
303 302
304static const DECLARE_TLV_DB_SCALE(max98090_line_single_ended_tlv, 303static const DECLARE_TLV_DB_SCALE(max98090_line_single_ended_tlv,
305 -600, 600, 0); 304 -600, 600, 0);
306 305
307static const unsigned int max98090_line_tlv[] = { 306static const DECLARE_TLV_DB_RANGE(max98090_line_tlv,
308 TLV_DB_RANGE_HEAD(2),
309 0, 3, TLV_DB_SCALE_ITEM(-600, 300, 0), 307 0, 3, TLV_DB_SCALE_ITEM(-600, 300, 0),
310 4, 5, TLV_DB_SCALE_ITEM(1400, 600, 0), 308 4, 5, TLV_DB_SCALE_ITEM(1400, 600, 0)
311}; 309);
312 310
313static const DECLARE_TLV_DB_SCALE(max98090_avg_tlv, 0, 600, 0); 311static const DECLARE_TLV_DB_SCALE(max98090_avg_tlv, 0, 600, 0);
314static const DECLARE_TLV_DB_SCALE(max98090_av_tlv, -1200, 100, 0); 312static const DECLARE_TLV_DB_SCALE(max98090_av_tlv, -1200, 100, 0);
@@ -324,38 +322,34 @@ static const DECLARE_TLV_DB_SCALE(max98090_alccomp_tlv, -3100, 100, 0);
324static const DECLARE_TLV_DB_SCALE(max98090_drcexp_tlv, -6600, 100, 0); 322static const DECLARE_TLV_DB_SCALE(max98090_drcexp_tlv, -6600, 100, 0);
325static const DECLARE_TLV_DB_SCALE(max98090_sdg_tlv, 50, 200, 0); 323static const DECLARE_TLV_DB_SCALE(max98090_sdg_tlv, 50, 200, 0);
326 324
327static const unsigned int max98090_mixout_tlv[] = { 325static const DECLARE_TLV_DB_RANGE(max98090_mixout_tlv,
328 TLV_DB_RANGE_HEAD(2),
329 0, 1, TLV_DB_SCALE_ITEM(-1200, 250, 0), 326 0, 1, TLV_DB_SCALE_ITEM(-1200, 250, 0),
330 2, 3, TLV_DB_SCALE_ITEM(-600, 600, 0), 327 2, 3, TLV_DB_SCALE_ITEM(-600, 600, 0)
331}; 328);
332 329
333static const unsigned int max98090_hp_tlv[] = { 330static const DECLARE_TLV_DB_RANGE(max98090_hp_tlv,
334 TLV_DB_RANGE_HEAD(5),
335 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0), 331 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0),
336 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0), 332 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0),
337 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0), 333 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0),
338 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0), 334 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0),
339 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0), 335 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0)
340}; 336);
341 337
342static const unsigned int max98090_spk_tlv[] = { 338static const DECLARE_TLV_DB_RANGE(max98090_spk_tlv,
343 TLV_DB_RANGE_HEAD(5),
344 0, 4, TLV_DB_SCALE_ITEM(-4800, 400, 0), 339 0, 4, TLV_DB_SCALE_ITEM(-4800, 400, 0),
345 5, 10, TLV_DB_SCALE_ITEM(-2900, 300, 0), 340 5, 10, TLV_DB_SCALE_ITEM(-2900, 300, 0),
346 11, 14, TLV_DB_SCALE_ITEM(-1200, 200, 0), 341 11, 14, TLV_DB_SCALE_ITEM(-1200, 200, 0),
347 15, 29, TLV_DB_SCALE_ITEM(-500, 100, 0), 342 15, 29, TLV_DB_SCALE_ITEM(-500, 100, 0),
348 30, 39, TLV_DB_SCALE_ITEM(950, 50, 0), 343 30, 39, TLV_DB_SCALE_ITEM(950, 50, 0)
349}; 344);
350 345
351static const unsigned int max98090_rcv_lout_tlv[] = { 346static const DECLARE_TLV_DB_RANGE(max98090_rcv_lout_tlv,
352 TLV_DB_RANGE_HEAD(5),
353 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0), 347 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0),
354 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0), 348 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0),
355 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0), 349 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0),
356 22, 27, TLV_DB_SCALE_ITEM(100, 100, 0), 350 22, 27, TLV_DB_SCALE_ITEM(100, 100, 0),
357 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0), 351 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0)
358}; 352);
359 353
360static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol, 354static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol,
361 struct snd_ctl_elem_value *ucontrol) 355 struct snd_ctl_elem_value *ucontrol)
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index ad4909e17327..1fedac50355e 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -398,48 +398,43 @@ static int max98095_mic2pre_get(struct snd_kcontrol *kcontrol,
398 return 0; 398 return 0;
399} 399}
400 400
401static const unsigned int max98095_micboost_tlv[] = { 401static const DECLARE_TLV_DB_RANGE(max98095_micboost_tlv,
402 TLV_DB_RANGE_HEAD(2),
403 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0), 402 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0),
404 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0), 403 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0)
405}; 404);
406 405
407static const DECLARE_TLV_DB_SCALE(max98095_mic_tlv, 0, 100, 0); 406static const DECLARE_TLV_DB_SCALE(max98095_mic_tlv, 0, 100, 0);
408static const DECLARE_TLV_DB_SCALE(max98095_adc_tlv, -1200, 100, 0); 407static const DECLARE_TLV_DB_SCALE(max98095_adc_tlv, -1200, 100, 0);
409static const DECLARE_TLV_DB_SCALE(max98095_adcboost_tlv, 0, 600, 0); 408static const DECLARE_TLV_DB_SCALE(max98095_adcboost_tlv, 0, 600, 0);
410 409
411static const unsigned int max98095_hp_tlv[] = { 410static const DECLARE_TLV_DB_RANGE(max98095_hp_tlv,
412 TLV_DB_RANGE_HEAD(5),
413 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0), 411 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0),
414 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0), 412 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0),
415 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0), 413 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0),
416 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0), 414 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0),
417 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0), 415 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0)
418}; 416);
419 417
420static const unsigned int max98095_spk_tlv[] = { 418static const DECLARE_TLV_DB_RANGE(max98095_spk_tlv,
421 TLV_DB_RANGE_HEAD(4),
422 0, 10, TLV_DB_SCALE_ITEM(-5900, 400, 0), 419 0, 10, TLV_DB_SCALE_ITEM(-5900, 400, 0),
423 11, 18, TLV_DB_SCALE_ITEM(-1700, 200, 0), 420 11, 18, TLV_DB_SCALE_ITEM(-1700, 200, 0),
424 19, 27, TLV_DB_SCALE_ITEM(-200, 100, 0), 421 19, 27, TLV_DB_SCALE_ITEM(-200, 100, 0),
425 28, 39, TLV_DB_SCALE_ITEM(650, 50, 0), 422 28, 39, TLV_DB_SCALE_ITEM(650, 50, 0)
426}; 423);
427 424
428static const unsigned int max98095_rcv_lout_tlv[] = { 425static const DECLARE_TLV_DB_RANGE(max98095_rcv_lout_tlv,
429 TLV_DB_RANGE_HEAD(5),
430 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0), 426 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0),
431 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0), 427 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0),
432 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0), 428 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0),
433 22, 27, TLV_DB_SCALE_ITEM(100, 100, 0), 429 22, 27, TLV_DB_SCALE_ITEM(100, 100, 0),
434 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0), 430 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0)
435}; 431);
436 432
437static const unsigned int max98095_lin_tlv[] = { 433static const DECLARE_TLV_DB_RANGE(max98095_lin_tlv,
438 TLV_DB_RANGE_HEAD(3),
439 0, 2, TLV_DB_SCALE_ITEM(-600, 300, 0), 434 0, 2, TLV_DB_SCALE_ITEM(-600, 300, 0),
440 3, 3, TLV_DB_SCALE_ITEM(300, 1100, 0), 435 3, 3, TLV_DB_SCALE_ITEM(300, 1100, 0),
441 4, 5, TLV_DB_SCALE_ITEM(1400, 600, 0), 436 4, 5, TLV_DB_SCALE_ITEM(1400, 600, 0)
442}; 437);
443 438
444static const struct snd_kcontrol_new max98095_snd_controls[] = { 439static const struct snd_kcontrol_new max98095_snd_controls[] = {
445 440
diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c
index 7c990521638c..c14a79d026a1 100644
--- a/sound/soc/codecs/max9850.c
+++ b/sound/soc/codecs/max9850.c
@@ -67,13 +67,12 @@ static const struct regmap_config max9850_regmap = {
67 .cache_type = REGCACHE_RBTREE, 67 .cache_type = REGCACHE_RBTREE,
68}; 68};
69 69
70static const unsigned int max9850_tlv[] = { 70static const DECLARE_TLV_DB_RANGE(max9850_tlv,
71 TLV_DB_RANGE_HEAD(4),
72 0x18, 0x1f, TLV_DB_SCALE_ITEM(-7450, 400, 0), 71 0x18, 0x1f, TLV_DB_SCALE_ITEM(-7450, 400, 0),
73 0x20, 0x33, TLV_DB_SCALE_ITEM(-4150, 200, 0), 72 0x20, 0x33, TLV_DB_SCALE_ITEM(-4150, 200, 0),
74 0x34, 0x37, TLV_DB_SCALE_ITEM(-150, 100, 0), 73 0x34, 0x37, TLV_DB_SCALE_ITEM(-150, 100, 0),
75 0x38, 0x3f, TLV_DB_SCALE_ITEM(250, 50, 0), 74 0x38, 0x3f, TLV_DB_SCALE_ITEM(250, 50, 0)
76}; 75);
77 76
78static const struct snd_kcontrol_new max9850_controls[] = { 77static const struct snd_kcontrol_new max9850_controls[] = {
79SOC_SINGLE_TLV("Headphone Volume", MAX9850_VOLUME, 0, 0x3f, 1, max9850_tlv), 78SOC_SINGLE_TLV("Headphone Volume", MAX9850_VOLUME, 0, 0x3f, 1, max9850_tlv),
diff --git a/sound/soc/codecs/max9877.c b/sound/soc/codecs/max9877.c
index fb448dde018d..61cc18e35efb 100644
--- a/sound/soc/codecs/max9877.c
+++ b/sound/soc/codecs/max9877.c
@@ -28,19 +28,17 @@ static const struct reg_default max9877_regs[] = {
28 { 4, 0x49 }, 28 { 4, 0x49 },
29}; 29};
30 30
31static const unsigned int max9877_pgain_tlv[] = { 31static const DECLARE_TLV_DB_RANGE(max9877_pgain_tlv,
32 TLV_DB_RANGE_HEAD(2),
33 0, 1, TLV_DB_SCALE_ITEM(0, 900, 0), 32 0, 1, TLV_DB_SCALE_ITEM(0, 900, 0),
34 2, 2, TLV_DB_SCALE_ITEM(2000, 0, 0), 33 2, 2, TLV_DB_SCALE_ITEM(2000, 0, 0)
35}; 34);
36 35
37static const unsigned int max9877_output_tlv[] = { 36static const DECLARE_TLV_DB_RANGE(max9877_output_tlv,
38 TLV_DB_RANGE_HEAD(4),
39 0, 7, TLV_DB_SCALE_ITEM(-7900, 400, 1), 37 0, 7, TLV_DB_SCALE_ITEM(-7900, 400, 1),
40 8, 15, TLV_DB_SCALE_ITEM(-4700, 300, 0), 38 8, 15, TLV_DB_SCALE_ITEM(-4700, 300, 0),
41 16, 23, TLV_DB_SCALE_ITEM(-2300, 200, 0), 39 16, 23, TLV_DB_SCALE_ITEM(-2300, 200, 0),
42 24, 31, TLV_DB_SCALE_ITEM(-700, 100, 0), 40 24, 31, TLV_DB_SCALE_ITEM(-700, 100, 0)
43}; 41);
44 42
45static const char *max9877_out_mode[] = { 43static const char *max9877_out_mode[] = {
46 "INA -> SPK", 44 "INA -> SPK",
diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c
index d8771020299d..1be2bab7dee3 100644
--- a/sound/soc/codecs/rt5631.c
+++ b/sound/soc/codecs/rt5631.c
@@ -174,16 +174,15 @@ static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
174static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -95625, 375, 0); 174static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -95625, 375, 0);
175static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); 175static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
176/* {0, +20, +24, +30, +35, +40, +44, +50, +52}dB */ 176/* {0, +20, +24, +30, +35, +40, +44, +50, +52}dB */
177static unsigned int mic_bst_tlv[] = { 177static const DECLARE_TLV_DB_RANGE(mic_bst_tlv,
178 TLV_DB_RANGE_HEAD(7),
179 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 178 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
180 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), 179 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
181 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), 180 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
182 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0), 181 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
183 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0), 182 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
184 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0), 183 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
185 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0), 184 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0)
186}; 185);
187 186
188static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, 187static int rt5631_dmic_get(struct snd_kcontrol *kcontrol,
189 struct snd_ctl_elem_value *ucontrol) 188 struct snd_ctl_elem_value *ucontrol)
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index b4139d3da334..e1ceeb885f7d 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -347,16 +347,15 @@ static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
347static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); 347static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
348 348
349/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ 349/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
350static unsigned int bst_tlv[] = { 350static const DECLARE_TLV_DB_RANGE(bst_tlv,
351 TLV_DB_RANGE_HEAD(7),
352 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 351 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
353 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), 352 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
354 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), 353 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
355 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0), 354 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
356 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0), 355 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
357 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0), 356 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
358 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0), 357 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0)
359}; 358);
360 359
361/* Interface data select */ 360/* Interface data select */
362static const char * const rt5640_data_select[] = { 361static const char * const rt5640_data_select[] = {
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 1e70736cc970..4972bf3efa91 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -459,16 +459,15 @@ static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0);
459static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); 459static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
460 460
461/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ 461/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
462static unsigned int bst_tlv[] = { 462static const DECLARE_TLV_DB_RANGE(bst_tlv,
463 TLV_DB_RANGE_HEAD(7),
464 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 463 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
465 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), 464 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
466 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), 465 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
467 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0), 466 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
468 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0), 467 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
469 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0), 468 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
470 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0), 469 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0)
471}; 470);
472 471
473static const struct snd_kcontrol_new rt5645_snd_controls[] = { 472static const struct snd_kcontrol_new rt5645_snd_controls[] = {
474 /* Speaker Output Volume */ 473 /* Speaker Output Volume */
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c
index 8f7159ba6ca2..1d4031818966 100644
--- a/sound/soc/codecs/rt5651.c
+++ b/sound/soc/codecs/rt5651.c
@@ -292,16 +292,15 @@ static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
292static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); 292static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
293 293
294/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ 294/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
295static unsigned int bst_tlv[] = { 295static const DECLARE_TLV_DB_RANGE(bst_tlv,
296 TLV_DB_RANGE_HEAD(7),
297 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 296 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
298 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), 297 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
299 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), 298 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
300 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0), 299 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
301 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0), 300 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
302 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0), 301 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
303 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0), 302 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0)
304}; 303);
305 304
306/* Interface data select */ 305/* Interface data select */
307static const char * const rt5651_data_select[] = { 306static const char * const rt5651_data_select[] = {
diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c
index 177748af94fc..49a9e7049e2b 100644
--- a/sound/soc/codecs/rt5670.c
+++ b/sound/soc/codecs/rt5670.c
@@ -592,16 +592,15 @@ static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
592static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); 592static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
593 593
594/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ 594/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
595static unsigned int bst_tlv[] = { 595static const DECLARE_TLV_DB_RANGE(bst_tlv,
596 TLV_DB_RANGE_HEAD(7),
597 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 596 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
598 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), 597 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
599 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), 598 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
600 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0), 599 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
601 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0), 600 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
602 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0), 601 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
603 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0), 602 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0)
604}; 603);
605 604
606/* Interface data select */ 605/* Interface data select */
607static const char * const rt5670_data_select[] = { 606static const char * const rt5670_data_select[] = {
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index b7de51b09c35..b4cd7e3bf5f8 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -788,16 +788,15 @@ static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
788static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0); 788static const DECLARE_TLV_DB_SCALE(st_vol_tlv, -4650, 150, 0);
789 789
790/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ 790/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
791static unsigned int bst_tlv[] = { 791static const DECLARE_TLV_DB_RANGE(bst_tlv,
792 TLV_DB_RANGE_HEAD(7),
793 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 792 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
794 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), 793 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
795 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), 794 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
796 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0), 795 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
797 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0), 796 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
798 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0), 797 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
799 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0), 798 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0)
800}; 799);
801 800
802static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol, 801static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
803 struct snd_ctl_elem_value *ucontrol) 802 struct snd_ctl_elem_value *ucontrol)
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index f3e646757215..bfda25ef0dd4 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -406,11 +406,10 @@ static int dac_put_volsw(struct snd_kcontrol *kcontrol,
406static const DECLARE_TLV_DB_SCALE(capture_6db_attenuate, -600, 600, 0); 406static const DECLARE_TLV_DB_SCALE(capture_6db_attenuate, -600, 600, 0);
407 407
408/* tlv for mic gain, 0db 20db 30db 40db */ 408/* tlv for mic gain, 0db 20db 30db 40db */
409static const unsigned int mic_gain_tlv[] = { 409static const DECLARE_TLV_DB_RANGE(mic_gain_tlv,
410 TLV_DB_RANGE_HEAD(2),
411 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 410 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
412 1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0), 411 1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0)
413}; 412);
414 413
415/* tlv for hp volume, -51.5db to 12.0db, step .5db */ 414/* tlv for hp volume, -51.5db to 12.0db, step .5db */
416static const DECLARE_TLV_DB_SCALE(headphone_volume, -5150, 50, 0); 415static const DECLARE_TLV_DB_SCALE(headphone_volume, -5150, 50, 0);
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c
index 69a773aeb13d..4452fea0b118 100644
--- a/sound/soc/codecs/ssm2602.c
+++ b/sound/soc/codecs/ssm2602.c
@@ -75,11 +75,10 @@ static const struct soc_enum ssm2602_enum[] = {
75 ssm2602_deemph), 75 ssm2602_deemph),
76}; 76};
77 77
78static const unsigned int ssm260x_outmix_tlv[] = { 78static const DECLARE_TLV_DB_RANGE(ssm260x_outmix_tlv,
79 TLV_DB_RANGE_HEAD(2),
80 0, 47, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0), 79 0, 47, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
81 48, 127, TLV_DB_SCALE_ITEM(-7400, 100, 0), 80 48, 127, TLV_DB_SCALE_ITEM(-7400, 100, 0)
82}; 81);
83 82
84static const DECLARE_TLV_DB_SCALE(ssm260x_inpga_tlv, -3450, 150, 0); 83static const DECLARE_TLV_DB_SCALE(ssm260x_inpga_tlv, -3450, 150, 0);
85static const DECLARE_TLV_DB_SCALE(ssm260x_sidetone_tlv, -1500, 300, 0); 84static const DECLARE_TLV_DB_SCALE(ssm260x_sidetone_tlv, -1500, 300, 0);
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
index 2f6a65afe5d2..e3a0bca28bcf 100644
--- a/sound/soc/codecs/tas2552.c
+++ b/sound/soc/codecs/tas2552.c
@@ -493,8 +493,7 @@ static int tas2552_runtime_suspend(struct device *dev)
493 regcache_cache_only(tas2552->regmap, true); 493 regcache_cache_only(tas2552->regmap, true);
494 regcache_mark_dirty(tas2552->regmap); 494 regcache_mark_dirty(tas2552->regmap);
495 495
496 if (tas2552->enable_gpio) 496 gpiod_set_value(tas2552->enable_gpio, 0);
497 gpiod_set_value(tas2552->enable_gpio, 0);
498 497
499 return 0; 498 return 0;
500} 499}
@@ -503,8 +502,7 @@ static int tas2552_runtime_resume(struct device *dev)
503{ 502{
504 struct tas2552_data *tas2552 = dev_get_drvdata(dev); 503 struct tas2552_data *tas2552 = dev_get_drvdata(dev);
505 504
506 if (tas2552->enable_gpio) 505 gpiod_set_value(tas2552->enable_gpio, 1);
507 gpiod_set_value(tas2552->enable_gpio, 1);
508 506
509 tas2552_sw_shutdown(tas2552, 0); 507 tas2552_sw_shutdown(tas2552, 0);
510 508
@@ -585,8 +583,7 @@ static int tas2552_codec_probe(struct snd_soc_codec *codec)
585 return ret; 583 return ret;
586 } 584 }
587 585
588 if (tas2552->enable_gpio) 586 gpiod_set_value(tas2552->enable_gpio, 1);
589 gpiod_set_value(tas2552->enable_gpio, 1);
590 587
591 ret = pm_runtime_get_sync(codec->dev); 588 ret = pm_runtime_get_sync(codec->dev);
592 if (ret < 0) { 589 if (ret < 0) {
@@ -610,8 +607,7 @@ static int tas2552_codec_probe(struct snd_soc_codec *codec)
610 return 0; 607 return 0;
611 608
612probe_fail: 609probe_fail:
613 if (tas2552->enable_gpio) 610 gpiod_set_value(tas2552->enable_gpio, 0);
614 gpiod_set_value(tas2552->enable_gpio, 0);
615 611
616 regulator_bulk_disable(ARRAY_SIZE(tas2552->supplies), 612 regulator_bulk_disable(ARRAY_SIZE(tas2552->supplies),
617 tas2552->supplies); 613 tas2552->supplies);
@@ -624,8 +620,7 @@ static int tas2552_codec_remove(struct snd_soc_codec *codec)
624 620
625 pm_runtime_put(codec->dev); 621 pm_runtime_put(codec->dev);
626 622
627 if (tas2552->enable_gpio) 623 gpiod_set_value(tas2552->enable_gpio, 0);
628 gpiod_set_value(tas2552->enable_gpio, 0);
629 624
630 return 0; 625 return 0;
631}; 626};
diff --git a/sound/soc/codecs/tas2552.h b/sound/soc/codecs/tas2552.h
index 5746f8fd0afd..e34752b8a299 100644
--- a/sound/soc/codecs/tas2552.h
+++ b/sound/soc/codecs/tas2552.h
@@ -42,7 +42,7 @@
42#define TAS2552_BOOST_APT_CTRL 0x14 42#define TAS2552_BOOST_APT_CTRL 0x14
43#define TAS2552_VER_NUM 0x16 43#define TAS2552_VER_NUM 0x16
44#define TAS2552_VBAT_DATA 0x19 44#define TAS2552_VBAT_DATA 0x19
45#define TAS2552_MAX_REG 0x20 45#define TAS2552_MAX_REG TAS2552_VBAT_DATA
46 46
47/* CFG1 Register Masks */ 47/* CFG1 Register Masks */
48#define TAS2552_DEV_RESET (1 << 0) 48#define TAS2552_DEV_RESET (1 << 0)
diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c
index 0a49fc851577..d49d25d51957 100644
--- a/sound/soc/codecs/tas5086.c
+++ b/sound/soc/codecs/tas5086.c
@@ -266,10 +266,14 @@ static int tas5086_set_deemph(struct snd_soc_codec *codec)
266 struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); 266 struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec);
267 int i, val = 0; 267 int i, val = 0;
268 268
269 if (priv->deemph) 269 if (priv->deemph) {
270 for (i = 0; i < ARRAY_SIZE(tas5086_deemph); i++) 270 for (i = 0; i < ARRAY_SIZE(tas5086_deemph); i++) {
271 if (tas5086_deemph[i] == priv->rate) 271 if (tas5086_deemph[i] == priv->rate) {
272 val = i; 272 val = i;
273 break;
274 }
275 }
276 }
273 277
274 return regmap_update_bits(priv->regmap, TAS5086_SYS_CONTROL_1, 278 return regmap_update_bits(priv->regmap, TAS5086_SYS_CONTROL_1,
275 TAS5086_DEEMPH_MASK, val); 279 TAS5086_DEEMPH_MASK, val);
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index 265c4c38804d..11d85c5c787a 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -259,8 +259,7 @@ static int tpa6130a2_put_volsw(struct snd_kcontrol *kcontrol,
259 * TPA6130 volume. From -59.5 to 4 dB with increasing step size when going 259 * TPA6130 volume. From -59.5 to 4 dB with increasing step size when going
260 * down in gain. 260 * down in gain.
261 */ 261 */
262static const unsigned int tpa6130_tlv[] = { 262static const DECLARE_TLV_DB_RANGE(tpa6130_tlv,
263 TLV_DB_RANGE_HEAD(10),
264 0, 1, TLV_DB_SCALE_ITEM(-5950, 600, 0), 263 0, 1, TLV_DB_SCALE_ITEM(-5950, 600, 0),
265 2, 3, TLV_DB_SCALE_ITEM(-5000, 250, 0), 264 2, 3, TLV_DB_SCALE_ITEM(-5000, 250, 0),
266 4, 5, TLV_DB_SCALE_ITEM(-4550, 160, 0), 265 4, 5, TLV_DB_SCALE_ITEM(-4550, 160, 0),
@@ -270,8 +269,8 @@ static const unsigned int tpa6130_tlv[] = {
270 12, 13, TLV_DB_SCALE_ITEM(-3040, 180, 0), 269 12, 13, TLV_DB_SCALE_ITEM(-3040, 180, 0),
271 14, 20, TLV_DB_SCALE_ITEM(-2710, 110, 0), 270 14, 20, TLV_DB_SCALE_ITEM(-2710, 110, 0),
272 21, 37, TLV_DB_SCALE_ITEM(-1960, 74, 0), 271 21, 37, TLV_DB_SCALE_ITEM(-1960, 74, 0),
273 38, 63, TLV_DB_SCALE_ITEM(-720, 45, 0), 272 38, 63, TLV_DB_SCALE_ITEM(-720, 45, 0)
274}; 273);
275 274
276static const struct snd_kcontrol_new tpa6130a2_controls[] = { 275static const struct snd_kcontrol_new tpa6130a2_controls[] = {
277 SOC_SINGLE_EXT_TLV("TPA6130A2 Headphone Playback Volume", 276 SOC_SINGLE_EXT_TLV("TPA6130A2 Headphone Playback Volume",
@@ -280,12 +279,11 @@ static const struct snd_kcontrol_new tpa6130a2_controls[] = {
280 tpa6130_tlv), 279 tpa6130_tlv),
281}; 280};
282 281
283static const unsigned int tpa6140_tlv[] = { 282static const DECLARE_TLV_DB_RANGE(tpa6140_tlv,
284 TLV_DB_RANGE_HEAD(3),
285 0, 8, TLV_DB_SCALE_ITEM(-5900, 400, 0), 283 0, 8, TLV_DB_SCALE_ITEM(-5900, 400, 0),
286 9, 16, TLV_DB_SCALE_ITEM(-2500, 200, 0), 284 9, 16, TLV_DB_SCALE_ITEM(-2500, 200, 0),
287 17, 31, TLV_DB_SCALE_ITEM(-1000, 100, 0), 285 17, 31, TLV_DB_SCALE_ITEM(-1000, 100, 0)
288}; 286);
289 287
290static const struct snd_kcontrol_new tpa6140a2_controls[] = { 288static const struct snd_kcontrol_new tpa6140a2_controls[] = {
291 SOC_SINGLE_EXT_TLV("TPA6140A2 Headphone Playback Volume", 289 SOC_SINGLE_EXT_TLV("TPA6140A2 Headphone Playback Volume",
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 90f5f04eca2d..2713e1845cbc 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -524,12 +524,11 @@ static const struct snd_kcontrol_new twl4030_dapm_abypassv_control =
524 SOC_DAPM_SINGLE("Switch", TWL4030_REG_VDL_APGA_CTL, 2, 1, 0); 524 SOC_DAPM_SINGLE("Switch", TWL4030_REG_VDL_APGA_CTL, 2, 1, 0);
525 525
526/* Digital bypass gain, mute instead of -30dB */ 526/* Digital bypass gain, mute instead of -30dB */
527static const unsigned int twl4030_dapm_dbypass_tlv[] = { 527static const DECLARE_TLV_DB_RANGE(twl4030_dapm_dbypass_tlv,
528 TLV_DB_RANGE_HEAD(3),
529 0, 1, TLV_DB_SCALE_ITEM(-3000, 600, 1), 528 0, 1, TLV_DB_SCALE_ITEM(-3000, 600, 1),
530 2, 3, TLV_DB_SCALE_ITEM(-2400, 0, 0), 529 2, 3, TLV_DB_SCALE_ITEM(-2400, 0, 0),
531 4, 7, TLV_DB_SCALE_ITEM(-1800, 600, 0), 530 4, 7, TLV_DB_SCALE_ITEM(-1800, 600, 0)
532}; 531);
533 532
534/* Digital bypass left (TX1L -> RX2L) */ 533/* Digital bypass left (TX1L -> RX2L) */
535static const struct snd_kcontrol_new twl4030_dapm_dbypassl_control = 534static const struct snd_kcontrol_new twl4030_dapm_dbypassl_control =
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index 5cafb16ccf1a..35f0469ebb16 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -269,12 +269,11 @@ static DECLARE_TLV_DB_SCALE(amix_tlv, -4950, 150, 1);
269 * from -66 dB in 0.5 dB steps (2 dB steps, really) and 269 * from -66 dB in 0.5 dB steps (2 dB steps, really) and
270 * from -52 dB in 0.25 dB steps 270 * from -52 dB in 0.25 dB steps
271 */ 271 */
272static const unsigned int mvol_tlv[] = { 272static const DECLARE_TLV_DB_RANGE(mvol_tlv,
273 TLV_DB_RANGE_HEAD(3),
274 0, 15, TLV_DB_SCALE_ITEM(-8200, 100, 1), 273 0, 15, TLV_DB_SCALE_ITEM(-8200, 100, 1),
275 16, 43, TLV_DB_SCALE_ITEM(-6600, 50, 0), 274 16, 43, TLV_DB_SCALE_ITEM(-6600, 50, 0),
276 44, 252, TLV_DB_SCALE_ITEM(-5200, 25, 0), 275 44, 252, TLV_DB_SCALE_ITEM(-5200, 25, 0)
277}; 276);
278 277
279/* 278/*
280 * from -72 dB in 1.5 dB steps (6 dB steps really), 279 * from -72 dB in 1.5 dB steps (6 dB steps really),
@@ -282,13 +281,12 @@ static const unsigned int mvol_tlv[] = {
282 * from -60 dB in 0.5 dB steps (2 dB steps really) and 281 * from -60 dB in 0.5 dB steps (2 dB steps really) and
283 * from -46 dB in 0.25 dB steps 282 * from -46 dB in 0.25 dB steps
284 */ 283 */
285static const unsigned int vc_tlv[] = { 284static const DECLARE_TLV_DB_RANGE(vc_tlv,
286 TLV_DB_RANGE_HEAD(4),
287 0, 7, TLV_DB_SCALE_ITEM(-7800, 150, 1), 285 0, 7, TLV_DB_SCALE_ITEM(-7800, 150, 1),
288 8, 15, TLV_DB_SCALE_ITEM(-6600, 75, 0), 286 8, 15, TLV_DB_SCALE_ITEM(-6600, 75, 0),
289 16, 43, TLV_DB_SCALE_ITEM(-6000, 50, 0), 287 16, 43, TLV_DB_SCALE_ITEM(-6000, 50, 0),
290 44, 228, TLV_DB_SCALE_ITEM(-4600, 25, 0), 288 44, 228, TLV_DB_SCALE_ITEM(-4600, 25, 0)
291}; 289);
292 290
293/* from 0 to 6 dB in 2 dB steps if SPF mode != flat */ 291/* from 0 to 6 dB in 2 dB steps if SPF mode != flat */
294static DECLARE_TLV_DB_SCALE(tr_tlv, 0, 200, 0); 292static DECLARE_TLV_DB_SCALE(tr_tlv, 0, 200, 0);
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c
index 41c62c1e62db..ffbf3df8ae97 100644
--- a/sound/soc/codecs/wm8350.c
+++ b/sound/soc/codecs/wm8350.c
@@ -394,11 +394,10 @@ static DECLARE_TLV_DB_SCALE(dac_pcm_tlv, -7163, 36, 1);
394static DECLARE_TLV_DB_SCALE(adc_pcm_tlv, -12700, 50, 1); 394static DECLARE_TLV_DB_SCALE(adc_pcm_tlv, -12700, 50, 1);
395static DECLARE_TLV_DB_SCALE(out_mix_tlv, -1500, 300, 1); 395static DECLARE_TLV_DB_SCALE(out_mix_tlv, -1500, 300, 1);
396 396
397static const unsigned int capture_sd_tlv[] = { 397static const DECLARE_TLV_DB_RANGE(capture_sd_tlv,
398 TLV_DB_RANGE_HEAD(2),
399 0, 12, TLV_DB_SCALE_ITEM(-3600, 300, 1), 398 0, 12, TLV_DB_SCALE_ITEM(-3600, 300, 1),
400 13, 15, TLV_DB_SCALE_ITEM(0, 0, 0), 399 13, 15, TLV_DB_SCALE_ITEM(0, 0, 0)
401}; 400);
402 401
403static const struct snd_kcontrol_new wm8350_snd_controls[] = { 402static const struct snd_kcontrol_new wm8350_snd_controls[] = {
404 SOC_ENUM("Playback Deemphasis", wm8350_enum[0]), 403 SOC_ENUM("Playback Deemphasis", wm8350_enum[0]),
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c
index d7555085e7f4..b1d346aa4696 100644
--- a/sound/soc/codecs/wm8400.c
+++ b/sound/soc/codecs/wm8400.c
@@ -370,10 +370,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w,
370} 370}
371 371
372/* INMIX dB values */ 372/* INMIX dB values */
373static const unsigned int in_mix_tlv[] = { 373static const DECLARE_TLV_DB_SCALE(in_mix_tlv, -1200, 600, 0);
374 TLV_DB_RANGE_HEAD(1),
375 0,7, TLV_DB_SCALE_ITEM(-1200, 600, 0),
376};
377 374
378/* Left In PGA Connections */ 375/* Left In PGA Connections */
379static const struct snd_kcontrol_new wm8400_dapm_lin12_pga_controls[] = { 376static const struct snd_kcontrol_new wm8400_dapm_lin12_pga_controls[] = {
diff --git a/sound/soc/codecs/wm8737.c b/sound/soc/codecs/wm8737.c
index b54a7b78f562..e4a03d98aed4 100644
--- a/sound/soc/codecs/wm8737.c
+++ b/sound/soc/codecs/wm8737.c
@@ -79,13 +79,12 @@ static int wm8737_reset(struct snd_soc_codec *codec)
79 return snd_soc_write(codec, WM8737_RESET, 0); 79 return snd_soc_write(codec, WM8737_RESET, 0);
80} 80}
81 81
82static const unsigned int micboost_tlv[] = { 82static const DECLARE_TLV_DB_RANGE(micboost_tlv,
83 TLV_DB_RANGE_HEAD(4),
84 0, 0, TLV_DB_SCALE_ITEM(1300, 0, 0), 83 0, 0, TLV_DB_SCALE_ITEM(1300, 0, 0),
85 1, 1, TLV_DB_SCALE_ITEM(1800, 0, 0), 84 1, 1, TLV_DB_SCALE_ITEM(1800, 0, 0),
86 2, 2, TLV_DB_SCALE_ITEM(2800, 0, 0), 85 2, 2, TLV_DB_SCALE_ITEM(2800, 0, 0),
87 3, 3, TLV_DB_SCALE_ITEM(3300, 0, 0), 86 3, 3, TLV_DB_SCALE_ITEM(3300, 0, 0)
88}; 87);
89static const DECLARE_TLV_DB_SCALE(pga_tlv, -9750, 50, 1); 88static const DECLARE_TLV_DB_SCALE(pga_tlv, -9750, 50, 1);
90static const DECLARE_TLV_DB_SCALE(adc_tlv, -600, 600, 0); 89static const DECLARE_TLV_DB_SCALE(adc_tlv, -600, 600, 0);
91static const DECLARE_TLV_DB_SCALE(ng_tlv, -7800, 600, 0); 90static const DECLARE_TLV_DB_SCALE(ng_tlv, -7800, 600, 0);
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index b5e50ffbf99f..0e946f3da1c0 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -276,12 +276,11 @@ static const DECLARE_TLV_DB_SCALE(rec_mix_tlv, -1500, 300, 0);
276static const DECLARE_TLV_DB_SCALE(mic_preamp_tlv, 1200, 600, 0); 276static const DECLARE_TLV_DB_SCALE(mic_preamp_tlv, 1200, 600, 0);
277static const DECLARE_TLV_DB_SCALE(adc_tlv, -9750, 50, 1); 277static const DECLARE_TLV_DB_SCALE(adc_tlv, -9750, 50, 1);
278static const DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 1); 278static const DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 1);
279static const unsigned int out_tlv[] = { 279static const DECLARE_TLV_DB_RANGE(out_tlv,
280 TLV_DB_RANGE_HEAD(2),
281 /* 0000000 - 0101111 = "Analogue mute" */ 280 /* 0000000 - 0101111 = "Analogue mute" */
282 0, 48, TLV_DB_SCALE_ITEM(-25500, 0, 0), 281 0, 48, TLV_DB_SCALE_ITEM(-25500, 0, 0),
283 48, 127, TLV_DB_SCALE_ITEM(-7300, 100, 0), 282 48, 127, TLV_DB_SCALE_ITEM(-7300, 100, 0)
284}; 283);
285static const DECLARE_TLV_DB_SCALE(mix_tlv, -1500, 300, 0); 284static const DECLARE_TLV_DB_SCALE(mix_tlv, -1500, 300, 0);
286static const DECLARE_TLV_DB_SCALE(voice_mix_tlv, -1200, 300, 0); 285static const DECLARE_TLV_DB_SCALE(voice_mix_tlv, -1200, 300, 0);
287static const DECLARE_TLV_DB_SCALE(pga_tlv, -1725, 75, 0); 286static const DECLARE_TLV_DB_SCALE(pga_tlv, -1725, 75, 0);
diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c
index 20a010344fd5..e30446a04740 100644
--- a/sound/soc/codecs/wm8961.c
+++ b/sound/soc/codecs/wm8961.c
@@ -331,13 +331,12 @@ static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
331static const DECLARE_TLV_DB_SCALE(hp_sec_tlv, -700, 100, 0); 331static const DECLARE_TLV_DB_SCALE(hp_sec_tlv, -700, 100, 0);
332static const DECLARE_TLV_DB_SCALE(adc_tlv, -7200, 75, 1); 332static const DECLARE_TLV_DB_SCALE(adc_tlv, -7200, 75, 1);
333static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -3600, 300, 0); 333static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -3600, 300, 0);
334static unsigned int boost_tlv[] = { 334static const DECLARE_TLV_DB_RANGE(boost_tlv,
335 TLV_DB_RANGE_HEAD(4),
336 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 335 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
337 1, 1, TLV_DB_SCALE_ITEM(13, 0, 0), 336 1, 1, TLV_DB_SCALE_ITEM(13, 0, 0),
338 2, 2, TLV_DB_SCALE_ITEM(20, 0, 0), 337 2, 2, TLV_DB_SCALE_ITEM(20, 0, 0),
339 3, 3, TLV_DB_SCALE_ITEM(29, 0, 0), 338 3, 3, TLV_DB_SCALE_ITEM(29, 0, 0)
340}; 339);
341static const DECLARE_TLV_DB_SCALE(pga_tlv, -2325, 75, 0); 340static const DECLARE_TLV_DB_SCALE(pga_tlv, -2325, 75, 0);
342 341
343static const struct snd_kcontrol_new wm8961_snd_controls[] = { 342static const struct snd_kcontrol_new wm8961_snd_controls[] = {
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 5c01707d4999..b4eb975da981 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -1456,14 +1456,13 @@ static int wm8962_reset(struct wm8962_priv *wm8962)
1456 1456
1457static const DECLARE_TLV_DB_SCALE(inpga_tlv, -2325, 75, 0); 1457static const DECLARE_TLV_DB_SCALE(inpga_tlv, -2325, 75, 0);
1458static const DECLARE_TLV_DB_SCALE(mixin_tlv, -1500, 300, 0); 1458static const DECLARE_TLV_DB_SCALE(mixin_tlv, -1500, 300, 0);
1459static const unsigned int mixinpga_tlv[] = { 1459static const DECLARE_TLV_DB_RANGE(mixinpga_tlv,
1460 TLV_DB_RANGE_HEAD(5),
1461 0, 1, TLV_DB_SCALE_ITEM(0, 600, 0), 1460 0, 1, TLV_DB_SCALE_ITEM(0, 600, 0),
1462 2, 2, TLV_DB_SCALE_ITEM(1300, 1300, 0), 1461 2, 2, TLV_DB_SCALE_ITEM(1300, 1300, 0),
1463 3, 4, TLV_DB_SCALE_ITEM(1800, 200, 0), 1462 3, 4, TLV_DB_SCALE_ITEM(1800, 200, 0),
1464 5, 5, TLV_DB_SCALE_ITEM(2400, 0, 0), 1463 5, 5, TLV_DB_SCALE_ITEM(2400, 0, 0),
1465 6, 7, TLV_DB_SCALE_ITEM(2700, 300, 0), 1464 6, 7, TLV_DB_SCALE_ITEM(2700, 300, 0)
1466}; 1465);
1467static const DECLARE_TLV_DB_SCALE(beep_tlv, -9600, 600, 1); 1466static const DECLARE_TLV_DB_SCALE(beep_tlv, -9600, 600, 1);
1468static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1); 1467static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1);
1469static const DECLARE_TLV_DB_SCALE(st_tlv, -3600, 300, 0); 1468static const DECLARE_TLV_DB_SCALE(st_tlv, -3600, 300, 0);
@@ -1471,11 +1470,10 @@ static const DECLARE_TLV_DB_SCALE(inmix_tlv, -600, 600, 0);
1471static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0); 1470static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0);
1472static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1); 1471static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1);
1473static const DECLARE_TLV_DB_SCALE(hp_tlv, -700, 100, 0); 1472static const DECLARE_TLV_DB_SCALE(hp_tlv, -700, 100, 0);
1474static const unsigned int classd_tlv[] = { 1473static const DECLARE_TLV_DB_RANGE(classd_tlv,
1475 TLV_DB_RANGE_HEAD(2),
1476 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0), 1474 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0),
1477 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0), 1475 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0)
1478}; 1476);
1479static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); 1477static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
1480 1478
1481static int wm8962_dsp2_write_config(struct snd_soc_codec *codec) 1479static int wm8962_dsp2_write_config(struct snd_soc_codec *codec)
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c
index 83d72d8bc51b..23ecd30d8bca 100644
--- a/sound/soc/codecs/wm8990.c
+++ b/sound/soc/codecs/wm8990.c
@@ -418,10 +418,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
418} 418}
419 419
420/* INMIX dB values */ 420/* INMIX dB values */
421static const unsigned int in_mix_tlv[] = { 421static const DECLARE_TLV_DB_SCALE(in_mix_tlv, -1200, 600, 0);
422 TLV_DB_RANGE_HEAD(1),
423 0, 7, TLV_DB_SCALE_ITEM(-1200, 600, 0),
424};
425 422
426/* Left In PGA Connections */ 423/* Left In PGA Connections */
427static const struct snd_kcontrol_new wm8990_dapm_lin12_pga_controls[] = { 424static const struct snd_kcontrol_new wm8990_dapm_lin12_pga_controls[] = {
diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c
index 709d16e338d9..c9ee0ac6a654 100644
--- a/sound/soc/codecs/wm8991.c
+++ b/sound/soc/codecs/wm8991.c
@@ -111,45 +111,14 @@ static bool wm8991_volatile(struct device *dev, unsigned int reg)
111 } 111 }
112} 112}
113 113
114static const unsigned int rec_mix_tlv[] = { 114static const DECLARE_TLV_DB_LINEAR(rec_mix_tlv, -1500, 600);
115 TLV_DB_RANGE_HEAD(1), 115static const DECLARE_TLV_DB_LINEAR(in_pga_tlv, -1650, 3000);
116 0, 7, TLV_DB_LINEAR_ITEM(-1500, 600), 116static const DECLARE_TLV_DB_LINEAR(out_mix_tlv, 0, -2100);
117}; 117static const DECLARE_TLV_DB_LINEAR(out_pga_tlv, -7300, 600);
118 118static const DECLARE_TLV_DB_LINEAR(out_omix_tlv, -600, 0);
119static const unsigned int in_pga_tlv[] = { 119static const DECLARE_TLV_DB_LINEAR(out_dac_tlv, -7163, 0);
120 TLV_DB_RANGE_HEAD(1), 120static const DECLARE_TLV_DB_LINEAR(in_adc_tlv, -7163, 1763);
121 0, 0x1F, TLV_DB_LINEAR_ITEM(-1650, 3000), 121static const DECLARE_TLV_DB_LINEAR(out_sidetone_tlv, -3600, 0);
122};
123
124static const unsigned int out_mix_tlv[] = {
125 TLV_DB_RANGE_HEAD(1),
126 0, 7, TLV_DB_LINEAR_ITEM(0, -2100),
127};
128
129static const unsigned int out_pga_tlv[] = {
130 TLV_DB_RANGE_HEAD(1),
131 0, 127, TLV_DB_LINEAR_ITEM(-7300, 600),
132};
133
134static const unsigned int out_omix_tlv[] = {
135 TLV_DB_RANGE_HEAD(1),
136 0, 7, TLV_DB_LINEAR_ITEM(-600, 0),
137};
138
139static const unsigned int out_dac_tlv[] = {
140 TLV_DB_RANGE_HEAD(1),
141 0, 255, TLV_DB_LINEAR_ITEM(-7163, 0),
142};
143
144static const unsigned int in_adc_tlv[] = {
145 TLV_DB_RANGE_HEAD(1),
146 0, 255, TLV_DB_LINEAR_ITEM(-7163, 1763),
147};
148
149static const unsigned int out_sidetone_tlv[] = {
150 TLV_DB_RANGE_HEAD(1),
151 0, 31, TLV_DB_LINEAR_ITEM(-3600, 0),
152};
153 122
154static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, 123static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol,
155 struct snd_ctl_elem_value *ucontrol) 124 struct snd_ctl_elem_value *ucontrol)
@@ -429,10 +398,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
429} 398}
430 399
431/* INMIX dB values */ 400/* INMIX dB values */
432static const unsigned int in_mix_tlv[] = { 401static const DECLARE_TLV_DB_LINEAR(in_mix_tlv, -1200, 600);
433 TLV_DB_RANGE_HEAD(1),
434 0, 7, TLV_DB_LINEAR_ITEM(-1200, 600),
435};
436 402
437/* Left In PGA Connections */ 403/* Left In PGA Connections */
438static const struct snd_kcontrol_new wm8991_dapm_lin12_pga_controls[] = { 404static const struct snd_kcontrol_new wm8991_dapm_lin12_pga_controls[] = {
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c
index ac9efd63dbef..8668c4c391b0 100644
--- a/sound/soc/codecs/wm8993.c
+++ b/sound/soc/codecs/wm8993.c
@@ -628,11 +628,10 @@ static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -3600, 300, 0);
628static const DECLARE_TLV_DB_SCALE(drc_comp_threash, -4500, 75, 0); 628static const DECLARE_TLV_DB_SCALE(drc_comp_threash, -4500, 75, 0);
629static const DECLARE_TLV_DB_SCALE(drc_comp_amp, -2250, 75, 0); 629static const DECLARE_TLV_DB_SCALE(drc_comp_amp, -2250, 75, 0);
630static const DECLARE_TLV_DB_SCALE(drc_min_tlv, -1800, 600, 0); 630static const DECLARE_TLV_DB_SCALE(drc_min_tlv, -1800, 600, 0);
631static const unsigned int drc_max_tlv[] = { 631static const DECLARE_TLV_DB_RANGE(drc_max_tlv,
632 TLV_DB_RANGE_HEAD(2),
633 0, 2, TLV_DB_SCALE_ITEM(1200, 600, 0), 632 0, 2, TLV_DB_SCALE_ITEM(1200, 600, 0),
634 3, 3, TLV_DB_SCALE_ITEM(3600, 0, 0), 633 3, 3, TLV_DB_SCALE_ITEM(3600, 0, 0)
635}; 634);
636static const DECLARE_TLV_DB_SCALE(drc_qr_tlv, 1200, 600, 0); 635static const DECLARE_TLV_DB_SCALE(drc_qr_tlv, 1200, 600, 0);
637static const DECLARE_TLV_DB_SCALE(drc_startup_tlv, -1800, 300, 0); 636static const DECLARE_TLV_DB_SCALE(drc_startup_tlv, -1800, 300, 0);
638static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); 637static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c
index 45223a20331f..ccb3b15139ad 100644
--- a/sound/soc/codecs/wm9081.c
+++ b/sound/soc/codecs/wm9081.c
@@ -243,13 +243,12 @@ static int wm9081_reset(struct regmap *map)
243static const DECLARE_TLV_DB_SCALE(drc_in_tlv, -4500, 75, 0); 243static const DECLARE_TLV_DB_SCALE(drc_in_tlv, -4500, 75, 0);
244static const DECLARE_TLV_DB_SCALE(drc_out_tlv, -2250, 75, 0); 244static const DECLARE_TLV_DB_SCALE(drc_out_tlv, -2250, 75, 0);
245static const DECLARE_TLV_DB_SCALE(drc_min_tlv, -1800, 600, 0); 245static const DECLARE_TLV_DB_SCALE(drc_min_tlv, -1800, 600, 0);
246static unsigned int drc_max_tlv[] = { 246static const DECLARE_TLV_DB_RANGE(drc_max_tlv,
247 TLV_DB_RANGE_HEAD(4),
248 0, 0, TLV_DB_SCALE_ITEM(1200, 0, 0), 247 0, 0, TLV_DB_SCALE_ITEM(1200, 0, 0),
249 1, 1, TLV_DB_SCALE_ITEM(1800, 0, 0), 248 1, 1, TLV_DB_SCALE_ITEM(1800, 0, 0),
250 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), 249 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
251 3, 3, TLV_DB_SCALE_ITEM(3600, 0, 0), 250 3, 3, TLV_DB_SCALE_ITEM(3600, 0, 0)
252}; 251);
253static const DECLARE_TLV_DB_SCALE(drc_qr_tlv, 1200, 600, 0); 252static const DECLARE_TLV_DB_SCALE(drc_qr_tlv, 1200, 600, 0);
254static const DECLARE_TLV_DB_SCALE(drc_startup_tlv, -300, 50, 0); 253static const DECLARE_TLV_DB_SCALE(drc_startup_tlv, -300, 50, 0);
255 254
diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c
index 12baf725d4a5..5d737290f547 100644
--- a/sound/soc/codecs/wm9090.c
+++ b/sound/soc/codecs/wm9090.c
@@ -162,23 +162,20 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec)
162 dev_err(codec->dev, "Timed out waiting for DC Servo\n"); 162 dev_err(codec->dev, "Timed out waiting for DC Servo\n");
163} 163}
164 164
165static const unsigned int in_tlv[] = { 165static const DECLARE_TLV_DB_RANGE(in_tlv,
166 TLV_DB_RANGE_HEAD(3),
167 0, 0, TLV_DB_SCALE_ITEM(-600, 0, 0), 166 0, 0, TLV_DB_SCALE_ITEM(-600, 0, 0),
168 1, 3, TLV_DB_SCALE_ITEM(-350, 350, 0), 167 1, 3, TLV_DB_SCALE_ITEM(-350, 350, 0),
169 4, 6, TLV_DB_SCALE_ITEM(600, 600, 0), 168 4, 6, TLV_DB_SCALE_ITEM(600, 600, 0)
170}; 169);
171static const unsigned int mix_tlv[] = { 170static const DECLARE_TLV_DB_RANGE(mix_tlv,
172 TLV_DB_RANGE_HEAD(2),
173 0, 2, TLV_DB_SCALE_ITEM(-1200, 300, 0), 171 0, 2, TLV_DB_SCALE_ITEM(-1200, 300, 0),
174 3, 3, TLV_DB_SCALE_ITEM(0, 0, 0), 172 3, 3, TLV_DB_SCALE_ITEM(0, 0, 0)
175}; 173);
176static const DECLARE_TLV_DB_SCALE(out_tlv, -5700, 100, 0); 174static const DECLARE_TLV_DB_SCALE(out_tlv, -5700, 100, 0);
177static const unsigned int spkboost_tlv[] = { 175static const DECLARE_TLV_DB_RANGE(spkboost_tlv,
178 TLV_DB_RANGE_HEAD(2),
179 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0), 176 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0),
180 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0), 177 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0)
181}; 178);
182 179
183static const struct snd_kcontrol_new wm9090_controls[] = { 180static const struct snd_kcontrol_new wm9090_controls[] = {
184SOC_SINGLE_TLV("IN1A Volume", WM9090_IN1_LINE_INPUT_A_VOLUME, 0, 6, 0, 181SOC_SINGLE_TLV("IN1A Volume", WM9090_IN1_LINE_INPUT_A_VOLUME, 0, 6, 0,
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c
index 955e6511af56..4083a5130cbd 100644
--- a/sound/soc/codecs/wm9713.c
+++ b/sound/soc/codecs/wm9713.c
@@ -119,11 +119,10 @@ SOC_ENUM_SINGLE_VIRT(2, wm9713_micb_select), /* mic selection 19 */
119static const DECLARE_TLV_DB_SCALE(out_tlv, -4650, 150, 0); 119static const DECLARE_TLV_DB_SCALE(out_tlv, -4650, 150, 0);
120static const DECLARE_TLV_DB_SCALE(main_tlv, -3450, 150, 0); 120static const DECLARE_TLV_DB_SCALE(main_tlv, -3450, 150, 0);
121static const DECLARE_TLV_DB_SCALE(misc_tlv, -1500, 300, 0); 121static const DECLARE_TLV_DB_SCALE(misc_tlv, -1500, 300, 0);
122static unsigned int mic_tlv[] = { 122static const DECLARE_TLV_DB_RANGE(mic_tlv,
123 TLV_DB_RANGE_HEAD(2),
124 0, 2, TLV_DB_SCALE_ITEM(1200, 600, 0), 123 0, 2, TLV_DB_SCALE_ITEM(1200, 600, 0),
125 3, 3, TLV_DB_SCALE_ITEM(3000, 0, 0), 124 3, 3, TLV_DB_SCALE_ITEM(3000, 0, 0)
126}; 125);
127 126
128static const struct snd_kcontrol_new wm9713_snd_ac97_controls[] = { 127static const struct snd_kcontrol_new wm9713_snd_ac97_controls[] = {
129SOC_DOUBLE_TLV("Speaker Playback Volume", AC97_MASTER, 8, 0, 31, 1, out_tlv), 128SOC_DOUBLE_TLV("Speaker Playback Volume", AC97_MASTER, 8, 0, 31, 1, out_tlv),
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c
index fd86bd105460..624b3b9cb079 100644
--- a/sound/soc/codecs/wm_hubs.c
+++ b/sound/soc/codecs/wm_hubs.c
@@ -38,11 +38,10 @@ static const DECLARE_TLV_DB_SCALE(earpiece_tlv, -600, 600, 0);
38static const DECLARE_TLV_DB_SCALE(outmix_tlv, -2100, 300, 0); 38static const DECLARE_TLV_DB_SCALE(outmix_tlv, -2100, 300, 0);
39static const DECLARE_TLV_DB_SCALE(spkmixout_tlv, -1800, 600, 1); 39static const DECLARE_TLV_DB_SCALE(spkmixout_tlv, -1800, 600, 1);
40static const DECLARE_TLV_DB_SCALE(outpga_tlv, -5700, 100, 0); 40static const DECLARE_TLV_DB_SCALE(outpga_tlv, -5700, 100, 0);
41static const unsigned int spkboost_tlv[] = { 41static const DECLARE_TLV_DB_RANGE(spkboost_tlv,
42 TLV_DB_RANGE_HEAD(2),
43 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0), 42 0, 6, TLV_DB_SCALE_ITEM(0, 150, 0),
44 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0), 43 7, 7, TLV_DB_SCALE_ITEM(1200, 0, 0)
45}; 44);
46static const DECLARE_TLV_DB_SCALE(line_tlv, -600, 600, 0); 45static const DECLARE_TLV_DB_SCALE(line_tlv, -600, 600, 0);
47 46
48static const char *speaker_ref_text[] = { 47static const char *speaker_ref_text[] = {
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index f4e92d35316e..69d01cd925ce 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -45,12 +45,12 @@
45#define SOC_TPLG_PASS_VENDOR 1 45#define SOC_TPLG_PASS_VENDOR 1
46#define SOC_TPLG_PASS_MIXER 2 46#define SOC_TPLG_PASS_MIXER 2
47#define SOC_TPLG_PASS_WIDGET 3 47#define SOC_TPLG_PASS_WIDGET 3
48#define SOC_TPLG_PASS_GRAPH 4 48#define SOC_TPLG_PASS_PCM_DAI 4
49#define SOC_TPLG_PASS_PINS 5 49#define SOC_TPLG_PASS_GRAPH 5
50#define SOC_TPLG_PASS_PCM_DAI 6 50#define SOC_TPLG_PASS_PINS 6
51 51
52#define SOC_TPLG_PASS_START SOC_TPLG_PASS_MANIFEST 52#define SOC_TPLG_PASS_START SOC_TPLG_PASS_MANIFEST
53#define SOC_TPLG_PASS_END SOC_TPLG_PASS_PCM_DAI 53#define SOC_TPLG_PASS_END SOC_TPLG_PASS_PINS
54 54
55struct soc_tplg { 55struct soc_tplg {
56 const struct firmware *fw; 56 const struct firmware *fw;
@@ -66,10 +66,14 @@ struct soc_tplg {
66 u32 index; /* current block index */ 66 u32 index; /* current block index */
67 u32 req_index; /* required index, only loaded/free matching blocks */ 67 u32 req_index; /* required index, only loaded/free matching blocks */
68 68
69 /* kcontrol operations */ 69 /* vendor specific kcontrol operations */
70 const struct snd_soc_tplg_kcontrol_ops *io_ops; 70 const struct snd_soc_tplg_kcontrol_ops *io_ops;
71 int io_ops_count; 71 int io_ops_count;
72 72
73 /* vendor specific bytes ext handlers, for TLV bytes controls */
74 const struct snd_soc_tplg_bytes_ext_ops *bytes_ext_ops;
75 int bytes_ext_ops_count;
76
73 /* optional fw loading callbacks to component drivers */ 77 /* optional fw loading callbacks to component drivers */
74 struct snd_soc_tplg_ops *ops; 78 struct snd_soc_tplg_ops *ops;
75}; 79};
@@ -508,38 +512,74 @@ static void remove_pcm_dai(struct snd_soc_component *comp,
508/* bind a kcontrol to it's IO handlers */ 512/* bind a kcontrol to it's IO handlers */
509static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr, 513static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr,
510 struct snd_kcontrol_new *k, 514 struct snd_kcontrol_new *k,
511 const struct snd_soc_tplg_kcontrol_ops *ops, int num_ops, 515 const struct soc_tplg *tplg)
512 const struct snd_soc_tplg_kcontrol_ops *bops, int num_bops)
513{ 516{
514 int i; 517 const struct snd_soc_tplg_kcontrol_ops *ops;
518 const struct snd_soc_tplg_bytes_ext_ops *ext_ops;
519 int num_ops, i;
520
521 if (hdr->ops.info == SND_SOC_TPLG_CTL_BYTES
522 && k->iface & SNDRV_CTL_ELEM_IFACE_MIXER
523 && k->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE
524 && k->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
525 struct soc_bytes_ext *sbe;
526 struct snd_soc_tplg_bytes_control *be;
527
528 sbe = (struct soc_bytes_ext *)k->private_value;
529 be = container_of(hdr, struct snd_soc_tplg_bytes_control, hdr);
530
531 /* TLV bytes controls need standard kcontrol info handler,
532 * TLV callback and extended put/get handlers.
533 */
534 k->info = snd_soc_bytes_info;
535 k->tlv.c = snd_soc_bytes_tlv_callback;
536
537 ext_ops = tplg->bytes_ext_ops;
538 num_ops = tplg->bytes_ext_ops_count;
539 for (i = 0; i < num_ops; i++) {
540 if (!sbe->put && ext_ops[i].id == be->ext_ops.put)
541 sbe->put = ext_ops[i].put;
542 if (!sbe->get && ext_ops[i].id == be->ext_ops.get)
543 sbe->get = ext_ops[i].get;
544 }
545
546 if (sbe->put && sbe->get)
547 return 0;
548 else
549 return -EINVAL;
550 }
515 551
516 /* try and map standard kcontrols handler first */ 552 /* try and map vendor specific kcontrol handlers first */
553 ops = tplg->io_ops;
554 num_ops = tplg->io_ops_count;
517 for (i = 0; i < num_ops; i++) { 555 for (i = 0; i < num_ops; i++) {
518 556
519 if (ops[i].id == hdr->ops.put) 557 if (k->put == NULL && ops[i].id == hdr->ops.put)
520 k->put = ops[i].put; 558 k->put = ops[i].put;
521 if (ops[i].id == hdr->ops.get) 559 if (k->get == NULL && ops[i].id == hdr->ops.get)
522 k->get = ops[i].get; 560 k->get = ops[i].get;
523 if (ops[i].id == hdr->ops.info) 561 if (k->info == NULL && ops[i].id == hdr->ops.info)
524 k->info = ops[i].info; 562 k->info = ops[i].info;
525 } 563 }
526 564
527 /* standard handlers found ? */ 565 /* vendor specific handlers found ? */
528 if (k->put && k->get && k->info) 566 if (k->put && k->get && k->info)
529 return 0; 567 return 0;
530 568
531 /* none found so try bespoke handlers */ 569 /* none found so try standard kcontrol handlers */
532 for (i = 0; i < num_bops; i++) { 570 ops = io_ops;
571 num_ops = ARRAY_SIZE(io_ops);
572 for (i = 0; i < num_ops; i++) {
533 573
534 if (k->put == NULL && bops[i].id == hdr->ops.put) 574 if (k->put == NULL && ops[i].id == hdr->ops.put)
535 k->put = bops[i].put; 575 k->put = ops[i].put;
536 if (k->get == NULL && bops[i].id == hdr->ops.get) 576 if (k->get == NULL && ops[i].id == hdr->ops.get)
537 k->get = bops[i].get; 577 k->get = ops[i].get;
538 if (k->info == NULL && bops[i].id == hdr->ops.info) 578 if (k->info == NULL && ops[i].id == hdr->ops.info)
539 k->info = bops[i].info; 579 k->info = ops[i].info;
540 } 580 }
541 581
542 /* bespoke handlers found ? */ 582 /* standard handlers found ? */
543 if (k->put && k->get && k->info) 583 if (k->put && k->get && k->info)
544 return 0; 584 return 0;
545 585
@@ -609,9 +649,7 @@ static int soc_tplg_create_tlv(struct soc_tplg *tplg,
609 if (!(tc->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE)) 649 if (!(tc->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE))
610 return 0; 650 return 0;
611 651
612 if (tc->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) { 652 if (!(tc->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK)) {
613 kc->tlv.c = snd_soc_bytes_tlv_callback;
614 } else {
615 tplg_tlv = &tc->tlv; 653 tplg_tlv = &tc->tlv;
616 switch (tplg_tlv->type) { 654 switch (tplg_tlv->type) {
617 case SNDRV_CTL_TLVT_DB_SCALE: 655 case SNDRV_CTL_TLVT_DB_SCALE:
@@ -682,8 +720,7 @@ static int soc_tplg_dbytes_create(struct soc_tplg *tplg, unsigned int count,
682 INIT_LIST_HEAD(&sbe->dobj.list); 720 INIT_LIST_HEAD(&sbe->dobj.list);
683 721
684 /* map io handlers */ 722 /* map io handlers */
685 err = soc_tplg_kcontrol_bind_io(&be->hdr, &kc, io_ops, 723 err = soc_tplg_kcontrol_bind_io(&be->hdr, &kc, tplg);
686 ARRAY_SIZE(io_ops), tplg->io_ops, tplg->io_ops_count);
687 if (err) { 724 if (err) {
688 soc_control_err(tplg, &be->hdr, be->hdr.name); 725 soc_control_err(tplg, &be->hdr, be->hdr.name);
689 kfree(sbe); 726 kfree(sbe);
@@ -777,8 +814,7 @@ static int soc_tplg_dmixer_create(struct soc_tplg *tplg, unsigned int count,
777 INIT_LIST_HEAD(&sm->dobj.list); 814 INIT_LIST_HEAD(&sm->dobj.list);
778 815
779 /* map io handlers */ 816 /* map io handlers */
780 err = soc_tplg_kcontrol_bind_io(&mc->hdr, &kc, io_ops, 817 err = soc_tplg_kcontrol_bind_io(&mc->hdr, &kc, tplg);
781 ARRAY_SIZE(io_ops), tplg->io_ops, tplg->io_ops_count);
782 if (err) { 818 if (err) {
783 soc_control_err(tplg, &mc->hdr, mc->hdr.name); 819 soc_control_err(tplg, &mc->hdr, mc->hdr.name);
784 kfree(sm); 820 kfree(sm);
@@ -855,12 +891,12 @@ static int soc_tplg_denum_create_values(struct soc_enum *se,
855 if (ec->items > sizeof(*ec->values)) 891 if (ec->items > sizeof(*ec->values))
856 return -EINVAL; 892 return -EINVAL;
857 893
858 se->dobj.control.dvalues = 894 se->dobj.control.dvalues = kmemdup(ec->values,
859 kmalloc(ec->items * sizeof(u32), GFP_KERNEL); 895 ec->items * sizeof(u32),
896 GFP_KERNEL);
860 if (!se->dobj.control.dvalues) 897 if (!se->dobj.control.dvalues)
861 return -ENOMEM; 898 return -ENOMEM;
862 899
863 memcpy(se->dobj.control.dvalues, ec->values, ec->items * sizeof(u32));
864 return 0; 900 return 0;
865} 901}
866 902
@@ -950,8 +986,7 @@ static int soc_tplg_denum_create(struct soc_tplg *tplg, unsigned int count,
950 } 986 }
951 987
952 /* map io handlers */ 988 /* map io handlers */
953 err = soc_tplg_kcontrol_bind_io(&ec->hdr, &kc, io_ops, 989 err = soc_tplg_kcontrol_bind_io(&ec->hdr, &kc, tplg);
954 ARRAY_SIZE(io_ops), tplg->io_ops, tplg->io_ops_count);
955 if (err) { 990 if (err) {
956 soc_control_err(tplg, &ec->hdr, ec->hdr.name); 991 soc_control_err(tplg, &ec->hdr, ec->hdr.name);
957 kfree(se); 992 kfree(se);
@@ -1093,7 +1128,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create(
1093 struct snd_soc_tplg_mixer_control *mc; 1128 struct snd_soc_tplg_mixer_control *mc;
1094 int i, err; 1129 int i, err;
1095 1130
1096 kc = kzalloc(sizeof(*kc) * num_kcontrols, GFP_KERNEL); 1131 kc = kcalloc(num_kcontrols, sizeof(*kc), GFP_KERNEL);
1097 if (kc == NULL) 1132 if (kc == NULL)
1098 return NULL; 1133 return NULL;
1099 1134
@@ -1137,8 +1172,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create(
1137 INIT_LIST_HEAD(&sm->dobj.list); 1172 INIT_LIST_HEAD(&sm->dobj.list);
1138 1173
1139 /* map io handlers */ 1174 /* map io handlers */
1140 err = soc_tplg_kcontrol_bind_io(&mc->hdr, &kc[i], io_ops, 1175 err = soc_tplg_kcontrol_bind_io(&mc->hdr, &kc[i], tplg);
1141 ARRAY_SIZE(io_ops), tplg->io_ops, tplg->io_ops_count);
1142 if (err) { 1176 if (err) {
1143 soc_control_err(tplg, &mc->hdr, mc->hdr.name); 1177 soc_control_err(tplg, &mc->hdr, mc->hdr.name);
1144 kfree(sm); 1178 kfree(sm);
@@ -1235,8 +1269,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
1235 } 1269 }
1236 1270
1237 /* map io handlers */ 1271 /* map io handlers */
1238 err = soc_tplg_kcontrol_bind_io(&ec->hdr, kc, io_ops, 1272 err = soc_tplg_kcontrol_bind_io(&ec->hdr, kc, tplg);
1239 ARRAY_SIZE(io_ops), tplg->io_ops, tplg->io_ops_count);
1240 if (err) { 1273 if (err) {
1241 soc_control_err(tplg, &ec->hdr, ec->hdr.name); 1274 soc_control_err(tplg, &ec->hdr, ec->hdr.name);
1242 goto err_se; 1275 goto err_se;
@@ -1274,7 +1307,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dbytes_create(
1274 struct snd_kcontrol_new *kc; 1307 struct snd_kcontrol_new *kc;
1275 int i, err; 1308 int i, err;
1276 1309
1277 kc = kzalloc(sizeof(*kc) * count, GFP_KERNEL); 1310 kc = kcalloc(count, sizeof(*kc), GFP_KERNEL);
1278 if (!kc) 1311 if (!kc)
1279 return NULL; 1312 return NULL;
1280 1313
@@ -1297,7 +1330,6 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dbytes_create(
1297 "ASoC: adding bytes kcontrol %s with access 0x%x\n", 1330 "ASoC: adding bytes kcontrol %s with access 0x%x\n",
1298 be->hdr.name, be->hdr.access); 1331 be->hdr.name, be->hdr.access);
1299 1332
1300 memset(kc, 0, sizeof(*kc));
1301 kc[i].name = be->hdr.name; 1333 kc[i].name = be->hdr.name;
1302 kc[i].private_value = (long)sbe; 1334 kc[i].private_value = (long)sbe;
1303 kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER; 1335 kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
@@ -1307,9 +1339,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dbytes_create(
1307 INIT_LIST_HEAD(&sbe->dobj.list); 1339 INIT_LIST_HEAD(&sbe->dobj.list);
1308 1340
1309 /* map standard io handlers and check for external handlers */ 1341 /* map standard io handlers and check for external handlers */
1310 err = soc_tplg_kcontrol_bind_io(&be->hdr, &kc[i], io_ops, 1342 err = soc_tplg_kcontrol_bind_io(&be->hdr, &kc[i], tplg);
1311 ARRAY_SIZE(io_ops), tplg->io_ops,
1312 tplg->io_ops_count);
1313 if (err) { 1343 if (err) {
1314 soc_control_err(tplg, &be->hdr, be->hdr.name); 1344 soc_control_err(tplg, &be->hdr, be->hdr.name);
1315 kfree(sbe); 1345 kfree(sbe);
@@ -1737,6 +1767,8 @@ int snd_soc_tplg_component_load(struct snd_soc_component *comp,
1737 tplg.req_index = id; 1767 tplg.req_index = id;
1738 tplg.io_ops = ops->io_ops; 1768 tplg.io_ops = ops->io_ops;
1739 tplg.io_ops_count = ops->io_ops_count; 1769 tplg.io_ops_count = ops->io_ops_count;
1770 tplg.bytes_ext_ops = ops->bytes_ext_ops;
1771 tplg.bytes_ext_ops_count = ops->bytes_ext_ops_count;
1740 1772
1741 return soc_tplg_load(&tplg); 1773 return soc_tplg_load(&tplg);
1742} 1774}
diff --git a/sound/soc/tegra/tegra20_das.c b/sound/soc/tegra/tegra20_das.c
index f52600b4f3fd..89add13c31cf 100644
--- a/sound/soc/tegra/tegra20_das.c
+++ b/sound/soc/tegra/tegra20_das.c
@@ -133,7 +133,7 @@ static const struct regmap_config tegra20_das_regmap_config = {
133 133
134static int tegra20_das_probe(struct platform_device *pdev) 134static int tegra20_das_probe(struct platform_device *pdev)
135{ 135{
136 struct resource *res, *region; 136 struct resource *res;
137 void __iomem *regs; 137 void __iomem *regs;
138 int ret = 0; 138 int ret = 0;
139 139
@@ -149,24 +149,9 @@ static int tegra20_das_probe(struct platform_device *pdev)
149 das->dev = &pdev->dev; 149 das->dev = &pdev->dev;
150 150
151 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 151 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
152 if (!res) { 152 regs = devm_ioremap_resource(&pdev->dev, res);
153 dev_err(&pdev->dev, "No memory resource\n"); 153 if (IS_ERR(regs)) {
154 ret = -ENODEV; 154 ret = PTR_ERR(regs);
155 goto err;
156 }
157
158 region = devm_request_mem_region(&pdev->dev, res->start,
159 resource_size(res), pdev->name);
160 if (!region) {
161 dev_err(&pdev->dev, "Memory region already claimed\n");
162 ret = -EBUSY;
163 goto err;
164 }
165
166 regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
167 if (!regs) {
168 dev_err(&pdev->dev, "ioremap failed\n");
169 ret = -ENOMEM;
170 goto err; 155 goto err;
171 } 156 }
172 157
diff --git a/sound/soc/tegra/tegra20_i2s.c b/sound/soc/tegra/tegra20_i2s.c
index 05f1c6ee99e3..14106fa82bca 100644
--- a/sound/soc/tegra/tegra20_i2s.c
+++ b/sound/soc/tegra/tegra20_i2s.c
@@ -339,7 +339,7 @@ static const struct regmap_config tegra20_i2s_regmap_config = {
339static int tegra20_i2s_platform_probe(struct platform_device *pdev) 339static int tegra20_i2s_platform_probe(struct platform_device *pdev)
340{ 340{
341 struct tegra20_i2s *i2s; 341 struct tegra20_i2s *i2s;
342 struct resource *mem, *memregion; 342 struct resource *mem;
343 void __iomem *regs; 343 void __iomem *regs;
344 int ret; 344 int ret;
345 345
@@ -362,24 +362,9 @@ static int tegra20_i2s_platform_probe(struct platform_device *pdev)
362 } 362 }
363 363
364 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 364 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
365 if (!mem) { 365 regs = devm_ioremap_resource(&pdev->dev, mem);
366 dev_err(&pdev->dev, "No memory resource\n"); 366 if (IS_ERR(regs)) {
367 ret = -ENODEV; 367 ret = PTR_ERR(regs);
368 goto err_clk_put;
369 }
370
371 memregion = devm_request_mem_region(&pdev->dev, mem->start,
372 resource_size(mem), DRV_NAME);
373 if (!memregion) {
374 dev_err(&pdev->dev, "Memory region already claimed\n");
375 ret = -EBUSY;
376 goto err_clk_put;
377 }
378
379 regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
380 if (!regs) {
381 dev_err(&pdev->dev, "ioremap failed\n");
382 ret = -ENOMEM;
383 goto err_clk_put; 368 goto err_clk_put;
384 } 369 }
385 370
diff --git a/sound/soc/tegra/tegra20_spdif.c b/sound/soc/tegra/tegra20_spdif.c
index 9141477a528d..a0c3640572b9 100644
--- a/sound/soc/tegra/tegra20_spdif.c
+++ b/sound/soc/tegra/tegra20_spdif.c
@@ -265,7 +265,7 @@ static const struct regmap_config tegra20_spdif_regmap_config = {
265static int tegra20_spdif_platform_probe(struct platform_device *pdev) 265static int tegra20_spdif_platform_probe(struct platform_device *pdev)
266{ 266{
267 struct tegra20_spdif *spdif; 267 struct tegra20_spdif *spdif;
268 struct resource *mem, *memregion, *dmareq; 268 struct resource *mem, *dmareq;
269 void __iomem *regs; 269 void __iomem *regs;
270 int ret; 270 int ret;
271 271
@@ -273,45 +273,26 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
273 GFP_KERNEL); 273 GFP_KERNEL);
274 if (!spdif) { 274 if (!spdif) {
275 dev_err(&pdev->dev, "Can't allocate tegra20_spdif\n"); 275 dev_err(&pdev->dev, "Can't allocate tegra20_spdif\n");
276 ret = -ENOMEM; 276 return -ENOMEM;
277 goto err;
278 } 277 }
279 dev_set_drvdata(&pdev->dev, spdif); 278 dev_set_drvdata(&pdev->dev, spdif);
280 279
281 spdif->clk_spdif_out = clk_get(&pdev->dev, "spdif_out"); 280 spdif->clk_spdif_out = devm_clk_get(&pdev->dev, "spdif_out");
282 if (IS_ERR(spdif->clk_spdif_out)) { 281 if (IS_ERR(spdif->clk_spdif_out)) {
283 pr_err("Can't retrieve spdif clock\n"); 282 pr_err("Can't retrieve spdif clock\n");
284 ret = PTR_ERR(spdif->clk_spdif_out); 283 ret = PTR_ERR(spdif->clk_spdif_out);
285 goto err; 284 return ret;
286 } 285 }
287 286
288 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 287 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
289 if (!mem) { 288 regs = devm_ioremap_resource(&pdev->dev, mem);
290 dev_err(&pdev->dev, "No memory resource\n"); 289 if (IS_ERR(regs))
291 ret = -ENODEV; 290 return PTR_ERR(regs);
292 goto err_clk_put;
293 }
294 291
295 dmareq = platform_get_resource(pdev, IORESOURCE_DMA, 0); 292 dmareq = platform_get_resource(pdev, IORESOURCE_DMA, 0);
296 if (!dmareq) { 293 if (!dmareq) {
297 dev_err(&pdev->dev, "No DMA resource\n"); 294 dev_err(&pdev->dev, "No DMA resource\n");
298 ret = -ENODEV; 295 return -ENODEV;
299 goto err_clk_put;
300 }
301
302 memregion = devm_request_mem_region(&pdev->dev, mem->start,
303 resource_size(mem), DRV_NAME);
304 if (!memregion) {
305 dev_err(&pdev->dev, "Memory region already claimed\n");
306 ret = -EBUSY;
307 goto err_clk_put;
308 }
309
310 regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
311 if (!regs) {
312 dev_err(&pdev->dev, "ioremap failed\n");
313 ret = -ENOMEM;
314 goto err_clk_put;
315 } 296 }
316 297
317 spdif->regmap = devm_regmap_init_mmio(&pdev->dev, regs, 298 spdif->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
@@ -319,7 +300,7 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
319 if (IS_ERR(spdif->regmap)) { 300 if (IS_ERR(spdif->regmap)) {
320 dev_err(&pdev->dev, "regmap init failed\n"); 301 dev_err(&pdev->dev, "regmap init failed\n");
321 ret = PTR_ERR(spdif->regmap); 302 ret = PTR_ERR(spdif->regmap);
322 goto err_clk_put; 303 return ret;
323 } 304 }
324 305
325 spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT; 306 spdif->playback_dma_data.addr = mem->start + TEGRA20_SPDIF_DATA_OUT;
@@ -335,7 +316,7 @@ static int tegra20_spdif_platform_probe(struct platform_device *pdev)
335 } 316 }
336 317
337 ret = snd_soc_register_component(&pdev->dev, &tegra20_spdif_component, 318 ret = snd_soc_register_component(&pdev->dev, &tegra20_spdif_component,
338 &tegra20_spdif_dai, 1); 319 &tegra20_spdif_dai, 1);
339 if (ret) { 320 if (ret) {
340 dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); 321 dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
341 ret = -ENOMEM; 322 ret = -ENOMEM;
@@ -357,16 +338,12 @@ err_suspend:
357 tegra20_spdif_runtime_suspend(&pdev->dev); 338 tegra20_spdif_runtime_suspend(&pdev->dev);
358err_pm_disable: 339err_pm_disable:
359 pm_runtime_disable(&pdev->dev); 340 pm_runtime_disable(&pdev->dev);
360err_clk_put: 341
361 clk_put(spdif->clk_spdif_out);
362err:
363 return ret; 342 return ret;
364} 343}
365 344
366static int tegra20_spdif_platform_remove(struct platform_device *pdev) 345static int tegra20_spdif_platform_remove(struct platform_device *pdev)
367{ 346{
368 struct tegra20_spdif *spdif = dev_get_drvdata(&pdev->dev);
369
370 pm_runtime_disable(&pdev->dev); 347 pm_runtime_disable(&pdev->dev);
371 if (!pm_runtime_status_suspended(&pdev->dev)) 348 if (!pm_runtime_status_suspended(&pdev->dev))
372 tegra20_spdif_runtime_suspend(&pdev->dev); 349 tegra20_spdif_runtime_suspend(&pdev->dev);
@@ -374,8 +351,6 @@ static int tegra20_spdif_platform_remove(struct platform_device *pdev)
374 tegra_pcm_platform_unregister(&pdev->dev); 351 tegra_pcm_platform_unregister(&pdev->dev);
375 snd_soc_unregister_component(&pdev->dev); 352 snd_soc_unregister_component(&pdev->dev);
376 353
377 clk_put(spdif->clk_spdif_out);
378
379 return 0; 354 return 0;
380} 355}
381 356
diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c
index bc94e5d8e79a..fef3b9a21a66 100644
--- a/sound/soc/tegra/tegra30_ahub.c
+++ b/sound/soc/tegra/tegra30_ahub.c
@@ -521,7 +521,7 @@ static int tegra30_ahub_probe(struct platform_device *pdev)
521 const struct tegra30_ahub_soc_data *soc_data; 521 const struct tegra30_ahub_soc_data *soc_data;
522 struct reset_control *rst; 522 struct reset_control *rst;
523 int i; 523 int i;
524 struct resource *res0, *res1, *region; 524 struct resource *res0, *res1;
525 void __iomem *regs_apbif, *regs_ahub; 525 void __iomem *regs_apbif, *regs_ahub;
526 int ret = 0; 526 int ret = 0;
527 527
@@ -549,103 +549,67 @@ static int tegra30_ahub_probe(struct platform_device *pdev)
549 dev_err(&pdev->dev, "Can't get reset %s\n", 549 dev_err(&pdev->dev, "Can't get reset %s\n",
550 configlink_mods[i].rst_name); 550 configlink_mods[i].rst_name);
551 ret = PTR_ERR(rst); 551 ret = PTR_ERR(rst);
552 goto err; 552 return ret;
553 } 553 }
554 554
555 ret = reset_control_deassert(rst); 555 ret = reset_control_deassert(rst);
556 reset_control_put(rst); 556 reset_control_put(rst);
557 if (ret) 557 if (ret)
558 goto err; 558 return ret;
559 } 559 }
560 560
561 ahub = devm_kzalloc(&pdev->dev, sizeof(struct tegra30_ahub), 561 ahub = devm_kzalloc(&pdev->dev, sizeof(struct tegra30_ahub),
562 GFP_KERNEL); 562 GFP_KERNEL);
563 if (!ahub) { 563 if (!ahub) {
564 dev_err(&pdev->dev, "Can't allocate tegra30_ahub\n"); 564 dev_err(&pdev->dev, "Can't allocate tegra30_ahub\n");
565 ret = -ENOMEM; 565 return -ENOMEM;
566 goto err;
567 } 566 }
568 dev_set_drvdata(&pdev->dev, ahub); 567 dev_set_drvdata(&pdev->dev, ahub);
569 568
570 ahub->soc_data = soc_data; 569 ahub->soc_data = soc_data;
571 ahub->dev = &pdev->dev; 570 ahub->dev = &pdev->dev;
572 571
573 ahub->clk_d_audio = clk_get(&pdev->dev, "d_audio"); 572 ahub->clk_d_audio = devm_clk_get(&pdev->dev, "d_audio");
574 if (IS_ERR(ahub->clk_d_audio)) { 573 if (IS_ERR(ahub->clk_d_audio)) {
575 dev_err(&pdev->dev, "Can't retrieve ahub d_audio clock\n"); 574 dev_err(&pdev->dev, "Can't retrieve ahub d_audio clock\n");
576 ret = PTR_ERR(ahub->clk_d_audio); 575 ret = PTR_ERR(ahub->clk_d_audio);
577 goto err; 576 return ret;
578 } 577 }
579 578
580 ahub->clk_apbif = clk_get(&pdev->dev, "apbif"); 579 ahub->clk_apbif = devm_clk_get(&pdev->dev, "apbif");
581 if (IS_ERR(ahub->clk_apbif)) { 580 if (IS_ERR(ahub->clk_apbif)) {
582 dev_err(&pdev->dev, "Can't retrieve ahub apbif clock\n"); 581 dev_err(&pdev->dev, "Can't retrieve ahub apbif clock\n");
583 ret = PTR_ERR(ahub->clk_apbif); 582 ret = PTR_ERR(ahub->clk_apbif);
584 goto err_clk_put_d_audio; 583 return ret;
585 } 584 }
586 585
587 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); 586 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
588 if (!res0) { 587 regs_apbif = devm_ioremap_resource(&pdev->dev, res0);
589 dev_err(&pdev->dev, "No apbif memory resource\n"); 588 if (IS_ERR(regs_apbif))
590 ret = -ENODEV; 589 return PTR_ERR(regs_apbif);
591 goto err_clk_put_apbif;
592 }
593 590
594 region = devm_request_mem_region(&pdev->dev, res0->start,
595 resource_size(res0), DRV_NAME);
596 if (!region) {
597 dev_err(&pdev->dev, "request region apbif failed\n");
598 ret = -EBUSY;
599 goto err_clk_put_apbif;
600 }
601 ahub->apbif_addr = res0->start; 591 ahub->apbif_addr = res0->start;
602 592
603 regs_apbif = devm_ioremap(&pdev->dev, res0->start,
604 resource_size(res0));
605 if (!regs_apbif) {
606 dev_err(&pdev->dev, "ioremap apbif failed\n");
607 ret = -ENOMEM;
608 goto err_clk_put_apbif;
609 }
610
611 ahub->regmap_apbif = devm_regmap_init_mmio(&pdev->dev, regs_apbif, 593 ahub->regmap_apbif = devm_regmap_init_mmio(&pdev->dev, regs_apbif,
612 &tegra30_ahub_apbif_regmap_config); 594 &tegra30_ahub_apbif_regmap_config);
613 if (IS_ERR(ahub->regmap_apbif)) { 595 if (IS_ERR(ahub->regmap_apbif)) {
614 dev_err(&pdev->dev, "apbif regmap init failed\n"); 596 dev_err(&pdev->dev, "apbif regmap init failed\n");
615 ret = PTR_ERR(ahub->regmap_apbif); 597 ret = PTR_ERR(ahub->regmap_apbif);
616 goto err_clk_put_apbif; 598 return ret;
617 } 599 }
618 regcache_cache_only(ahub->regmap_apbif, true); 600 regcache_cache_only(ahub->regmap_apbif, true);
619 601
620 res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); 602 res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
621 if (!res1) { 603 regs_ahub = devm_ioremap_resource(&pdev->dev, res1);
622 dev_err(&pdev->dev, "No ahub memory resource\n"); 604 if (IS_ERR(regs_ahub))
623 ret = -ENODEV; 605 return PTR_ERR(regs_ahub);
624 goto err_clk_put_apbif;
625 }
626
627 region = devm_request_mem_region(&pdev->dev, res1->start,
628 resource_size(res1), DRV_NAME);
629 if (!region) {
630 dev_err(&pdev->dev, "request region ahub failed\n");
631 ret = -EBUSY;
632 goto err_clk_put_apbif;
633 }
634
635 regs_ahub = devm_ioremap(&pdev->dev, res1->start,
636 resource_size(res1));
637 if (!regs_ahub) {
638 dev_err(&pdev->dev, "ioremap ahub failed\n");
639 ret = -ENOMEM;
640 goto err_clk_put_apbif;
641 }
642 606
643 ahub->regmap_ahub = devm_regmap_init_mmio(&pdev->dev, regs_ahub, 607 ahub->regmap_ahub = devm_regmap_init_mmio(&pdev->dev, regs_ahub,
644 &tegra30_ahub_ahub_regmap_config); 608 &tegra30_ahub_ahub_regmap_config);
645 if (IS_ERR(ahub->regmap_ahub)) { 609 if (IS_ERR(ahub->regmap_ahub)) {
646 dev_err(&pdev->dev, "ahub regmap init failed\n"); 610 dev_err(&pdev->dev, "ahub regmap init failed\n");
647 ret = PTR_ERR(ahub->regmap_ahub); 611 ret = PTR_ERR(ahub->regmap_ahub);
648 goto err_clk_put_apbif; 612 return ret;
649 } 613 }
650 regcache_cache_only(ahub->regmap_ahub, true); 614 regcache_cache_only(ahub->regmap_ahub, true);
651 615
@@ -662,12 +626,7 @@ static int tegra30_ahub_probe(struct platform_device *pdev)
662 626
663err_pm_disable: 627err_pm_disable:
664 pm_runtime_disable(&pdev->dev); 628 pm_runtime_disable(&pdev->dev);
665err_clk_put_apbif: 629
666 clk_put(ahub->clk_apbif);
667err_clk_put_d_audio:
668 clk_put(ahub->clk_d_audio);
669 ahub = NULL;
670err:
671 return ret; 630 return ret;
672} 631}
673 632
@@ -680,11 +639,6 @@ static int tegra30_ahub_remove(struct platform_device *pdev)
680 if (!pm_runtime_status_suspended(&pdev->dev)) 639 if (!pm_runtime_status_suspended(&pdev->dev))
681 tegra30_ahub_runtime_suspend(&pdev->dev); 640 tegra30_ahub_runtime_suspend(&pdev->dev);
682 641
683 clk_put(ahub->clk_apbif);
684 clk_put(ahub->clk_d_audio);
685
686 ahub = NULL;
687
688 return 0; 642 return 0;
689} 643}
690 644
diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c
index fe36375ba89c..8e55583aa104 100644
--- a/sound/soc/tegra/tegra30_i2s.c
+++ b/sound/soc/tegra/tegra30_i2s.c
@@ -379,7 +379,7 @@ static int tegra30_i2s_platform_probe(struct platform_device *pdev)
379 struct tegra30_i2s *i2s; 379 struct tegra30_i2s *i2s;
380 const struct of_device_id *match; 380 const struct of_device_id *match;
381 u32 cif_ids[2]; 381 u32 cif_ids[2];
382 struct resource *mem, *memregion; 382 struct resource *mem;
383 void __iomem *regs; 383 void __iomem *regs;
384 int ret; 384 int ret;
385 385
@@ -419,24 +419,9 @@ static int tegra30_i2s_platform_probe(struct platform_device *pdev)
419 } 419 }
420 420
421 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 421 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
422 if (!mem) { 422 regs = devm_ioremap_resource(&pdev->dev, mem);
423 dev_err(&pdev->dev, "No memory resource\n"); 423 if (IS_ERR(regs)) {
424 ret = -ENODEV; 424 ret = PTR_ERR(regs);
425 goto err_clk_put;
426 }
427
428 memregion = devm_request_mem_region(&pdev->dev, mem->start,
429 resource_size(mem), DRV_NAME);
430 if (!memregion) {
431 dev_err(&pdev->dev, "Memory region already claimed\n");
432 ret = -EBUSY;
433 goto err_clk_put;
434 }
435
436 regs = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
437 if (!regs) {
438 dev_err(&pdev->dev, "ioremap failed\n");
439 ret = -ENOMEM;
440 goto err_clk_put; 425 goto err_clk_put;
441 } 426 }
442 427