summaryrefslogtreecommitdiff
path: root/sound/soc/soc-topology.c
diff options
context:
space:
mode:
authorLiam Girdwood <liam.r.girdwood@linux.intel.com>2015-06-29 19:36:43 +0300
committerMark Brown <broonie@kernel.org>2015-07-02 14:40:09 +0300
commit7084ffbff494669b06ceb457150c38887e26d2a3 (patch)
tree4febfbc59c4f475fd7a9ca96cb9eae177cf20525 /sound/soc/soc-topology.c
parent11e688862c4c8162119a4ca51c3326555966c8bb (diff)
downloadlinux-7084ffbff494669b06ceb457150c38887e26d2a3.tar.xz
ASoC: topology: Fix TLV size calculation.
TLV size calculation was incorrectly calculated. Fix this according to include/sound/tlv.h Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-topology.c')
-rw-r--r--sound/soc/soc-topology.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index d0960683c409..7a19df313fe8 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -580,27 +580,26 @@ static int soc_tplg_init_kcontrol(struct soc_tplg *tplg,
}
static int soc_tplg_create_tlv(struct soc_tplg *tplg,
- struct snd_kcontrol_new *kc, u32 tlv_size)
+ struct snd_kcontrol_new *kc, struct snd_soc_tplg_ctl_tlv *tplg_tlv)
{
- struct snd_soc_tplg_ctl_tlv *tplg_tlv;
struct snd_ctl_tlv *tlv;
+ int size;
- if (tlv_size == 0)
+ if (tplg_tlv->count == 0)
return 0;
- tplg_tlv = (struct snd_soc_tplg_ctl_tlv *) tplg->pos;
- tplg->pos += tlv_size;
-
- tlv = kzalloc(sizeof(*tlv) + tlv_size, GFP_KERNEL);
+ size = ((tplg_tlv->count + (sizeof(unsigned int) - 1)) &
+ ~(sizeof(unsigned int) - 1));
+ tlv = kzalloc(sizeof(*tlv) + size, GFP_KERNEL);
if (tlv == NULL)
return -ENOMEM;
dev_dbg(tplg->dev, " created TLV type %d size %d bytes\n",
- tplg_tlv->numid, tplg_tlv->size);
+ tplg_tlv->numid, size);
tlv->numid = tplg_tlv->numid;
- tlv->length = tplg_tlv->size;
- memcpy(tlv->tlv, tplg_tlv + 1, tplg_tlv->size);
+ tlv->length = size;
+ memcpy(&tlv->tlv[0], tplg_tlv->data, size);
kc->tlv.p = (void *)tlv;
return 0;
@@ -773,7 +772,7 @@ static int soc_tplg_dmixer_create(struct soc_tplg *tplg, unsigned int count,
}
/* create any TLV data */
- soc_tplg_create_tlv(tplg, &kc, mc->hdr.tlv_size);
+ soc_tplg_create_tlv(tplg, &kc, &mc->tlv);
/* register control here */
err = soc_tplg_add_kcontrol(tplg, &kc,