Skip to content

Commit 7d5df96

Browse files
charleskeepaxbroonie
authored andcommitted
ASoC: ops: Remove snd_soc_put_volsw_range()
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>
1 parent fd74425 commit 7d5df96

File tree

4 files changed

+9
-67
lines changed

4 files changed

+9
-67
lines changed

include/sound/soc.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct platform_device;
6666
#define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
6767
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
6868
.info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
69-
.put = snd_soc_put_volsw_range, \
69+
.put = snd_soc_put_volsw, \
7070
.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, 0) }
7171
#define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
7272
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
@@ -91,7 +91,7 @@ struct platform_device;
9191
SNDRV_CTL_ELEM_ACCESS_READWRITE,\
9292
.tlv.p = (tlv_array), \
9393
.info = snd_soc_info_volsw, \
94-
.get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
94+
.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
9595
.private_value = SOC_SINGLE_VALUE(xreg, xshift, xmin, xmax, xinvert, 0) }
9696
#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
9797
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
@@ -117,7 +117,7 @@ struct platform_device;
117117
xmax, xinvert) \
118118
{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
119119
.info = snd_soc_info_volsw, \
120-
.get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
120+
.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
121121
.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, \
122122
xshift, xmin, xmax, xinvert) }
123123
#define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
@@ -165,7 +165,7 @@ struct platform_device;
165165
SNDRV_CTL_ELEM_ACCESS_READWRITE,\
166166
.tlv.p = (tlv_array), \
167167
.info = snd_soc_info_volsw, \
168-
.get = snd_soc_get_volsw, .put = snd_soc_put_volsw_range, \
168+
.get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
169169
.private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, \
170170
xshift, xmin, xmax, xinvert) }
171171
#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,
569569
struct snd_ctl_elem_value *ucontrol);
570570
int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
571571
struct snd_ctl_elem_value *ucontrol);
572-
int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
573-
struct snd_ctl_elem_value *ucontrol);
574572
int snd_soc_limit_volume(struct snd_soc_card *card,
575573
const char *name, int max);
576574
int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,

sound/soc/codecs/wm5110.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static int wm5110_in_pga_put(struct snd_kcontrol *kcontrol,
497497
*/
498498
snd_soc_dapm_mutex_lock(dapm);
499499

500-
ret = snd_soc_put_volsw_range(kcontrol, ucontrol);
500+
ret = snd_soc_put_volsw(kcontrol, ucontrol);
501501

502502
snd_soc_dapm_mutex_unlock(dapm);
503503

sound/soc/soc-ops.c

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,12 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
289289
EXPORT_SYMBOL_GPL(snd_soc_get_volsw);
290290

291291
/**
292-
* snd_soc_put_volsw - single mixer put callback
292+
* snd_soc_put_volsw - single mixer put callback with range
293293
* @kcontrol: mixer control
294294
* @ucontrol: control element information
295295
*
296-
* Callback to set the value of a single mixer control, or a double mixer
297-
* control that spans 2 registers.
296+
* Callback to set the value , within a range, of a single mixer control, or
297+
* a double mixer control that spans 2 registers.
298298
*
299299
* Returns 0 for success.
300300
*/
@@ -450,62 +450,6 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
450450
}
451451
EXPORT_SYMBOL_GPL(snd_soc_put_volsw_sx);
452452

453-
/**
454-
* snd_soc_put_volsw_range - single mixer put value callback with range.
455-
* @kcontrol: mixer control
456-
* @ucontrol: control element information
457-
*
458-
* Callback to set the value, within a range, for a single mixer control.
459-
*
460-
* Returns 0 for success.
461-
*/
462-
int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
463-
struct snd_ctl_elem_value *ucontrol)
464-
{
465-
struct soc_mixer_control *mc =
466-
(struct soc_mixer_control *)kcontrol->private_value;
467-
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
468-
unsigned int reg = mc->reg;
469-
unsigned int rreg = mc->rreg;
470-
int max = mc->max - mc->min;
471-
unsigned int mask = soc_mixer_mask(mc);
472-
unsigned int val_mask = mask << mc->shift;
473-
unsigned int val;
474-
int err, ret;
475-
476-
ret = soc_mixer_valid_ctl(mc, ucontrol->value.integer.value[0],
477-
mc->max - mc->min);
478-
if (ret)
479-
return ret;
480-
481-
val = soc_mixer_ctl_to_reg(mc, ucontrol->value.integer.value[0],
482-
mask, mc->shift, max);
483-
484-
err = snd_soc_component_update_bits(component, reg, val_mask, val);
485-
if (err < 0)
486-
return err;
487-
ret = err;
488-
489-
if (snd_soc_volsw_is_stereo(mc)) {
490-
ret = soc_mixer_valid_ctl(mc, ucontrol->value.integer.value[1],
491-
max);
492-
if (ret)
493-
return ret;
494-
495-
val = soc_mixer_ctl_to_reg(mc, ucontrol->value.integer.value[1],
496-
mask, mc->shift, max);
497-
498-
err = snd_soc_component_update_bits(component, rreg, val_mask,
499-
val);
500-
/* Don't discard any error code or drop change flag */
501-
if (ret == 0 || err < 0)
502-
ret = err;
503-
}
504-
505-
return ret;
506-
}
507-
EXPORT_SYMBOL_GPL(snd_soc_put_volsw_range);
508-
509453
static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl)
510454
{
511455
struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;

sound/soc/soc-topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static const struct snd_soc_tplg_kcontrol_ops io_ops[] = {
132132
{SND_SOC_TPLG_CTL_BYTES, snd_soc_bytes_get,
133133
snd_soc_bytes_put, snd_soc_bytes_info},
134134
{SND_SOC_TPLG_CTL_RANGE, snd_soc_get_volsw,
135-
snd_soc_put_volsw_range, snd_soc_info_volsw},
135+
snd_soc_put_volsw, snd_soc_info_volsw},
136136
{SND_SOC_TPLG_CTL_VOLSW_XR_SX, snd_soc_get_xr_sx,
137137
snd_soc_put_xr_sx, snd_soc_info_xr_sx},
138138
{SND_SOC_TPLG_CTL_STROBE, snd_soc_get_strobe,

0 commit comments

Comments
 (0)