diff mbox

[RFC,2/4] alsa: add locked variant for snd_ctl_remove_id

Message ID 1455538772-24926-3-git-send-email-vaibhav.agarwal@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Vaibhav Agarwal Feb. 15, 2016, 12:19 p.m. UTC
While removing kcontrols due to dynamic dai_link/codec removal,
mutex/semaphore for soc-card/sound card is already acquired.
Thus, added lock already acquired variant for ctl_remove_id.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
---
 include/sound/control.h |  1 +
 sound/core/control.c    | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)

Comments

Mark Brown Feb. 15, 2016, 2:02 p.m. UTC | #1
On Mon, Feb 15, 2016 at 05:49:30PM +0530, Vaibhav Agarwal wrote:
> While removing kcontrols due to dynamic dai_link/codec removal,
> mutex/semaphore for soc-card/sound card is already acquired.
> Thus, added lock already acquired variant for ctl_remove_id.

Please use subject lines matching the style for the subsystem and
remember to CC maintainers on patch submission.
Vaibhav Agarwal Feb. 16, 2016, 1:54 p.m. UTC | #2
+Takashi

On 15 February 2016 at 19:32, Mark Brown <broonie@kernel.org> wrote:
> On Mon, Feb 15, 2016 at 05:49:30PM +0530, Vaibhav Agarwal wrote:
>> While removing kcontrols due to dynamic dai_link/codec removal,
>> mutex/semaphore for soc-card/sound card is already acquired.
>> Thus, added lock already acquired variant for ctl_remove_id.
>
> Please use subject lines matching the style for the subsystem and
> remember to CC maintainers on patch submission.
 Sure, will follow the convention for subject lines as well.
Takashi Iwai Feb. 16, 2016, 2:13 p.m. UTC | #3
On Tue, 16 Feb 2016 14:54:57 +0100,
Vaibhav Agarwal wrote:
> 
> +Takashi
> 
> On 15 February 2016 at 19:32, Mark Brown <broonie@kernel.org> wrote:
> > On Mon, Feb 15, 2016 at 05:49:30PM +0530, Vaibhav Agarwal wrote:
> >> While removing kcontrols due to dynamic dai_link/codec removal,
> >> mutex/semaphore for soc-card/sound card is already acquired.
> >> Thus, added lock already acquired variant for ctl_remove_id.
> >
> > Please use subject lines matching the style for the subsystem and
> > remember to CC maintainers on patch submission.
>  Sure, will follow the convention for subject lines as well.

I prefer reducing snd_ctl_remove_id() as well.  Just wrap the call of
the unlocked one with down/up_write().


Takashi
Vaibhav Agarwal Feb. 16, 2016, 2:15 p.m. UTC | #4
On 16 February 2016 at 19:43, Takashi Iwai <tiwai@suse.de> wrote:
> On Tue, 16 Feb 2016 14:54:57 +0100,
> Vaibhav Agarwal wrote:
>>
>> +Takashi
>>
>> On 15 February 2016 at 19:32, Mark Brown <broonie@kernel.org> wrote:
>> > On Mon, Feb 15, 2016 at 05:49:30PM +0530, Vaibhav Agarwal wrote:
>> >> While removing kcontrols due to dynamic dai_link/codec removal,
>> >> mutex/semaphore for soc-card/sound card is already acquired.
>> >> Thus, added lock already acquired variant for ctl_remove_id.
>> >
>> > Please use subject lines matching the style for the subsystem and
>> > remember to CC maintainers on patch submission.
>>  Sure, will follow the convention for subject lines as well.
>
> I prefer reducing snd_ctl_remove_id() as well.  Just wrap the call of
> the unlocked one with down/up_write().
Sure, will make the change in next patchset.
>
>
> Takashi
diff mbox

Patch

diff --git a/include/sound/control.h b/include/sound/control.h
index 21d047f..8faea10 100644
--- a/include/sound/control.h
+++ b/include/sound/control.h
@@ -125,6 +125,7 @@  int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol);
 int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol);
 int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, bool add_on_replace);
 int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id);
+int snd_ctl_remove_id_locked(struct snd_card *card, struct snd_ctl_elem_id *id);
 int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id);
 int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
 			int active);
diff --git a/sound/core/control.c b/sound/core/control.c
index a85d455..dca1998 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -530,6 +530,29 @@  int snd_ctl_remove_id(struct snd_card *card, struct snd_ctl_elem_id *id)
 EXPORT_SYMBOL(snd_ctl_remove_id);
 
 /**
+ * snd_ctl_remove_id_locked - remove the control of the given id and release it
+ * @card: the card instance
+ * @id: the control id to remove
+ *
+ * Finds the control instance with the given id, removes it from the
+ * card list and releases it.
+ *
+ * Return: 0 if successful, or a negative error code on failure.
+ */
+int snd_ctl_remove_id_locked(struct snd_card *card, struct snd_ctl_elem_id *id)
+{
+	struct snd_kcontrol *kctl;
+	int ret;
+
+	kctl = snd_ctl_find_id(card, id);
+	if (kctl == NULL)
+		return -ENOENT;
+	ret = snd_ctl_remove(card, kctl);
+	return ret;
+}
+EXPORT_SYMBOL(snd_ctl_remove_id_locked);
+
+/**
  * snd_ctl_remove_user_ctl - remove and release the unlocked user control
  * @file: active control handle
  * @id: the control id to remove