diff options
| author | Chris Rorvick <chris@rorvick.com> | 2015-01-12 15:42:59 -0500 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2015-01-12 16:24:11 -0500 |
| commit | a46c467251353109683d353826208a17aec9383e (patch) | |
| tree | 45b2e813554ae184dfdbd0264a75b93764fc7e66 | |
| parent | 01f6b2bc6a40efa2d29b213e636b9208a8126318 (diff) | |
staging: line6: Call *_disconnect() via pointer
Which *_disconnect() to call on disconnect is known at initialization.
Add a function pointer to the `usb_line6' struct and use to call into
the appropriate logic instead of evaluating the conditional logic.
Signed-off-by: Chris Rorvick <chris@rorvick.com>
Reviewed-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
| -rw-r--r-- | drivers/staging/line6/driver.c | 43 | ||||
| -rw-r--r-- | drivers/staging/line6/driver.h | 1 | ||||
| -rw-r--r-- | drivers/staging/line6/pod.c | 1 | ||||
| -rw-r--r-- | drivers/staging/line6/podhd.c | 2 | ||||
| -rw-r--r-- | drivers/staging/line6/toneport.c | 2 | ||||
| -rw-r--r-- | drivers/staging/line6/variax.c | 1 |
6 files changed, 8 insertions, 42 deletions
diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c index f7629cbe01a3..fc852f6ab8bc 100644 --- a/drivers/staging/line6/driver.c +++ b/drivers/staging/line6/driver.c | |||
| @@ -1017,48 +1017,7 @@ static void line6_disconnect(struct usb_interface *interface) | |||
| 1017 | dev_err(line6->ifcdev, | 1017 | dev_err(line6->ifcdev, |
| 1018 | "driver bug: inconsistent usb device\n"); | 1018 | "driver bug: inconsistent usb device\n"); |
| 1019 | 1019 | ||
| 1020 | switch (line6->type) { | 1020 | line6->disconnect(interface); |
| 1021 | case LINE6_BASSPODXT: | ||
| 1022 | case LINE6_BASSPODXTLIVE: | ||
| 1023 | case LINE6_BASSPODXTPRO: | ||
| 1024 | case LINE6_POCKETPOD: | ||
| 1025 | case LINE6_PODXT: | ||
| 1026 | case LINE6_PODXTPRO: | ||
| 1027 | line6_pod_disconnect(interface); | ||
| 1028 | break; | ||
| 1029 | |||
| 1030 | case LINE6_PODHD300: | ||
| 1031 | case LINE6_PODHD400: | ||
| 1032 | case LINE6_PODHD500_0: | ||
| 1033 | case LINE6_PODHD500_1: | ||
| 1034 | line6_podhd_disconnect(interface); | ||
| 1035 | break; | ||
| 1036 | |||
| 1037 | case LINE6_PODXTLIVE_POD: | ||
| 1038 | line6_pod_disconnect(interface); | ||
| 1039 | break; | ||
| 1040 | |||
| 1041 | case LINE6_PODXTLIVE_VARIAX: | ||
| 1042 | line6_variax_disconnect(interface); | ||
| 1043 | break; | ||
| 1044 | |||
| 1045 | case LINE6_VARIAX: | ||
| 1046 | line6_variax_disconnect(interface); | ||
| 1047 | break; | ||
| 1048 | |||
| 1049 | case LINE6_PODSTUDIO_GX: | ||
| 1050 | case LINE6_PODSTUDIO_UX1: | ||
| 1051 | case LINE6_PODSTUDIO_UX2: | ||
| 1052 | case LINE6_TONEPORT_GX: | ||
| 1053 | case LINE6_TONEPORT_UX1: | ||
| 1054 | case LINE6_TONEPORT_UX2: | ||
| 1055 | case LINE6_GUITARPORT: | ||
| 1056 | line6_toneport_disconnect(interface); | ||
| 1057 | break; | ||
| 1058 | |||
| 1059 | default: | ||
| 1060 | MISSING_CASE; | ||
| 1061 | } | ||
| 1062 | 1021 | ||
| 1063 | dev_info(&interface->dev, "Line6 %s now disconnected\n", | 1022 | dev_info(&interface->dev, "Line6 %s now disconnected\n", |
| 1064 | line6->properties->name); | 1023 | line6->properties->name); |
diff --git a/drivers/staging/line6/driver.h b/drivers/staging/line6/driver.h index 220813f1cbb9..ad203f197e80 100644 --- a/drivers/staging/line6/driver.h +++ b/drivers/staging/line6/driver.h | |||
| @@ -196,6 +196,7 @@ struct usb_line6 { | |||
| 196 | int message_length; | 196 | int message_length; |
| 197 | 197 | ||
| 198 | void (*process_message)(struct usb_line6 *); | 198 | void (*process_message)(struct usb_line6 *); |
| 199 | void (*disconnect)(struct usb_interface *); | ||
| 199 | }; | 200 | }; |
| 200 | 201 | ||
| 201 | extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, | 202 | extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, |
diff --git a/drivers/staging/line6/pod.c b/drivers/staging/line6/pod.c index 79dcff4ae5a7..b9af5cf50ecf 100644 --- a/drivers/staging/line6/pod.c +++ b/drivers/staging/line6/pod.c | |||
| @@ -360,6 +360,7 @@ static int pod_try_init(struct usb_interface *interface, | |||
| 360 | struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; | 360 | struct usb_line6_pod *pod = (struct usb_line6_pod *) line6; |
| 361 | 361 | ||
| 362 | line6->process_message = line6_pod_process_message; | 362 | line6->process_message = line6_pod_process_message; |
| 363 | line6->disconnect = line6_pod_disconnect; | ||
| 363 | 364 | ||
| 364 | init_timer(&pod->startup_timer); | 365 | init_timer(&pod->startup_timer); |
| 365 | INIT_WORK(&pod->startup_work, pod_startup4); | 366 | INIT_WORK(&pod->startup_work, pod_startup4); |
diff --git a/drivers/staging/line6/podhd.c b/drivers/staging/line6/podhd.c index 3bb942e7ff93..a57fbce3503e 100644 --- a/drivers/staging/line6/podhd.c +++ b/drivers/staging/line6/podhd.c | |||
| @@ -98,6 +98,8 @@ static int podhd_try_init(struct usb_interface *interface, | |||
| 98 | if ((interface == NULL) || (podhd == NULL)) | 98 | if ((interface == NULL) || (podhd == NULL)) |
| 99 | return -ENODEV; | 99 | return -ENODEV; |
| 100 | 100 | ||
| 101 | line6->disconnect = line6_podhd_disconnect; | ||
| 102 | |||
| 101 | /* initialize audio system: */ | 103 | /* initialize audio system: */ |
| 102 | err = line6_init_audio(line6); | 104 | err = line6_init_audio(line6); |
| 103 | if (err < 0) | 105 | if (err < 0) |
diff --git a/drivers/staging/line6/toneport.c b/drivers/staging/line6/toneport.c index de91910a102c..5c462b72a850 100644 --- a/drivers/staging/line6/toneport.c +++ b/drivers/staging/line6/toneport.c | |||
| @@ -347,6 +347,8 @@ static int toneport_try_init(struct usb_interface *interface, | |||
| 347 | if ((interface == NULL) || (toneport == NULL)) | 347 | if ((interface == NULL) || (toneport == NULL)) |
| 348 | return -ENODEV; | 348 | return -ENODEV; |
| 349 | 349 | ||
| 350 | line6->disconnect = line6_toneport_disconnect; | ||
| 351 | |||
| 350 | /* initialize audio system: */ | 352 | /* initialize audio system: */ |
| 351 | err = line6_init_audio(line6); | 353 | err = line6_init_audio(line6); |
| 352 | if (err < 0) | 354 | if (err < 0) |
diff --git a/drivers/staging/line6/variax.c b/drivers/staging/line6/variax.c index ccb1f689e335..ca25b41ea88b 100644 --- a/drivers/staging/line6/variax.c +++ b/drivers/staging/line6/variax.c | |||
| @@ -181,6 +181,7 @@ static int variax_try_init(struct usb_interface *interface, | |||
| 181 | int err; | 181 | int err; |
| 182 | 182 | ||
| 183 | line6->process_message = line6_variax_process_message; | 183 | line6->process_message = line6_variax_process_message; |
| 184 | line6->disconnect = line6_variax_disconnect; | ||
| 184 | 185 | ||
| 185 | init_timer(&variax->startup_timer1); | 186 | init_timer(&variax->startup_timer1); |
| 186 | init_timer(&variax->startup_timer2); | 187 | init_timer(&variax->startup_timer2); |
