lkml.org 
[lkml]   [2019]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH 3.16 254/305] ALSA: usb-audio: Replace probing flag with active refcount
3.16.63-rc1 review patch.  If anyone has any objections, please let me know.

------------------

From: Takashi Iwai <tiwai@suse.de>

commit a6da499b76b1a75412f047ac388e9ffd69a5c55b upstream.

We can use active refcount for preventing autopm during probe.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
sound/usb/card.c | 12 ++++--------
sound/usb/usbaudio.h | 1 -
2 files changed, 4 insertions(+), 9 deletions(-)

--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -402,7 +402,7 @@ static int snd_usb_audio_create(struct u
chip->card = card;
chip->setup = device_setup[idx];
chip->autoclock = autoclock;
- chip->probing = 1;
+ atomic_set(&chip->active, 1); /* avoid autopm during probing */
atomic_set(&chip->usage_count, 0);
atomic_set(&chip->shutdown, 0);

@@ -532,7 +532,7 @@ snd_usb_audio_probe(struct usb_device *d
goto __error;
}
chip = usb_chip[i];
- chip->probing = 1;
+ atomic_inc(&chip->active); /* avoid autopm */
break;
}
}
@@ -588,7 +588,7 @@ snd_usb_audio_probe(struct usb_device *d

usb_chip[chip->index] = chip;
chip->num_interfaces++;
- chip->probing = 0;
+ atomic_dec(&chip->active);
mutex_unlock(&register_mutex);
return chip;

@@ -596,7 +596,7 @@ snd_usb_audio_probe(struct usb_device *d
if (chip) {
if (!chip->num_interfaces)
snd_card_free(chip->card);
- chip->probing = 0;
+ atomic_dec(&chip->active);
}
mutex_unlock(&register_mutex);
__err_val:
@@ -712,8 +712,6 @@ int snd_usb_autoresume(struct snd_usb_au
{
if (atomic_read(&chip->shutdown))
return -EIO;
- if (chip->probing)
- return 0;
if (atomic_inc_return(&chip->active) == 1)
return usb_autopm_get_interface(chip->pm_intf);
return 0;
@@ -721,8 +719,6 @@ int snd_usb_autoresume(struct snd_usb_au

void snd_usb_autosuspend(struct snd_usb_audio *chip)
{
- if (chip->probing)
- return;
if (atomic_dec_and_test(&chip->active))
usb_autopm_put_interface(chip->pm_intf);
}
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -37,7 +37,6 @@ struct snd_usb_audio {
struct usb_interface *pm_intf;
u32 usb_id;
struct mutex mutex;
- unsigned int probing:1;
unsigned int autosuspended:1;
atomic_t active;
atomic_t shutdown;
\
 
 \ /
  Last update: 2019-02-03 14:54    [W:0.700 / U:6.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site