summaryrefslogtreecommitdiff
path: root/sound/usb/usbaudio.h
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/usbaudio.h')
-rw-r--r--sound/usb/usbaudio.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index 158ec053dc44..7521098ba391 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -139,6 +139,29 @@ struct snd_usb_audio_quirk {
int snd_usb_lock_shutdown(struct snd_usb_audio *chip);
void snd_usb_unlock_shutdown(struct snd_usb_audio *chip);
+/* auto-cleanup */
+struct __snd_usb_lock {
+ struct snd_usb_audio *chip;
+ int err;
+};
+
+static inline struct __snd_usb_lock __snd_usb_lock_shutdown(struct snd_usb_audio *chip)
+{
+ struct __snd_usb_lock T = { .chip = chip };
+ T.err = snd_usb_lock_shutdown(chip);
+ return T;
+}
+
+static inline void __snd_usb_unlock_shutdown(struct __snd_usb_lock *lock)
+{
+ if (!lock->err)
+ snd_usb_unlock_shutdown(lock->chip);
+}
+
+DEFINE_CLASS(snd_usb_lock, struct __snd_usb_lock,
+ __snd_usb_unlock_shutdown(&(_T)), __snd_usb_lock_shutdown(chip),
+ struct snd_usb_audio *chip)
+
extern bool snd_usb_use_vmalloc;
extern bool snd_usb_skip_validation;