From 85a9339becf0af4d547ceb6bb16d1893b05fbce4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Jan 2015 15:54:00 +0100 Subject: 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 Signed-off-by: Takashi Iwai --- sound/usb/line6/podhd.c | 75 +++++-------------------------------------------- 1 file changed, 7 insertions(+), 68 deletions(-) (limited to 'sound/usb/line6/podhd.c') diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c index 8f4ca1d20b62..1d11185780e3 100644 --- a/sound/usb/line6/podhd.c +++ b/sound/usb/line6/podhd.c @@ -15,7 +15,6 @@ #include #include -#include "audio.h" #include "driver.h" #include "pcm.h" #include "usbdefs.h" @@ -85,58 +84,18 @@ static struct line6_pcm_properties podhd_pcm_properties = { .bytes_per_frame = PODHD_BYTES_PER_FRAME }; -/* - POD HD destructor. -*/ -static void podhd_destruct(struct usb_interface *interface) -{ - struct usb_line6_podhd *podhd = usb_get_intfdata(interface); - - if (podhd == NULL) - return; - line6_cleanup_audio(&podhd->line6); -} - -/* - POD HD device disconnected. -*/ -static void line6_podhd_disconnect(struct usb_interface *interface) -{ - struct usb_line6_podhd *podhd; - - if (interface == NULL) - return; - podhd = usb_get_intfdata(interface); - - if (podhd != NULL) { - struct snd_line6_pcm *line6pcm = podhd->line6.line6pcm; - - if (line6pcm != NULL) - line6_pcm_disconnect(line6pcm); - } - - podhd_destruct(interface); -} - /* Try to init POD HD device. */ -static int podhd_try_init(struct usb_interface *interface, - struct usb_line6_podhd *podhd) +static int podhd_init(struct usb_interface *interface, + struct usb_line6 *line6) { + struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6; int err; - struct usb_line6 *line6 = &podhd->line6; if ((interface == NULL) || (podhd == NULL)) return -ENODEV; - line6->disconnect = line6_podhd_disconnect; - - /* initialize audio system: */ - err = line6_init_audio(line6); - if (err < 0) - return err; - /* initialize MIDI subsystem: */ err = line6_init_midi(line6); if (err < 0) @@ -148,8 +107,7 @@ static int podhd_try_init(struct usb_interface *interface, return err; /* register USB audio system: */ - err = line6_register_audio(line6); - return err; + return snd_card_register(line6->card); } #define LINE6_DEVICE(prod) USB_DEVICE(0x0e41, prod) @@ -217,21 +175,6 @@ static const struct line6_properties podhd_properties_table[] = { }, }; -/* - Init POD HD device (and clean up in case of failure). -*/ -static int podhd_init(struct usb_interface *interface, - struct usb_line6 *line6) -{ - struct usb_line6_podhd *podhd = (struct usb_line6_podhd *) line6; - int err = podhd_try_init(interface, podhd); - - if (err < 0) - podhd_destruct(interface); - - return err; -} - /* Probe USB device. */ @@ -239,17 +182,13 @@ static int podhd_probe(struct usb_interface *interface, const struct usb_device_id *id) { struct usb_line6_podhd *podhd; - int err; podhd = kzalloc(sizeof(*podhd), GFP_KERNEL); if (!podhd) return -ENODEV; - err = line6_probe(interface, &podhd->line6, - &podhd_properties_table[id->driver_info], - podhd_init); - if (err < 0) - kfree(podhd); - return err; + return line6_probe(interface, &podhd->line6, + &podhd_properties_table[id->driver_info], + podhd_init); } static struct usb_driver podhd_driver = { -- cgit v1.2.3