]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ASoC: soc-ops: use snd_soc_component_regmap_val_bytes()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 12 Mar 2026 00:15:21 +0000 (00:15 +0000)
committerMark Brown <broonie@kernel.org>
Fri, 20 Mar 2026 12:55:38 +0000 (12:55 +0000)
component has component->val_bytes which is set via
snd_soc_component_setup_regmap(). But it can be calculated via
component->regmap. No need to keep it as component->val_bytes.

Use snd_soc_component_regmap_val_bytes().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/875x71zyw5.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-ops.c

index f966d4e13c7fc38b8711a44b2e188c8d377dcef3..01d20a71ed779f79e94c6643aa37d8dd21da1063 100644 (file)
@@ -514,9 +514,10 @@ int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_bytes *params = (void *)kcontrol->private_value;
+       int val_bytes = snd_soc_component_regmap_val_bytes(component);
 
        uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-       uinfo->count = params->num_regs * component->val_bytes;
+       uinfo->count = params->num_regs * val_bytes;
 
        return 0;
 }
@@ -527,18 +528,19 @@ int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_bytes *params = (void *)kcontrol->private_value;
+       int val_bytes = snd_soc_component_regmap_val_bytes(component);
        int ret;
 
        if (component->regmap)
                ret = regmap_raw_read(component->regmap, params->base,
                                      ucontrol->value.bytes.data,
-                                     params->num_regs * component->val_bytes);
+                                     params->num_regs * val_bytes);
        else
                ret = -EINVAL;
 
        /* Hide any masked bytes to ensure consistent data reporting */
        if (ret == 0 && params->mask) {
-               switch (component->val_bytes) {
+               switch (val_bytes) {
                case 1:
                        ucontrol->value.bytes.data[0] &= ~params->mask;
                        break;
@@ -564,13 +566,14 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_bytes *params = (void *)kcontrol->private_value;
+       int val_bytes = snd_soc_component_regmap_val_bytes(component);
        unsigned int val, mask;
        int ret, len;
 
        if (!component->regmap || !params->num_regs)
                return -EINVAL;
 
-       len = params->num_regs * component->val_bytes;
+       len = params->num_regs * val_bytes;
 
        void *data __free(kfree) = kmemdup(ucontrol->value.bytes.data, len,
                                           GFP_KERNEL | GFP_DMA);
@@ -589,7 +592,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
 
                val &= params->mask;
 
-               switch (component->val_bytes) {
+               switch (val_bytes) {
                case 1:
                        ((u8 *)data)[0] &= ~params->mask;
                        ((u8 *)data)[0] |= val;
@@ -712,9 +715,10 @@ int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
        struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_mreg_control *mc =
                (struct soc_mreg_control *)kcontrol->private_value;
+       int val_bytes = snd_soc_component_regmap_val_bytes(component);
        unsigned int regbase = mc->regbase;
        unsigned int regcount = mc->regcount;
-       unsigned int regwshift = component->val_bytes * BITS_PER_BYTE;
+       unsigned int regwshift = val_bytes * BITS_PER_BYTE;
        unsigned int regwmask = GENMASK(regwshift - 1, 0);
        unsigned long mask = GENMASK(mc->nbits - 1, 0);
        long val = 0;
@@ -756,9 +760,10 @@ int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
        struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_mreg_control *mc =
                (struct soc_mreg_control *)kcontrol->private_value;
+       int val_bytes = snd_soc_component_regmap_val_bytes(component);
        unsigned int regbase = mc->regbase;
        unsigned int regcount = mc->regcount;
-       unsigned int regwshift = component->val_bytes * BITS_PER_BYTE;
+       unsigned int regwshift = val_bytes * BITS_PER_BYTE;
        unsigned int regwmask = GENMASK(regwshift - 1, 0);
        unsigned long mask = GENMASK(mc->nbits - 1, 0);
        long val = ucontrol->value.integer.value[0];