@@ -325,7 +325,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
325325 if (ucontrol -> value .integer .value [0 ] < 0 )
326326 return - EINVAL ;
327327 val = ucontrol -> value .integer .value [0 ];
328- if (mc -> platform_max && (( int ) val + min ) > mc -> platform_max )
328+ if (mc -> platform_max && val > mc -> platform_max )
329329 return - EINVAL ;
330330 if (val > max - min )
331331 return - EINVAL ;
@@ -338,7 +338,7 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
338338 if (ucontrol -> value .integer .value [1 ] < 0 )
339339 return - EINVAL ;
340340 val2 = ucontrol -> value .integer .value [1 ];
341- if (mc -> platform_max && (( int ) val2 + min ) > mc -> platform_max )
341+ if (mc -> platform_max && val2 > mc -> platform_max )
342342 return - EINVAL ;
343343 if (val2 > max - min )
344344 return - EINVAL ;
@@ -491,17 +491,16 @@ int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
491491{
492492 struct soc_mixer_control * mc =
493493 (struct soc_mixer_control * )kcontrol -> private_value ;
494- int platform_max ;
495- int min = mc -> min ;
494+ int max ;
496495
497- if (! mc -> platform_max )
498- mc -> platform_max = mc -> max ;
499- platform_max = mc -> platform_max ;
496+ max = mc -> max - mc -> min ;
497+ if ( mc -> platform_max && mc -> platform_max < max )
498+ max = mc -> platform_max ;
500499
501500 uinfo -> type = SNDRV_CTL_ELEM_TYPE_INTEGER ;
502501 uinfo -> count = snd_soc_volsw_is_stereo (mc ) ? 2 : 1 ;
503502 uinfo -> value .integer .min = 0 ;
504- uinfo -> value .integer .max = platform_max - min ;
503+ uinfo -> value .integer .max = max ;
505504
506505 return 0 ;
507506}
0 commit comments