pcm: hw: use position offset macro of TLV data

A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Sakamoto 2018-05-15 21:36:37 +09:00 committed by Takashi Iwai
parent 33f0888f0d
commit b0b720513e

View file

@ -1199,6 +1199,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev,
snd_ctl_t *ctl; snd_ctl_t *ctl;
snd_ctl_elem_id_t id = {0}; snd_ctl_elem_id_t id = {0};
unsigned int tlv[2048], *start; unsigned int tlv[2048], *start;
unsigned int type;
snd_pcm_chmap_query_t **map; snd_pcm_chmap_query_t **map;
int i, ret, nums; int i, ret, nums;
@ -1223,9 +1224,10 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev,
/* FIXME: the parser below assumes that the TLV only contains /* FIXME: the parser below assumes that the TLV only contains
* chmap-related blocks * chmap-related blocks
*/ */
if (tlv[0] != SND_CTL_TLVT_CONTAINER) { type = tlv[SNDRV_CTL_TLVO_TYPE];
if (!is_chmap_type(tlv[0])) { if (type != SND_CTL_TLVT_CONTAINER) {
SYSMSG("Invalid TLV type %d\n", tlv[0]); if (!is_chmap_type(type)) {
SYSMSG("Invalid TLV type %d\n", type);
return NULL; return NULL;
} }
start = tlv; start = tlv;
@ -1234,7 +1236,7 @@ snd_pcm_query_chmaps_from_hw(int card, int dev, int subdev,
unsigned int *p; unsigned int *p;
int size; int size;
start = tlv + 2; start = tlv + 2;
size = tlv[1]; size = tlv[SNDRV_CTL_TLVO_LEN];
nums = 0; nums = 0;
for (p = start; size > 0; ) { for (p = start; size > 0; ) {
if (!is_chmap_type(p[0])) { if (!is_chmap_type(p[0])) {