#define PODHD_STARTUP_DELAY 500
-/*
- * Stages of POD startup procedure
- */
-enum {
- PODHD_STARTUP_INIT = 1,
- PODHD_STARTUP_SCHEDULE_WORKQUEUE,
- PODHD_STARTUP_SETUP,
- PODHD_STARTUP_LAST = PODHD_STARTUP_SETUP - 1
-};
-
enum {
LINE6_PODHD300,
LINE6_PODHD400,
/* Generic Line 6 USB data */
struct usb_line6 line6;
- /* Timer for device initialization */
- struct timer_list startup_timer;
-
- /* Work handler for device initialization */
- struct work_struct startup_work;
-
- /* Current progress in startup procedure */
- int startup_progress;
-
/* Serial number of device */
u32 serial_number;
};
static struct usb_driver podhd_driver;
-static void podhd_startup_start_workqueue(struct timer_list *t);
-static void podhd_startup_workqueue(struct work_struct *work);
-static int podhd_startup_finalize(struct usb_line6_podhd *pod);
-
static ssize_t serial_number_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
* audio nor bulk interfaces to work.
*/
-static void podhd_startup(struct usb_line6_podhd *pod)
-{
- CHECK_STARTUP_PROGRESS(pod->startup_progress, PODHD_STARTUP_INIT);
-
- /* delay startup procedure: */
- line6_start_timer(&pod->startup_timer, PODHD_STARTUP_DELAY,
- podhd_startup_start_workqueue);
-}
-
-static void podhd_startup_start_workqueue(struct timer_list *t)
-{
- struct usb_line6_podhd *pod = from_timer(pod, t, startup_timer);
-
- CHECK_STARTUP_PROGRESS(pod->startup_progress,
- PODHD_STARTUP_SCHEDULE_WORKQUEUE);
-
- /* schedule work for global work queue: */
- schedule_work(&pod->startup_work);
-}
-
static int podhd_dev_start(struct usb_line6_podhd *pod)
{
int ret;
return ret;
}
-static void podhd_startup_workqueue(struct work_struct *work)
+static void podhd_startup(struct usb_line6 *line6)
{
- struct usb_line6_podhd *pod =
- container_of(work, struct usb_line6_podhd, startup_work);
-
- CHECK_STARTUP_PROGRESS(pod->startup_progress, PODHD_STARTUP_SETUP);
+ struct usb_line6_podhd *pod = (struct usb_line6_podhd *)line6;
podhd_dev_start(pod);
line6_read_serial_number(&pod->line6, &pod->serial_number);
-
- podhd_startup_finalize(pod);
-}
-
-static int podhd_startup_finalize(struct usb_line6_podhd *pod)
-{
- struct usb_line6 *line6 = &pod->line6;
-
- /* ALSA audio interface: */
- return snd_card_register(line6->card);
+ if (snd_card_register(line6->card))
+ dev_err(line6->ifcdev, "Failed to register POD HD card.\n");
}
static void podhd_disconnect(struct usb_line6 *line6)
if (pod->line6.properties->capabilities & LINE6_CAP_CONTROL_INFO) {
struct usb_interface *intf;
- del_timer_sync(&pod->startup_timer);
- cancel_work_sync(&pod->startup_work);
-
intf = usb_ifnum_to_if(line6->usbdev,
pod->line6.properties->ctrl_if);
if (intf)
struct usb_interface *intf;
line6->disconnect = podhd_disconnect;
-
- timer_setup(&pod->startup_timer, NULL, 0);
- INIT_WORK(&pod->startup_work, podhd_startup_workqueue);
+ line6->startup = podhd_startup;
if (pod->line6.properties->capabilities & LINE6_CAP_CONTROL) {
/* claim the data interface */
if (!(pod->line6.properties->capabilities & LINE6_CAP_CONTROL_INFO)) {
/* register USB audio system directly */
- return podhd_startup_finalize(pod);
+ return snd_card_register(line6->card);
}
/* init device and delay registering */
- podhd_startup(pod);
+ schedule_delayed_work(&line6->startup_work,
+ msecs_to_jiffies(PODHD_STARTUP_DELAY));
return 0;
}