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

ASoC: max98095: 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
54c2011f 8896bc3e

+15 -20
+15 -20
sound/soc/codecs/max98095.c
··· 661 661 return 0; 662 662 } 663 663 664 - static const unsigned int max98095_micboost_tlv[] = { 665 - TLV_DB_RANGE_HEAD(2), 664 + static const DECLARE_TLV_DB_RANGE(max98095_micboost_tlv, 666 665 0, 1, TLV_DB_SCALE_ITEM(0, 2000, 0), 667 - 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0), 668 - }; 666 + 2, 2, TLV_DB_SCALE_ITEM(3000, 0, 0) 667 + ); 669 668 670 669 static const DECLARE_TLV_DB_SCALE(max98095_mic_tlv, 0, 100, 0); 671 670 static const DECLARE_TLV_DB_SCALE(max98095_adc_tlv, -1200, 100, 0); 672 671 static const DECLARE_TLV_DB_SCALE(max98095_adcboost_tlv, 0, 600, 0); 673 672 674 - static const unsigned int max98095_hp_tlv[] = { 675 - TLV_DB_RANGE_HEAD(5), 673 + static const DECLARE_TLV_DB_RANGE(max98095_hp_tlv, 676 674 0, 6, TLV_DB_SCALE_ITEM(-6700, 400, 0), 677 675 7, 14, TLV_DB_SCALE_ITEM(-4000, 300, 0), 678 676 15, 21, TLV_DB_SCALE_ITEM(-1700, 200, 0), 679 677 22, 27, TLV_DB_SCALE_ITEM(-400, 100, 0), 680 - 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0), 681 - }; 678 + 28, 31, TLV_DB_SCALE_ITEM(150, 50, 0) 679 + ); 682 680 683 - static const unsigned int max98095_spk_tlv[] = { 684 - TLV_DB_RANGE_HEAD(4), 681 + static const DECLARE_TLV_DB_RANGE(max98095_spk_tlv, 685 682 0, 10, TLV_DB_SCALE_ITEM(-5900, 400, 0), 686 683 11, 18, TLV_DB_SCALE_ITEM(-1700, 200, 0), 687 684 19, 27, TLV_DB_SCALE_ITEM(-200, 100, 0), 688 - 28, 39, TLV_DB_SCALE_ITEM(650, 50, 0), 689 - }; 685 + 28, 39, TLV_DB_SCALE_ITEM(650, 50, 0) 686 + ); 690 687 691 - static const unsigned int max98095_rcv_lout_tlv[] = { 692 - TLV_DB_RANGE_HEAD(5), 688 + static const DECLARE_TLV_DB_RANGE(max98095_rcv_lout_tlv, 693 689 0, 6, TLV_DB_SCALE_ITEM(-6200, 400, 0), 694 690 7, 14, TLV_DB_SCALE_ITEM(-3500, 300, 0), 695 691 15, 21, TLV_DB_SCALE_ITEM(-1200, 200, 0), 696 692 22, 27, TLV_DB_SCALE_ITEM(100, 100, 0), 697 - 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0), 698 - }; 693 + 28, 31, TLV_DB_SCALE_ITEM(650, 50, 0) 694 + ); 699 695 700 - static const unsigned int max98095_lin_tlv[] = { 701 - TLV_DB_RANGE_HEAD(3), 696 + static const DECLARE_TLV_DB_RANGE(max98095_lin_tlv, 702 697 0, 2, TLV_DB_SCALE_ITEM(-600, 300, 0), 703 698 3, 3, TLV_DB_SCALE_ITEM(300, 1100, 0), 704 - 4, 5, TLV_DB_SCALE_ITEM(1400, 600, 0), 705 - }; 699 + 4, 5, TLV_DB_SCALE_ITEM(1400, 600, 0) 700 + ); 706 701 707 702 static const struct snd_kcontrol_new max98095_snd_controls[] = { 708 703