Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: max98090: Replace TLV_DB_RANGE_HEAD with DECLARE_TLV_DB_RANGE

DECLARE_TLV_DB_RANGE() has the advantage over using TLV_DB_RANGE_HEAD()
that it automatically calculates the number of items in the TLV and is
hence less prone to manual error.

Generate using the following coccinelle script

// <smpl>
@@
declarer name DECLARE_TLV_DB_RANGE;
identifier tlv;
constant x;
@@
-unsigned int tlv[] = {
- TLV_DB_RANGE_HEAD(x),
+DECLARE_TLV_DB_RANGE(tlv,
...
-};
+);
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Lars-Peter Clausen and committed by
Mark Brown
8896bc3e 80170468

+18 -24
+18 -24
sound/soc/codecs/max98090.c
··· 360 360 return ret; 361 361 } 362 362 363 - static const unsigned int max98090_micboost_tlv[] = { 364 - TLV_DB_RANGE_HEAD(2), 363 + static const DECLARE_TLV_DB_RANGE(max98090_micboost_tlv, 365 364 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0), 366 - 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0), 367 - }; 365 + 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0) 366 + ); 368 367 369 368 static const DECLARE_TLV_DB_SCALE(max98090_mic_tlv, 0, 100, 0); 370 369 371 370 static const DECLARE_TLV_DB_SCALE(max98090_line_single_ended_tlv, 372 371 -600, 600, 0); 373 372 374 - static const unsigned int max98090_line_tlv[] = { 375 - TLV_DB_RANGE_HEAD(2), 373 + static const DECLARE_TLV_DB_RANGE(max98090_line_tlv, 376 374 0, 3, TLV_DB_SCALE_ITEM(-600, 300, 0), 377 - 4, 5, TLV_DB_SCALE_ITEM(1400, 600, 0), 378 - }; 375 + 4, 5, TLV_DB_SCALE_ITEM(1400, 600, 0) 376 + ); 379 377 380 378 static const DECLARE_TLV_DB_SCALE(max98090_avg_tlv, 0, 600, 0); 381 379 static const DECLARE_TLV_DB_SCALE(max98090_av_tlv, -1200, 100, 0); ··· 389 391 static const DECLARE_TLV_DB_SCALE(max98090_drcexp_tlv, -6600, 100, 0); 390 392 static const DECLARE_TLV_DB_SCALE(max98090_sdg_tlv, 50, 200, 0); 391 393 392 - static const unsigned int max98090_mixout_tlv[] = { 393 - TLV_DB_RANGE_HEAD(2), 394 + static const DECLARE_TLV_DB_RANGE(max98090_mixout_tlv, 394 395 0, 1, TLV_DB_SCALE_ITEM(-1200, 250, 0), 395 - 2, 3, TLV_DB_SCALE_ITEM(-600, 600, 0), 396 - }; 396 + 2, 3, TLV_DB_SCALE_ITEM(-600, 600, 0) 397 + ); 397 398 398 - static const unsigned int max98090_hp_tlv[] = { 399 - TLV_DB_RANGE_HEAD(5), 399 + static const DECLARE_TLV_DB_RANGE(max98090_hp_tlv, 400 400 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0), 401 401 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0), 402 402 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0), 403 403 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0), 404 - 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0), 405 - }; 404 + 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0) 405 + ); 406 406 407 - static const unsigned int max98090_spk_tlv[] = { 408 - TLV_DB_RANGE_HEAD(5), 407 + static const DECLARE_TLV_DB_RANGE(max98090_spk_tlv, 409 408 0, 4, TLV_DB_SCALE_ITEM(-4800, 400, 0), 410 409 5, 10, TLV_DB_SCALE_ITEM(-2900, 300, 0), 411 410 11, 14, TLV_DB_SCALE_ITEM(-1200, 200, 0), 412 411 15, 29, TLV_DB_SCALE_ITEM(-500, 100, 0), 413 - 30, 39, TLV_DB_SCALE_ITEM(950, 50, 0), 414 - }; 412 + 30, 39, TLV_DB_SCALE_ITEM(950, 50, 0) 413 + ); 415 414 416 - static const unsigned int max98090_rcv_lout_tlv[] = { 417 - TLV_DB_RANGE_HEAD(5), 415 + static const DECLARE_TLV_DB_RANGE(max98090_rcv_lout_tlv, 418 416 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0), 419 417 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0), 420 418 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0), 421 419 22, 27, TLV_DB_SCALE_ITEM(100, 100, 0), 422 - 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0), 423 - }; 420 + 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0) 421 + ); 424 422 425 423 static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol, 426 424 struct snd_ctl_elem_value *ucontrol)