diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-01-19 15:54:00 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-01-20 08:17:16 +0100 |
commit | 85a9339becf0af4d547ceb6bb16d1893b05fbce4 (patch) | |
tree | 0f25a3def6f9aeca37f942c4aa70b88772a48259 /sound/usb/line6/variax.c | |
parent | 84ac9bb12e8158e1affad4ae7718eb653fa5e36d (diff) | |
download | talos-obmc-linux-85a9339becf0af4d547ceb6bb16d1893b05fbce4.tar.gz talos-obmc-linux-85a9339becf0af4d547ceb6bb16d1893b05fbce4.zip |
ALSA: line6: Reorganize card resource handling
This is a fairly big rewrite regarding the card resource management in
line6 drivers:
- The card creation is moved into line6_probe(). This adds the global
destructor to private_free, so that each driver doesn't have to call
it any longer.
- The USB disconnect callback handles the card release, thus each
driver needs to concentrate on only its own resources. No need to
snd_card_*() call in the destructor.
- Fix the potential stall in disconnection by removing
snd_card_free(). It's replaced with snd_card_free_when_closed()
for asynchronous release.
- The only remaining operation for the card in each driver is the call
of snd_card_register(). All the rest are dealt in the common module
by itself.
- These ended up with removal of audio.[ch] as a result of a reduction
of one layer. Each driver just needs to call line6_probe().
Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/line6/variax.c')
-rw-r--r-- | sound/usb/line6/variax.c | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/sound/usb/line6/variax.c b/sound/usb/line6/variax.c index 9a9c7e48e24f..a591c2c5794f 100644 --- a/sound/usb/line6/variax.c +++ b/sound/usb/line6/variax.c @@ -16,7 +16,6 @@ #include <linux/module.h> #include <sound/core.h> -#include "audio.h" #include "driver.h" #include "usbdefs.h" @@ -179,7 +178,7 @@ static void variax_startup6(struct work_struct *work) CHECK_STARTUP_PROGRESS(variax->startup_progress, VARIAX_STARTUP_SETUP); /* ALSA audio interface: */ - line6_register_audio(&variax->line6); + snd_card_register(variax->line6.card); } /* @@ -211,13 +210,16 @@ static void line6_variax_process_message(struct usb_line6 *line6) /* Variax destructor. */ -static void variax_destruct(struct usb_interface *interface) +static void line6_variax_disconnect(struct usb_interface *interface) { - struct usb_line6_variax *variax = usb_get_intfdata(interface); + struct usb_line6_variax *variax; + + if (!interface) + return; - if (variax == NULL) + variax = usb_get_intfdata(interface); + if (!variax) return; - line6_cleanup_audio(&variax->line6); del_timer(&variax->startup_timer1); del_timer(&variax->startup_timer2); @@ -227,21 +229,10 @@ static void variax_destruct(struct usb_interface *interface) } /* - Workbench device disconnected. -*/ -static void line6_variax_disconnect(struct usb_interface *interface) -{ - if (interface == NULL) - return; - - variax_destruct(interface); -} - -/* Try to init workbench device. */ -static int variax_try_init(struct usb_interface *interface, - struct usb_line6 *line6) +static int variax_init(struct usb_interface *interface, + struct usb_line6 *line6) { struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; int err; @@ -263,11 +254,6 @@ static int variax_try_init(struct usb_interface *interface, if (variax->buffer_activate == NULL) return -ENOMEM; - /* initialize audio system: */ - err = line6_init_audio(&variax->line6); - if (err < 0) - return err; - /* initialize MIDI subsystem: */ err = line6_init_midi(&variax->line6); if (err < 0) @@ -278,20 +264,6 @@ static int variax_try_init(struct usb_interface *interface, return 0; } -/* - Init workbench device (and clean up in case of failure). -*/ -static int variax_init(struct usb_interface *interface, - struct usb_line6 *line6) -{ - int err = variax_try_init(interface, line6); - - if (err < 0) - variax_destruct(interface); - - return err; -} - #define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) #define LINE6_IF_NUM(prod, n) USB_DEVICE_INTERFACE_NUMBER(0x0e41, prod, n) @@ -335,17 +307,13 @@ static int variax_probe(struct usb_interface *interface, const struct usb_device_id *id) { struct usb_line6_variax *variax; - int err; variax = kzalloc(sizeof(*variax), GFP_KERNEL); if (!variax) return -ENODEV; - err = line6_probe(interface, &variax->line6, - &variax_properties_table[id->driver_info], - variax_init); - if (err < 0) - kfree(variax); - return err; + return line6_probe(interface, &variax->line6, + &variax_properties_table[id->driver_info], + variax_init); } static struct usb_driver variax_driver = { |