Commit f66fd990 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: line6: Drop interface argument from private_init and disconnect callbacks

The interface argument is used just for retrieving the assigned
device, which can be already found in line6->ifcdev.  Drop them from
the callbacks.  Also, pass the usb id to private_init so that the
driver can deal with it there.  This is a preliminary work for the
further cleanup to move the whole allocation into driver.c.
Tested-by: default avatarChris Rorvick <chris@rorvick.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 62a109d9
...@@ -488,9 +488,10 @@ static int line6_init_cap_control(struct usb_line6 *line6) ...@@ -488,9 +488,10 @@ static int line6_init_cap_control(struct usb_line6 *line6)
Probe USB device. Probe USB device.
*/ */
int line6_probe(struct usb_interface *interface, int line6_probe(struct usb_interface *interface,
const struct usb_device_id *id,
struct usb_line6 *line6, struct usb_line6 *line6,
const struct line6_properties *properties, const struct line6_properties *properties,
int (*private_init)(struct usb_interface *, struct usb_line6 *)) int (*private_init)(struct usb_line6 *, const struct usb_device_id *id))
{ {
struct usb_device *usbdev = interface_to_usbdev(interface); struct usb_device *usbdev = interface_to_usbdev(interface);
struct snd_card *card; struct snd_card *card;
...@@ -552,7 +553,7 @@ int line6_probe(struct usb_interface *interface, ...@@ -552,7 +553,7 @@ int line6_probe(struct usb_interface *interface,
} }
/* initialize device data based on device: */ /* initialize device data based on device: */
ret = private_init(interface, line6); ret = private_init(line6, id);
if (ret < 0) if (ret < 0)
goto error; goto error;
...@@ -565,7 +566,7 @@ int line6_probe(struct usb_interface *interface, ...@@ -565,7 +566,7 @@ int line6_probe(struct usb_interface *interface,
error: error:
if (line6->disconnect) if (line6->disconnect)
line6->disconnect(interface); line6->disconnect(line6);
snd_card_free(card); snd_card_free(card);
return ret; return ret;
} }
...@@ -592,7 +593,7 @@ void line6_disconnect(struct usb_interface *interface) ...@@ -592,7 +593,7 @@ void line6_disconnect(struct usb_interface *interface)
if (line6->line6pcm) if (line6->line6pcm)
line6_pcm_disconnect(line6->line6pcm); line6_pcm_disconnect(line6->line6pcm);
if (line6->disconnect) if (line6->disconnect)
line6->disconnect(interface); line6->disconnect(line6);
dev_info(&interface->dev, "Line 6 %s now disconnected\n", dev_info(&interface->dev, "Line 6 %s now disconnected\n",
line6->properties->name); line6->properties->name);
......
...@@ -157,7 +157,7 @@ struct usb_line6 { ...@@ -157,7 +157,7 @@ struct usb_line6 {
int message_length; int message_length;
void (*process_message)(struct usb_line6 *); void (*process_message)(struct usb_line6 *);
void (*disconnect)(struct usb_interface *); void (*disconnect)(struct usb_line6 *line6);
}; };
extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1,
...@@ -180,9 +180,11 @@ extern int line6_write_data(struct usb_line6 *line6, int address, void *data, ...@@ -180,9 +180,11 @@ extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
size_t datalen); size_t datalen);
int line6_probe(struct usb_interface *interface, int line6_probe(struct usb_interface *interface,
const struct usb_device_id *id,
struct usb_line6 *line6, struct usb_line6 *line6,
const struct line6_properties *properties, const struct line6_properties *properties,
int (*private_init)(struct usb_interface *, struct usb_line6 *)); int (*private_init)(struct usb_line6 *, const struct usb_device_id *id));
void line6_disconnect(struct usb_interface *interface); void line6_disconnect(struct usb_interface *interface);
#ifdef CONFIG_PM #ifdef CONFIG_PM
......
...@@ -399,10 +399,10 @@ static struct snd_kcontrol_new pod_control_monitor = { ...@@ -399,10 +399,10 @@ static struct snd_kcontrol_new pod_control_monitor = {
/* /*
POD device disconnected. POD device disconnected.
*/ */
static void line6_pod_disconnect(struct usb_interface *interface) static void line6_pod_disconnect(struct usb_line6 *line6)
{ {
struct usb_line6_pod *pod = usb_get_intfdata(interface); struct usb_line6_pod *pod = (struct usb_line6_pod *)line6;
struct device *dev = &interface->dev; struct device *dev = line6->ifcdev;
/* remove sysfs entries: */ /* remove sysfs entries: */
device_remove_file(dev, &dev_attr_device_id); device_remove_file(dev, &dev_attr_device_id);
...@@ -435,8 +435,8 @@ static int pod_create_files2(struct device *dev) ...@@ -435,8 +435,8 @@ static int pod_create_files2(struct device *dev)
/* /*
Try to init POD device. Try to init POD device.
*/ */
static int pod_init(struct usb_interface *interface, static int pod_init(struct usb_line6 *line6,
struct usb_line6 *line6) const struct usb_device_id *id)
{ {
int err; int err;
struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; struct usb_line6_pod *pod = (struct usb_line6_pod *) line6;
...@@ -448,7 +448,7 @@ static int pod_init(struct usb_interface *interface, ...@@ -448,7 +448,7 @@ static int pod_init(struct usb_interface *interface,
INIT_WORK(&pod->startup_work, pod_startup4); INIT_WORK(&pod->startup_work, pod_startup4);
/* create sysfs entries: */ /* create sysfs entries: */
err = pod_create_files2(&interface->dev); err = pod_create_files2(line6->ifcdev);
if (err < 0) if (err < 0)
return err; return err;
...@@ -596,7 +596,7 @@ static int pod_probe(struct usb_interface *interface, ...@@ -596,7 +596,7 @@ static int pod_probe(struct usb_interface *interface,
pod = kzalloc(sizeof(*pod), GFP_KERNEL); pod = kzalloc(sizeof(*pod), GFP_KERNEL);
if (!pod) if (!pod)
return -ENODEV; return -ENODEV;
return line6_probe(interface, &pod->line6, return line6_probe(interface, id, &pod->line6,
&pod_properties_table[id->driver_info], &pod_properties_table[id->driver_info],
pod_init); pod_init);
} }
......
...@@ -87,8 +87,8 @@ static struct line6_pcm_properties podhd_pcm_properties = { ...@@ -87,8 +87,8 @@ static struct line6_pcm_properties podhd_pcm_properties = {
/* /*
Try to init POD HD device. Try to init POD HD device.
*/ */
static int podhd_init(struct usb_interface *interface, static int podhd_init(struct usb_line6 *line6,
struct usb_line6 *line6) const struct usb_device_id *id)
{ {
int err; int err;
...@@ -182,7 +182,7 @@ static int podhd_probe(struct usb_interface *interface, ...@@ -182,7 +182,7 @@ static int podhd_probe(struct usb_interface *interface,
podhd = kzalloc(sizeof(*podhd), GFP_KERNEL); podhd = kzalloc(sizeof(*podhd), GFP_KERNEL);
if (!podhd) if (!podhd)
return -ENODEV; return -ENODEV;
return line6_probe(interface, &podhd->line6, return line6_probe(interface, id, &podhd->line6,
&podhd_properties_table[id->driver_info], &podhd_properties_table[id->driver_info],
podhd_init); podhd_init);
} }
......
...@@ -387,11 +387,11 @@ static void toneport_setup(struct usb_line6_toneport *toneport) ...@@ -387,11 +387,11 @@ static void toneport_setup(struct usb_line6_toneport *toneport)
/* /*
Toneport device disconnected. Toneport device disconnected.
*/ */
static void line6_toneport_disconnect(struct usb_interface *interface) static void line6_toneport_disconnect(struct usb_line6 *line6)
{ {
struct usb_line6_toneport *toneport; struct usb_line6_toneport *toneport =
(struct usb_line6_toneport *)line6;
toneport = usb_get_intfdata(interface);
del_timer_sync(&toneport->timer); del_timer_sync(&toneport->timer);
if (toneport_has_led(toneport->type)) if (toneport_has_led(toneport->type))
...@@ -402,12 +402,13 @@ static void line6_toneport_disconnect(struct usb_interface *interface) ...@@ -402,12 +402,13 @@ static void line6_toneport_disconnect(struct usb_interface *interface)
/* /*
Try to init Toneport device. Try to init Toneport device.
*/ */
static int toneport_init(struct usb_interface *interface, static int toneport_init(struct usb_line6 *line6,
struct usb_line6 *line6) const struct usb_device_id *id)
{ {
int err; int err;
struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6; struct usb_line6_toneport *toneport = (struct usb_line6_toneport *) line6;
toneport->type = id->driver_info;
setup_timer(&toneport->timer, toneport_start_pcm, setup_timer(&toneport->timer, toneport_start_pcm,
(unsigned long)toneport); (unsigned long)toneport);
...@@ -562,8 +563,7 @@ static int toneport_probe(struct usb_interface *interface, ...@@ -562,8 +563,7 @@ static int toneport_probe(struct usb_interface *interface,
toneport = kzalloc(sizeof(*toneport), GFP_KERNEL); toneport = kzalloc(sizeof(*toneport), GFP_KERNEL);
if (!toneport) if (!toneport)
return -ENODEV; return -ENODEV;
toneport->type = id->driver_info; return line6_probe(interface, id, &toneport->line6,
return line6_probe(interface, &toneport->line6,
&toneport_properties_table[id->driver_info], &toneport_properties_table[id->driver_info],
toneport_init); toneport_init);
} }
......
...@@ -210,11 +210,9 @@ static void line6_variax_process_message(struct usb_line6 *line6) ...@@ -210,11 +210,9 @@ static void line6_variax_process_message(struct usb_line6 *line6)
/* /*
Variax destructor. Variax destructor.
*/ */
static void line6_variax_disconnect(struct usb_interface *interface) static void line6_variax_disconnect(struct usb_line6 *line6)
{ {
struct usb_line6_variax *variax; struct usb_line6_variax *variax = (struct usb_line6_variax *)line6;
variax = usb_get_intfdata(interface);
del_timer(&variax->startup_timer1); del_timer(&variax->startup_timer1);
del_timer(&variax->startup_timer2); del_timer(&variax->startup_timer2);
...@@ -226,8 +224,8 @@ static void line6_variax_disconnect(struct usb_interface *interface) ...@@ -226,8 +224,8 @@ static void line6_variax_disconnect(struct usb_interface *interface)
/* /*
Try to init workbench device. Try to init workbench device.
*/ */
static int variax_init(struct usb_interface *interface, static int variax_init(struct usb_line6 *line6,
struct usb_line6 *line6) const struct usb_device_id *id)
{ {
struct usb_line6_variax *variax = (struct usb_line6_variax *) line6; struct usb_line6_variax *variax = (struct usb_line6_variax *) line6;
int err; int err;
...@@ -303,7 +301,7 @@ static int variax_probe(struct usb_interface *interface, ...@@ -303,7 +301,7 @@ static int variax_probe(struct usb_interface *interface,
variax = kzalloc(sizeof(*variax), GFP_KERNEL); variax = kzalloc(sizeof(*variax), GFP_KERNEL);
if (!variax) if (!variax)
return -ENODEV; return -ENODEV;
return line6_probe(interface, &variax->line6, return line6_probe(interface, id, &variax->line6,
&variax_properties_table[id->driver_info], &variax_properties_table[id->driver_info],
variax_init); variax_init);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment