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

ASoC: max98088: 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
80170468 44744eec

+10 -13
+10 -13
sound/soc/codecs/max98088.c
··· 680 680 return 0; 681 681 } 682 682 683 - static const unsigned int max98088_micboost_tlv[] = { 684 - TLV_DB_RANGE_HEAD(2), 685 - 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0), 686 - 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0), 687 - }; 683 + static const DECLARE_TLV_DB_RANGE(max98088_micboost_tlv, 684 + 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0), 685 + 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0) 686 + ); 688 687 689 - static const unsigned int max98088_hp_tlv[] = { 690 - TLV_DB_RANGE_HEAD(5), 688 + static const DECLARE_TLV_DB_RANGE(max98088_hp_tlv, 691 689 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0), 692 690 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0), 693 691 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0), 694 692 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0), 695 - 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0), 696 - }; 693 + 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0) 694 + ); 697 695 698 - static const unsigned int max98088_spk_tlv[] = { 699 - TLV_DB_RANGE_HEAD(5), 696 + static const DECLARE_TLV_DB_RANGE(max98088_spk_tlv, 700 697 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0), 701 698 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0), 702 699 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0), 703 700 22, 27, TLV_DB_SCALE_ITEM(100, 100, 0), 704 - 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0), 705 - }; 701 + 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0) 702 + ); 706 703 707 704 static const struct snd_kcontrol_new max98088_snd_controls[] = { 708 705