summaryrefslogtreecommitdiff
path: root/sound/usb/line6/pod.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-01-19 15:54:00 +0100
committerTakashi Iwai <tiwai@suse.de>2015-01-20 08:17:16 +0100
commit85a9339becf0af4d547ceb6bb16d1893b05fbce4 (patch)
tree0f25a3def6f9aeca37f942c4aa70b88772a48259 /sound/usb/line6/pod.c
parent84ac9bb12e8158e1affad4ae7718eb653fa5e36d (diff)
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/pod.c')
-rw-r--r--sound/usb/line6/pod.c60
1 files changed, 9 insertions, 51 deletions
diff --git a/sound/usb/line6/pod.c b/sound/usb/line6/pod.c
index d6bc5a1ab7f4..6b30deb6b157 100644
--- a/sound/usb/line6/pod.c
+++ b/sound/usb/line6/pod.c
@@ -18,7 +18,6 @@
#include <sound/core.h>
#include <sound/control.h>
-#include "audio.h"
#include "capture.h"
#include "driver.h"
#include "playback.h"
@@ -340,7 +339,7 @@ static void pod_startup4(struct work_struct *work)
line6_read_serial_number(&pod->line6, &pod->serial_number);
/* ALSA audio interface: */
- line6_register_audio(line6);
+ snd_card_register(line6->card);
}
/* POD special files: */
@@ -398,21 +397,6 @@ static struct snd_kcontrol_new pod_control_monitor = {
};
/*
- POD destructor.
-*/
-static void pod_destruct(struct usb_interface *interface)
-{
- struct usb_line6_pod *pod = usb_get_intfdata(interface);
-
- if (pod == NULL)
- return;
- line6_cleanup_audio(&pod->line6);
-
- del_timer(&pod->startup_timer);
- cancel_work_sync(&pod->startup_work);
-}
-
-/*
POD device disconnected.
*/
static void line6_pod_disconnect(struct usb_interface *interface)
@@ -424,21 +408,18 @@ static void line6_pod_disconnect(struct usb_interface *interface)
pod = usb_get_intfdata(interface);
if (pod != NULL) {
- struct snd_line6_pcm *line6pcm = pod->line6.line6pcm;
struct device *dev = &interface->dev;
- if (line6pcm != NULL)
- line6_pcm_disconnect(line6pcm);
-
if (dev != NULL) {
/* remove sysfs entries: */
device_remove_file(dev, &dev_attr_device_id);
device_remove_file(dev, &dev_attr_firmware_version);
device_remove_file(dev, &dev_attr_serial_number);
}
- }
- pod_destruct(interface);
+ del_timer_sync(&pod->startup_timer);
+ cancel_work_sync(&pod->startup_work);
+ }
}
/*
@@ -457,8 +438,8 @@ static int pod_create_files2(struct device *dev)
/*
Try to init POD device.
*/
-static int pod_try_init(struct usb_interface *interface,
- struct usb_line6 *line6)
+static int pod_init(struct usb_interface *interface,
+ struct usb_line6 *line6)
{
int err;
struct usb_line6_pod *pod = (struct usb_line6_pod *) line6;
@@ -477,11 +458,6 @@ static int pod_try_init(struct usb_interface *interface,
if (err < 0)
return err;
- /* initialize audio system: */
- err = line6_init_audio(line6);
- if (err < 0)
- return err;
-
/* initialize MIDI subsystem: */
err = line6_init_midi(line6);
if (err < 0)
@@ -514,20 +490,6 @@ static int pod_try_init(struct usb_interface *interface,
return 0;
}
-/*
- Init POD device (and clean up in case of failure).
-*/
-static int pod_init(struct usb_interface *interface,
- struct usb_line6 *line6)
-{
- int err = pod_try_init(interface, line6);
-
- if (err < 0)
- pod_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)
@@ -636,17 +598,13 @@ static int pod_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
struct usb_line6_pod *pod;
- int err;
pod = kzalloc(sizeof(*pod), GFP_KERNEL);
if (!pod)
return -ENODEV;
- err = line6_probe(interface, &pod->line6,
- &pod_properties_table[id->driver_info],
- pod_init);
- if (err < 0)
- kfree(pod);
- return err;
+ return line6_probe(interface, &pod->line6,
+ &pod_properties_table[id->driver_info],
+ pod_init);
}
static struct usb_driver pod_driver = {