ASoC: soc-topology: fix endianness issues
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Thu, 2 Jan 2020 19:59:52 +0000 (13:59 -0600)
committerMark Brown <broonie@kernel.org>
Fri, 3 Jan 2020 00:57:57 +0000 (00:57 +0000)
Sparse complains about a series of easy warnings, fix.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200102195952.9465-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-topology.c

index 69d6a52..107ba3e 100644 (file)
@@ -605,9 +605,11 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr,
                ext_ops = tplg->bytes_ext_ops;
                num_ops = tplg->bytes_ext_ops_count;
                for (i = 0; i < num_ops; i++) {
-                       if (!sbe->put && ext_ops[i].id == be->ext_ops.put)
+                       if (!sbe->put &&
+                           ext_ops[i].id == le32_to_cpu(be->ext_ops.put))
                                sbe->put = ext_ops[i].put;
-                       if (!sbe->get && ext_ops[i].id == be->ext_ops.get)
+                       if (!sbe->get &&
+                           ext_ops[i].id == le32_to_cpu(be->ext_ops.get))
                                sbe->get = ext_ops[i].get;
                }
 
@@ -622,11 +624,11 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr,
        num_ops = tplg->io_ops_count;
        for (i = 0; i < num_ops; i++) {
 
-               if (k->put == NULL && ops[i].id == hdr->ops.put)
+               if (k->put == NULL && ops[i].id == le32_to_cpu(hdr->ops.put))
                        k->put = ops[i].put;
-               if (k->get == NULL && ops[i].id == hdr->ops.get)
+               if (k->get == NULL && ops[i].id == le32_to_cpu(hdr->ops.get))
                        k->get = ops[i].get;
-               if (k->info == NULL && ops[i].id == hdr->ops.info)
+               if (k->info == NULL && ops[i].id == le32_to_cpu(hdr->ops.info))
                        k->info = ops[i].info;
        }
 
@@ -639,11 +641,11 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr,
        num_ops = ARRAY_SIZE(io_ops);
        for (i = 0; i < num_ops; i++) {
 
-               if (k->put == NULL && ops[i].id == hdr->ops.put)
+               if (k->put == NULL && ops[i].id == le32_to_cpu(hdr->ops.put))
                        k->put = ops[i].put;
-               if (k->get == NULL && ops[i].id == hdr->ops.get)
+               if (k->get == NULL && ops[i].id == le32_to_cpu(hdr->ops.get))
                        k->get = ops[i].get;
-               if (k->info == NULL && ops[i].id == hdr->ops.info)
+               if (k->info == NULL && ops[i].id == le32_to_cpu(hdr->ops.info))
                        k->info = ops[i].info;
        }
 
@@ -932,7 +934,7 @@ static int soc_tplg_denum_create_texts(struct soc_enum *se,
        if (se->dobj.control.dtexts == NULL)
                return -ENOMEM;
 
-       for (i = 0; i < ec->items; i++) {
+       for (i = 0; i < le32_to_cpu(ec->items); i++) {
 
                if (strnlen(ec->texts[i], SNDRV_CTL_ELEM_ID_NAME_MAXLEN) ==
                        SNDRV_CTL_ELEM_ID_NAME_MAXLEN) {
@@ -1326,7 +1328,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create(
                if (kc[i].name == NULL)
                        goto err_sm;
                kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
-               kc[i].access = mc->hdr.access;
+               kc[i].access = le32_to_cpu(mc->hdr.access);
 
                /* we only support FL/FR channel mapping atm */
                sm->reg = tplc_chan_get_reg(tplg, mc->channel,
@@ -1338,10 +1340,10 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create(
                sm->rshift = tplc_chan_get_shift(tplg, mc->channel,
                        SNDRV_CHMAP_FR);
 
-               sm->max = mc->max;
-               sm->min = mc->min;
-               sm->invert = mc->invert;
-               sm->platform_max = mc->platform_max;
+               sm->max = le32_to_cpu(mc->max);
+               sm->min = le32_to_cpu(mc->min);
+               sm->invert = le32_to_cpu(mc->invert);
+               sm->platform_max = le32_to_cpu(mc->platform_max);
                sm->dobj.index = tplg->index;
                INIT_LIST_HEAD(&sm->dobj.list);
 
@@ -1402,7 +1404,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
                        goto err_se;
 
                tplg->pos += (sizeof(struct snd_soc_tplg_enum_control) +
-                               ec->priv.size);
+                             le32_to_cpu(ec->priv.size));
 
                dev_dbg(tplg->dev, " adding DAPM widget enum control %s\n",
                        ec->hdr.name);
@@ -1412,7 +1414,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
                if (kc[i].name == NULL)
                        goto err_se;
                kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
-               kc[i].access = ec->hdr.access;
+               kc[i].access = le32_to_cpu(ec->hdr.access);
 
                /* we only support FL/FR channel mapping atm */
                se->reg = tplc_chan_get_reg(tplg, ec->channel, SNDRV_CHMAP_FL);
@@ -1421,8 +1423,8 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
                se->shift_r = tplc_chan_get_shift(tplg, ec->channel,
                                                  SNDRV_CHMAP_FR);
 
-               se->items = ec->items;
-               se->mask = ec->mask;
+               se->items = le32_to_cpu(ec->items);
+               se->mask = le32_to_cpu(ec->mask);
                se->dobj.index = tplg->index;
 
                switch (le32_to_cpu(ec->hdr.ops.info)) {
@@ -1524,9 +1526,9 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dbytes_create(
                if (kc[i].name == NULL)
                        goto err_sbe;
                kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
-               kc[i].access = be->hdr.access;
+               kc[i].access = le32_to_cpu(be->hdr.access);
 
-               sbe->max = be->max;
+               sbe->max = le32_to_cpu(be->max);
                INIT_LIST_HEAD(&sbe->dobj.list);
 
                /* map standard io handlers and check for external handlers */