diff options
Diffstat (limited to 'drivers/usb/gadget/legacy/gmidi.c')
-rw-r--r-- | drivers/usb/gadget/legacy/gmidi.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/drivers/usb/gadget/legacy/gmidi.c b/drivers/usb/gadget/legacy/gmidi.c index 3d696b86ff76..e02a095294ac 100644 --- a/drivers/usb/gadget/legacy/gmidi.c +++ b/drivers/usb/gadget/legacy/gmidi.c | |||
@@ -37,7 +37,7 @@ | |||
37 | 37 | ||
38 | #include "gadget_chips.h" | 38 | #include "gadget_chips.h" |
39 | 39 | ||
40 | #include "f_midi.c" | 40 | #include "u_midi.h" |
41 | 41 | ||
42 | /*-------------------------------------------------------------------------*/ | 42 | /*-------------------------------------------------------------------------*/ |
43 | 43 | ||
@@ -115,8 +115,13 @@ static struct usb_gadget_strings *dev_strings[] = { | |||
115 | NULL, | 115 | NULL, |
116 | }; | 116 | }; |
117 | 117 | ||
118 | static struct usb_function_instance *fi_midi; | ||
119 | static struct usb_function *f_midi; | ||
120 | |||
118 | static int __exit midi_unbind(struct usb_composite_dev *dev) | 121 | static int __exit midi_unbind(struct usb_composite_dev *dev) |
119 | { | 122 | { |
123 | usb_put_function(f_midi); | ||
124 | usb_put_function_instance(fi_midi); | ||
120 | return 0; | 125 | return 0; |
121 | } | 126 | } |
122 | 127 | ||
@@ -130,28 +135,54 @@ static struct usb_configuration midi_config = { | |||
130 | 135 | ||
131 | static int __init midi_bind_config(struct usb_configuration *c) | 136 | static int __init midi_bind_config(struct usb_configuration *c) |
132 | { | 137 | { |
133 | return f_midi_bind_config(c, index, id, | 138 | int status; |
134 | in_ports, out_ports, | 139 | |
135 | buflen, qlen); | 140 | f_midi = usb_get_function(fi_midi); |
141 | if (IS_ERR(f_midi)) | ||
142 | return PTR_ERR(f_midi); | ||
143 | |||
144 | status = usb_add_function(c, f_midi); | ||
145 | if (status < 0) { | ||
146 | usb_put_function(f_midi); | ||
147 | return status; | ||
148 | } | ||
149 | |||
150 | return 0; | ||
136 | } | 151 | } |
137 | 152 | ||
138 | static int __init midi_bind(struct usb_composite_dev *cdev) | 153 | static int __init midi_bind(struct usb_composite_dev *cdev) |
139 | { | 154 | { |
155 | struct f_midi_opts *midi_opts; | ||
140 | int status; | 156 | int status; |
141 | 157 | ||
158 | fi_midi = usb_get_function_instance("midi"); | ||
159 | if (IS_ERR(fi_midi)) | ||
160 | return PTR_ERR(fi_midi); | ||
161 | |||
162 | midi_opts = container_of(fi_midi, struct f_midi_opts, func_inst); | ||
163 | midi_opts->index = index; | ||
164 | midi_opts->id = id; | ||
165 | midi_opts->in_ports = in_ports; | ||
166 | midi_opts->out_ports = out_ports; | ||
167 | midi_opts->buflen = buflen; | ||
168 | midi_opts->qlen = qlen; | ||
169 | |||
142 | status = usb_string_ids_tab(cdev, strings_dev); | 170 | status = usb_string_ids_tab(cdev, strings_dev); |
143 | if (status < 0) | 171 | if (status < 0) |
144 | return status; | 172 | goto put; |
145 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; | 173 | device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; |
146 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; | 174 | device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; |
147 | midi_config.iConfiguration = strings_dev[STRING_DESCRIPTION_IDX].id; | 175 | midi_config.iConfiguration = strings_dev[STRING_DESCRIPTION_IDX].id; |
148 | 176 | ||
149 | status = usb_add_config(cdev, &midi_config, midi_bind_config); | 177 | status = usb_add_config(cdev, &midi_config, midi_bind_config); |
150 | if (status < 0) | 178 | if (status < 0) |
151 | return status; | 179 | goto put; |
152 | usb_composite_overwrite_options(cdev, &coverwrite); | 180 | usb_composite_overwrite_options(cdev, &coverwrite); |
153 | pr_info("%s\n", longname); | 181 | pr_info("%s\n", longname); |
154 | return 0; | 182 | return 0; |
183 | put: | ||
184 | usb_put_function_instance(fi_midi); | ||
185 | return status; | ||
155 | } | 186 | } |
156 | 187 | ||
157 | static __refdata struct usb_composite_driver midi_driver = { | 188 | static __refdata struct usb_composite_driver midi_driver = { |