]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: ops: Remove snd_soc_put_volsw_range()
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Tue, 18 Mar 2025 17:14:54 +0000 (17:14 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 19 Mar 2025 12:48:05 +0000 (12:48 +0000)
With the addition of the soc_mixer_ctl_to_reg() helper it is now very
clear that the only difference between snd_soc_put_volsw() and
snd_soc_put_volsw_range() is that the former supports double controls
with both values in the same register. As such we can combine both
functions.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://patch.msgid.link/20250318171459.3203730-11-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc.h
sound/soc/codecs/wm5110.c
sound/soc/soc-ops.c
sound/soc/soc-topology.c

index b11c6cdb0201c3e4a321f1c937ae0b9d6ebc7206..952ed77b8c87fb8164c27f052d8abd9592ead193 100644 (file)
@@ -66,7 +66,7 @@ struct platform_device;
 #define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
        .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
-       .put = snd_soc_put_volsw_range, \
+       .put = snd_soc_put_volsw, \
        .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, 0) }
 #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
@@ -91,7 +91,7 @@ struct platform_device;
                 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
        .tlv.p = (tlv_array), \
        .info = snd_soc_info_volsw, \
-       .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
+       .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
        .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, 0) }
 #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
@@ -117,7 +117,7 @@ struct platform_device;
                           xmax, xinvert)               \
 {      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
        .info = snd_soc_info_volsw, \
-       .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
+       .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
        .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, \
                                            xshift, xmin, xmax, xinvert) }
 #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
@@ -165,7 +165,7 @@ struct platform_device;
                 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
        .tlv.p = (tlv_array), \
        .info = snd_soc_info_volsw, \
-       .get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
+       .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
        .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, \
                                            xshift, xmin, xmax, xinvert) }
 #define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
@@ -569,8 +569,6 @@ int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol);
 int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol);
-int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
-       struct snd_ctl_elem_value *ucontrol);
 int snd_soc_limit_volume(struct snd_soc_card *card,
        const char *name, int max);
 int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
index c24b42c375785948820a719f48075564c1078b93..212eca675f27e7dd572068b807b2194e28c8b56b 100644 (file)
@@ -497,7 +497,7 @@ static int wm5110_in_pga_put(struct snd_kcontrol *kcontrol,
         */
        snd_soc_dapm_mutex_lock(dapm);
 
-       ret = snd_soc_put_volsw_range(kcontrol, ucontrol);
+       ret = snd_soc_put_volsw(kcontrol, ucontrol);
 
        snd_soc_dapm_mutex_unlock(dapm);
 
index fbda8e21c5a60d4bdb75d71a2f8493ad1db092cf..d26d9e050af12c1b70123459bc54a385775cc14e 100644 (file)
@@ -289,12 +289,12 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
 EXPORT_SYMBOL_GPL(snd_soc_get_volsw);
 
 /**
- * snd_soc_put_volsw - single mixer put callback
+ * snd_soc_put_volsw - single mixer put callback with range
  * @kcontrol: mixer control
  * @ucontrol: control element information
  *
- * Callback to set the value of a single mixer control, or a double mixer
- * control that spans 2 registers.
+ * Callback to set the value , within a range, of a single mixer control, or
+ * a double mixer control that spans 2 registers.
  *
  * Returns 0 for success.
  */
@@ -450,62 +450,6 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
 }
 EXPORT_SYMBOL_GPL(snd_soc_put_volsw_sx);
 
-/**
- * snd_soc_put_volsw_range - single mixer put value callback with range.
- * @kcontrol: mixer control
- * @ucontrol: control element information
- *
- * Callback to set the value, within a range, for a single mixer control.
- *
- * Returns 0 for success.
- */
-int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
-                           struct snd_ctl_elem_value *ucontrol)
-{
-       struct soc_mixer_control *mc =
-               (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
-       unsigned int reg = mc->reg;
-       unsigned int rreg = mc->rreg;
-       int max = mc->max - mc->min;
-       unsigned int mask = soc_mixer_mask(mc);
-       unsigned int val_mask = mask << mc->shift;
-       unsigned int val;
-       int err, ret;
-
-       ret = soc_mixer_valid_ctl(mc, ucontrol->value.integer.value[0],
-                                 mc->max - mc->min);
-       if (ret)
-               return ret;
-
-       val = soc_mixer_ctl_to_reg(mc, ucontrol->value.integer.value[0],
-                                  mask, mc->shift, max);
-
-       err = snd_soc_component_update_bits(component, reg, val_mask, val);
-       if (err < 0)
-               return err;
-       ret = err;
-
-       if (snd_soc_volsw_is_stereo(mc)) {
-               ret = soc_mixer_valid_ctl(mc, ucontrol->value.integer.value[1],
-                                         max);
-               if (ret)
-                       return ret;
-
-               val = soc_mixer_ctl_to_reg(mc, ucontrol->value.integer.value[1],
-                                          mask, mc->shift, max);
-
-               err = snd_soc_component_update_bits(component, rreg, val_mask,
-                                                   val);
-               /* Don't discard any error code or drop change flag */
-               if (ret == 0 || err < 0)
-                       ret = err;
-       }
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(snd_soc_put_volsw_range);
-
 static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl)
 {
        struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;
index 3c988925c512f41ef81111edffc8ed657d7eda45..7b0b8531bb32f51ea34722132feda35cc6f67b61 100644 (file)
@@ -132,7 +132,7 @@ static const struct snd_soc_tplg_kcontrol_ops io_ops[] = {
        {SND_SOC_TPLG_CTL_BYTES, snd_soc_bytes_get,
                snd_soc_bytes_put, snd_soc_bytes_info},
        {SND_SOC_TPLG_CTL_RANGE, snd_soc_get_volsw,
-               snd_soc_put_volsw_range, snd_soc_info_volsw},
+               snd_soc_put_volsw, snd_soc_info_volsw},
        {SND_SOC_TPLG_CTL_VOLSW_XR_SX, snd_soc_get_xr_sx,
                snd_soc_put_xr_sx, snd_soc_info_xr_sx},
        {SND_SOC_TPLG_CTL_STROBE, snd_soc_get_strobe,