Skip to content

Commit da42bcb

Browse files
committed
ALSA: hda/tas2781: Use standard clamp() macro
Instead of the home-made clamp() function, use the standard macro(). Fixes: 5be27f1 ("ALSA: hda/tas2781: Add tas2781 HDA driver") Link: https://lore.kernel.org/r/20230831123620.23064-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 358040e commit da42bcb

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

sound/pci/hda/tas2781_hda_i2c.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,6 @@ static int tasdevice_get_profile_id(struct snd_kcontrol *kcontrol,
173173
return 0;
174174
}
175175

176-
static int tasdevice_hda_clamp(int val, int max)
177-
{
178-
if (val > max)
179-
val = max;
180-
181-
if (val < 0)
182-
val = 0;
183-
return val;
184-
}
185-
186176
static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol,
187177
struct snd_ctl_elem_value *ucontrol)
188178
{
@@ -191,7 +181,7 @@ static int tasdevice_set_profile_id(struct snd_kcontrol *kcontrol,
191181
int max = tas_priv->rcabin.ncfgs - 1;
192182
int val, ret = 0;
193183

194-
val = tasdevice_hda_clamp(nr_profile, max);
184+
val = clamp(nr_profile, 0, max);
195185

196186
if (tas_priv->rcabin.profile_cfg_id != val) {
197187
tas_priv->rcabin.profile_cfg_id = val;
@@ -248,7 +238,7 @@ static int tasdevice_program_put(struct snd_kcontrol *kcontrol,
248238
int max = tas_fw->nr_programs - 1;
249239
int val, ret = 0;
250240

251-
val = tasdevice_hda_clamp(nr_program, max);
241+
val = clamp(nr_program, 0, max);
252242

253243
if (tas_priv->cur_prog != val) {
254244
tas_priv->cur_prog = val;
@@ -277,7 +267,7 @@ static int tasdevice_config_put(struct snd_kcontrol *kcontrol,
277267
int max = tas_fw->nr_configurations - 1;
278268
int val, ret = 0;
279269

280-
val = tasdevice_hda_clamp(nr_config, max);
270+
val = clamp(nr_config, 0, max);
281271

282272
if (tas_priv->cur_conf != val) {
283273
tas_priv->cur_conf = val;

0 commit comments

Comments
 (0)