Skip to content

Commit 839284e

Browse files
Tzung-Bi Shihbroonie
authored andcommitted
ASoC: dapm: add snd_soc_dapm_put_enum_double_locked
Adds snd_soc_dapm_put_enum_double_locked() for those use cases if dapm_mutex has already locked. Signed-off-by: Tzung-Bi Shih <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 08df0d9 commit 839284e

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

include/sound/soc-dapm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
392392
struct snd_ctl_elem_value *ucontrol);
393393
int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
394394
struct snd_ctl_elem_value *ucontrol);
395+
int snd_soc_dapm_put_enum_double_locked(struct snd_kcontrol *kcontrol,
396+
struct snd_ctl_elem_value *ucontrol);
395397
int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol,
396398
struct snd_ctl_elem_info *uinfo);
397399
int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,

sound/soc/soc-dapm.c

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,17 +3441,8 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
34413441
}
34423442
EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double);
34433443

3444-
/**
3445-
* snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
3446-
* @kcontrol: mixer control
3447-
* @ucontrol: control element information
3448-
*
3449-
* Callback to set the value of a dapm enumerated double mixer control.
3450-
*
3451-
* Returns 0 for success.
3452-
*/
3453-
int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
3454-
struct snd_ctl_elem_value *ucontrol)
3444+
static int __snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
3445+
struct snd_ctl_elem_value *ucontrol, int locked)
34553446
{
34563447
struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol);
34573448
struct snd_soc_card *card = dapm->card;
@@ -3474,7 +3465,9 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
34743465
mask |= e->mask << e->shift_r;
34753466
}
34763467

3477-
mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3468+
if (!locked)
3469+
mutex_lock_nested(&card->dapm_mutex,
3470+
SND_SOC_DAPM_CLASS_RUNTIME);
34783471

34793472
change = dapm_kcontrol_set_value(kcontrol, val);
34803473

@@ -3496,15 +3489,50 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
34963489
card->update = NULL;
34973490
}
34983491

3499-
mutex_unlock(&card->dapm_mutex);
3492+
if (!locked)
3493+
mutex_unlock(&card->dapm_mutex);
35003494

35013495
if (ret > 0)
35023496
soc_dpcm_runtime_update(card);
35033497

35043498
return change;
35053499
}
3500+
3501+
/**
3502+
* snd_soc_dapm_put_enum_double - dapm enumerated double mixer set callback
3503+
* @kcontrol: mixer control
3504+
* @ucontrol: control element information
3505+
*
3506+
* Callback to set the value of a dapm enumerated double mixer control.
3507+
*
3508+
* Returns 0 for success.
3509+
*/
3510+
int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
3511+
struct snd_ctl_elem_value *ucontrol)
3512+
{
3513+
return __snd_soc_dapm_put_enum_double(kcontrol, ucontrol, 0);
3514+
}
35063515
EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double);
35073516

3517+
/**
3518+
* snd_soc_dapm_put_enum_double_locked - dapm enumerated double mixer set
3519+
* callback
3520+
* @kcontrol: mixer control
3521+
* @ucontrol: control element information
3522+
*
3523+
* Callback to set the value of a dapm enumerated double mixer control.
3524+
* Must acquire dapm_mutex before calling the function.
3525+
*
3526+
* Returns 0 for success.
3527+
*/
3528+
int snd_soc_dapm_put_enum_double_locked(struct snd_kcontrol *kcontrol,
3529+
struct snd_ctl_elem_value *ucontrol)
3530+
{
3531+
dapm_assert_locked(snd_soc_dapm_kcontrol_dapm(kcontrol));
3532+
return __snd_soc_dapm_put_enum_double(kcontrol, ucontrol, 1);
3533+
}
3534+
EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double_locked);
3535+
35083536
/**
35093537
* snd_soc_dapm_info_pin_switch - Info for a pin switch
35103538
*

0 commit comments

Comments
 (0)