mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 00:20:32 +00:00
ASoC: ops: Don't modify the driver's plaform_max when reading state
Currently snd_soc_info_volsw() will set a platform_max based on the limit the control has if one is not already set. This isn't really great, we shouldn't be modifying the passed in driver data especially in a path like this which may not ever be executed or where we may execute other callbacks before this one. Instead make this function leave the data unchanged, and clarify things a bit by referring to max rather than platform_max within the function. platform_max is now applied as a limit after working out the natural maximum value for the control. This means that platform_max is no longer treated as a direct register value for controls were min is non-zero. The put() callbacks already validate on this basis, and there do not appear to be any in tree users that would be affected. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20220603112508.3856519-1-broonie@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
14cc584912
commit
30ac498413
1 changed files with 7 additions and 6 deletions
|
@ -176,20 +176,21 @@ int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
|
||||||
{
|
{
|
||||||
struct soc_mixer_control *mc =
|
struct soc_mixer_control *mc =
|
||||||
(struct soc_mixer_control *)kcontrol->private_value;
|
(struct soc_mixer_control *)kcontrol->private_value;
|
||||||
int platform_max;
|
int max;
|
||||||
|
|
||||||
if (!mc->platform_max)
|
max = uinfo->value.integer.max = mc->max - mc->min;
|
||||||
mc->platform_max = mc->max;
|
if (mc->platform_max && mc->platform_max < max)
|
||||||
platform_max = mc->platform_max;
|
max = mc->platform_max;
|
||||||
|
|
||||||
if (platform_max == 1 && !strstr(kcontrol->id.name, " Volume"))
|
if (max == 1 && !strstr(kcontrol->id.name, " Volume"))
|
||||||
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
|
||||||
else
|
else
|
||||||
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
||||||
|
|
||||||
uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
|
uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
|
||||||
uinfo->value.integer.min = 0;
|
uinfo->value.integer.min = 0;
|
||||||
uinfo->value.integer.max = platform_max - mc->min;
|
uinfo->value.integer.max = max;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
|
EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
|
||||||
|
|
Loading…
Reference in a new issue