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

ASoC: max9877: 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
d6e3bb7a e0340985

+6 -8
+6 -8
sound/soc/codecs/max9877.c
··· 30 30 { 4, 0x49 }, 31 31 }; 32 32 33 - static const unsigned int max9877_pgain_tlv[] = { 34 - TLV_DB_RANGE_HEAD(2), 33 + static const DECLARE_TLV_DB_RANGE(max9877_pgain_tlv, 35 34 0, 1, TLV_DB_SCALE_ITEM(0, 900, 0), 36 - 2, 2, TLV_DB_SCALE_ITEM(2000, 0, 0), 37 - }; 35 + 2, 2, TLV_DB_SCALE_ITEM(2000, 0, 0) 36 + ); 38 37 39 - static const unsigned int max9877_output_tlv[] = { 40 - TLV_DB_RANGE_HEAD(4), 38 + static const DECLARE_TLV_DB_RANGE(max9877_output_tlv, 41 39 0, 7, TLV_DB_SCALE_ITEM(-7900, 400, 1), 42 40 8, 15, TLV_DB_SCALE_ITEM(-4700, 300, 0), 43 41 16, 23, TLV_DB_SCALE_ITEM(-2300, 200, 0), 44 - 24, 31, TLV_DB_SCALE_ITEM(-700, 100, 0), 45 - }; 42 + 24, 31, TLV_DB_SCALE_ITEM(-700, 100, 0) 43 + ); 46 44 47 45 static const char *max9877_out_mode[] = { 48 46 "INA -> SPK",