summaryrefslogtreecommitdiff
path: root/sound/usb/line6/podhd.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-01-19 14:54:00 (GMT)
committerTakashi Iwai <tiwai@suse.de>2015-01-20 07:17:16 (GMT)
commit85a9339becf0af4d547ceb6bb16d1893b05fbce4 (patch)
tree0f25a3def6f9aeca37f942c4aa70b88772a48259 /sound/usb/line6/podhd.c
parent84ac9bb12e8158e1affad4ae7718eb653fa5e36d (diff)
downloadlinux-85a9339becf0af4d547ceb6bb16d1893b05fbce4.tar.xz
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/podhd.c')
-rw-r--r--sound/usb/line6/podhd.c75
1 files changed, 7 insertions, 68 deletions
diff --git a/sound/usb/line6/podhd.c b/sound/usb/line6/podhd.c
index 8f4ca1d..1d11185 100644
--- a/sound/usb/line6/podhd.c
+++ b/sound/usb/line6/podhd.c
@@ -15,7 +15,6 @@
#include <sound/core.h>
#include <sound/pcm.h>
-#include "audio.h"
#include "driver.h"
#include "pcm.h"
#include "usbdefs.h"
@@ -86,57 +85,17 @@ static struct line6_pcm_properties podhd_pcm_properties = {
};
/*
- 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)
@@ -218,38 +176,19 @@ 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.
*/
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 = {