diff options
Diffstat (limited to 'drivers/usb/gadget/serial.c')
-rw-r--r-- | drivers/usb/gadget/serial.c | 59 |
1 files changed, 7 insertions, 52 deletions
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 68d7bb06ebcb..1f5f978d35d5 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -12,6 +12,7 @@ | |||
12 | 12 | ||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/device.h> | 14 | #include <linux/device.h> |
15 | #include <linux/module.h> | ||
15 | #include <linux/tty.h> | 16 | #include <linux/tty.h> |
16 | #include <linux/tty_flip.h> | 17 | #include <linux/tty_flip.h> |
17 | 18 | ||
@@ -28,18 +29,6 @@ | |||
28 | #define GS_VERSION_NAME GS_LONG_NAME " " GS_VERSION_STR | 29 | #define GS_VERSION_NAME GS_LONG_NAME " " GS_VERSION_STR |
29 | 30 | ||
30 | /*-------------------------------------------------------------------------*/ | 31 | /*-------------------------------------------------------------------------*/ |
31 | |||
32 | /* | ||
33 | * Kbuild is not very cooperative with respect to linking separately | ||
34 | * compiled library objects into one module. So for now we won't use | ||
35 | * separate compilation ... ensuring init/exit sections work to shrink | ||
36 | * the runtime footprint, and giving us at least some parts of what | ||
37 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | ||
38 | */ | ||
39 | #include "f_obex.c" | ||
40 | #include "f_serial.c" | ||
41 | |||
42 | /*-------------------------------------------------------------------------*/ | ||
43 | USB_GADGET_COMPOSITE_OPTIONS(); | 32 | USB_GADGET_COMPOSITE_OPTIONS(); |
44 | 33 | ||
45 | /* Thanks to NetChip Technologies for donating this product ID. | 34 | /* Thanks to NetChip Technologies for donating this product ID. |
@@ -126,27 +115,6 @@ module_param(n_ports, uint, 0); | |||
126 | MODULE_PARM_DESC(n_ports, "number of ports to create, default=1"); | 115 | MODULE_PARM_DESC(n_ports, "number of ports to create, default=1"); |
127 | 116 | ||
128 | /*-------------------------------------------------------------------------*/ | 117 | /*-------------------------------------------------------------------------*/ |
129 | static unsigned char tty_lines[MAX_U_SERIAL_PORTS]; | ||
130 | |||
131 | static int __init serial_bind_obex_config(struct usb_configuration *c) | ||
132 | { | ||
133 | unsigned i; | ||
134 | int status = 0; | ||
135 | |||
136 | for (i = 0; i < n_ports && status == 0; i++) | ||
137 | status = obex_bind_config(c, tty_lines[i]); | ||
138 | return status; | ||
139 | } | ||
140 | |||
141 | static int __init serial_bind_gser_config(struct usb_configuration *c) | ||
142 | { | ||
143 | unsigned i; | ||
144 | int status = 0; | ||
145 | |||
146 | for (i = 0; i < n_ports && status == 0; i++) | ||
147 | status = gser_bind_config(c, tty_lines[i]); | ||
148 | return status; | ||
149 | } | ||
150 | 118 | ||
151 | static struct usb_configuration serial_config_driver = { | 119 | static struct usb_configuration serial_config_driver = { |
152 | /* .label = f(use_acm) */ | 120 | /* .label = f(use_acm) */ |
@@ -169,15 +137,12 @@ static int serial_register_ports(struct usb_composite_dev *cdev, | |||
169 | goto out; | 137 | goto out; |
170 | 138 | ||
171 | for (i = 0; i < n_ports; i++) { | 139 | for (i = 0; i < n_ports; i++) { |
172 | struct f_serial_opts *opts; | ||
173 | 140 | ||
174 | fi_serial[i] = usb_get_function_instance(f_name); | 141 | fi_serial[i] = usb_get_function_instance(f_name); |
175 | if (IS_ERR(fi_serial[i])) { | 142 | if (IS_ERR(fi_serial[i])) { |
176 | ret = PTR_ERR(fi_serial[i]); | 143 | ret = PTR_ERR(fi_serial[i]); |
177 | goto fail; | 144 | goto fail; |
178 | } | 145 | } |
179 | opts = container_of(fi_serial[i], struct f_serial_opts, func_inst); | ||
180 | opts->port_num = tty_lines[i]; | ||
181 | 146 | ||
182 | f_serial[i] = usb_get_function(fi_serial[i]); | 147 | f_serial[i] = usb_get_function(fi_serial[i]); |
183 | if (IS_ERR(f_serial[i])) { | 148 | if (IS_ERR(f_serial[i])) { |
@@ -212,13 +177,6 @@ out: | |||
212 | static int __init gs_bind(struct usb_composite_dev *cdev) | 177 | static int __init gs_bind(struct usb_composite_dev *cdev) |
213 | { | 178 | { |
214 | int status; | 179 | int status; |
215 | int cur_line; | ||
216 | |||
217 | for (cur_line = 0; cur_line < n_ports; cur_line++) { | ||
218 | status = gserial_alloc_line(&tty_lines[cur_line]); | ||
219 | if (status) | ||
220 | goto fail; | ||
221 | } | ||
222 | 180 | ||
223 | /* Allocate string descriptor numbers ... note that string | 181 | /* Allocate string descriptor numbers ... note that string |
224 | * contents can be overridden by the composite_dev glue. | 182 | * contents can be overridden by the composite_dev glue. |
@@ -243,11 +201,12 @@ static int __init gs_bind(struct usb_composite_dev *cdev) | |||
243 | "acm"); | 201 | "acm"); |
244 | usb_ep_autoconfig_reset(cdev->gadget); | 202 | usb_ep_autoconfig_reset(cdev->gadget); |
245 | } else if (use_obex) | 203 | } else if (use_obex) |
246 | status = usb_add_config(cdev, &serial_config_driver, | 204 | status = serial_register_ports(cdev, &serial_config_driver, |
247 | serial_bind_obex_config); | 205 | "obex"); |
248 | else | 206 | else { |
249 | status = usb_add_config(cdev, &serial_config_driver, | 207 | status = serial_register_ports(cdev, &serial_config_driver, |
250 | serial_bind_gser_config); | 208 | "gser"); |
209 | } | ||
251 | if (status < 0) | 210 | if (status < 0) |
252 | goto fail; | 211 | goto fail; |
253 | 212 | ||
@@ -257,9 +216,6 @@ static int __init gs_bind(struct usb_composite_dev *cdev) | |||
257 | return 0; | 216 | return 0; |
258 | 217 | ||
259 | fail: | 218 | fail: |
260 | cur_line--; | ||
261 | while (cur_line >= 0) | ||
262 | gserial_free_line(tty_lines[cur_line--]); | ||
263 | return status; | 219 | return status; |
264 | } | 220 | } |
265 | 221 | ||
@@ -270,7 +226,6 @@ static int gs_unbind(struct usb_composite_dev *cdev) | |||
270 | for (i = 0; i < n_ports; i++) { | 226 | for (i = 0; i < n_ports; i++) { |
271 | usb_put_function(f_serial[i]); | 227 | usb_put_function(f_serial[i]); |
272 | usb_put_function_instance(fi_serial[i]); | 228 | usb_put_function_instance(fi_serial[i]); |
273 | gserial_free_line(tty_lines[i]); | ||
274 | } | 229 | } |
275 | return 0; | 230 | return 0; |
276 | } | 231 | } |