aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/usb-serial.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-07-23 13:10:23 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-23 13:10:23 -0400
commita4e0d9af403d099e751797f6cc69e4a8e2d78ef1 (patch)
tree6f4afdffe5dbaad7529be987b8c3259a07395031 /drivers/usb/serial/usb-serial.c
parentc60f2b5c1defb6b1345968e1c65c2008c221d57d (diff)
parentc010b2f76c3032e48097a6eef291d8593d5d79a6 (diff)
Merge ../linux-2.6
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r--drivers/usb/serial/usb-serial.c400
1 files changed, 214 insertions, 186 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 0cb0d77dc429..8c2d531eedea 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -12,7 +12,8 @@
12 * This driver was originally based on the ACM driver by Armin Fuerst (which was 12 * This driver was originally based on the ACM driver by Armin Fuerst (which was
13 * based on a driver by Brad Keryan) 13 * based on a driver by Brad Keryan)
14 * 14 *
15 * See Documentation/usb/usb-serial.txt for more information on using this driver 15 * See Documentation/usb/usb-serial.txt for more information on using this
16 * driver
16 * 17 *
17 */ 18 */
18 19
@@ -28,7 +29,7 @@
28#include <linux/spinlock.h> 29#include <linux/spinlock.h>
29#include <linux/mutex.h> 30#include <linux/mutex.h>
30#include <linux/list.h> 31#include <linux/list.h>
31#include <asm/uaccess.h> 32#include <linux/uaccess.h>
32#include <linux/usb.h> 33#include <linux/usb.h>
33#include <linux/usb/serial.h> 34#include <linux/usb/serial.h>
34#include "pl2303.h" 35#include "pl2303.h"
@@ -59,7 +60,8 @@ static struct usb_driver usb_serial_driver = {
59*/ 60*/
60 61
61static int debug; 62static int debug;
62static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */ 63/* initially all NULL */
64static struct usb_serial *serial_table[SERIAL_TTY_MINORS];
63static DEFINE_MUTEX(table_lock); 65static DEFINE_MUTEX(table_lock);
64static LIST_HEAD(usb_serial_driver_list); 66static LIST_HEAD(usb_serial_driver_list);
65 67
@@ -76,7 +78,8 @@ struct usb_serial *usb_serial_get_by_index(unsigned index)
76 return serial; 78 return serial;
77} 79}
78 80
79static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_ports, unsigned int *minor) 81static struct usb_serial *get_free_serial(struct usb_serial *serial,
82 int num_ports, unsigned int *minor)
80{ 83{
81 unsigned int i, j; 84 unsigned int i, j;
82 int good_spot; 85 int good_spot;
@@ -122,9 +125,8 @@ static void return_serial(struct usb_serial *serial)
122 if (serial == NULL) 125 if (serial == NULL)
123 return; 126 return;
124 127
125 for (i = 0; i < serial->num_ports; ++i) { 128 for (i = 0; i < serial->num_ports; ++i)
126 serial_table[serial->minor + i] = NULL; 129 serial_table[serial->minor + i] = NULL;
127 }
128} 130}
129 131
130static void destroy_serial(struct kref *kref) 132static void destroy_serial(struct kref *kref)
@@ -143,7 +145,7 @@ static void destroy_serial(struct kref *kref)
143 return_serial(serial); 145 return_serial(serial);
144 146
145 for (i = 0; i < serial->num_ports; ++i) 147 for (i = 0; i < serial->num_ports; ++i)
146 serial->port[i]->open_count = 0; 148 serial->port[i]->port.count = 0;
147 149
148 /* the ports are cleaned up and released in port_release() */ 150 /* the ports are cleaned up and released in port_release() */
149 for (i = 0; i < serial->num_ports; ++i) 151 for (i = 0; i < serial->num_ports; ++i)
@@ -156,7 +158,8 @@ static void destroy_serial(struct kref *kref)
156 * not get cleaned up in port_release() as it was never registered with 158 * not get cleaned up in port_release() as it was never registered with
157 * the driver core */ 159 * the driver core */
158 if (serial->num_ports < serial->num_port_pointers) { 160 if (serial->num_ports < serial->num_port_pointers) {
159 for (i = serial->num_ports; i < serial->num_port_pointers; ++i) { 161 for (i = serial->num_ports;
162 i < serial->num_port_pointers; ++i) {
160 port = serial->port[i]; 163 port = serial->port[i];
161 if (!port) 164 if (!port)
162 continue; 165 continue;
@@ -167,7 +170,7 @@ static void destroy_serial(struct kref *kref)
167 usb_put_dev(serial->dev); 170 usb_put_dev(serial->dev);
168 171
169 /* free up any memory that we allocated */ 172 /* free up any memory that we allocated */
170 kfree (serial); 173 kfree(serial);
171} 174}
172 175
173void usb_serial_put(struct usb_serial *serial) 176void usb_serial_put(struct usb_serial *serial)
@@ -180,13 +183,13 @@ void usb_serial_put(struct usb_serial *serial)
180/***************************************************************************** 183/*****************************************************************************
181 * Driver tty interface functions 184 * Driver tty interface functions
182 *****************************************************************************/ 185 *****************************************************************************/
183static int serial_open (struct tty_struct *tty, struct file * filp) 186static int serial_open (struct tty_struct *tty, struct file *filp)
184{ 187{
185 struct usb_serial *serial; 188 struct usb_serial *serial;
186 struct usb_serial_port *port; 189 struct usb_serial_port *port;
187 unsigned int portNumber; 190 unsigned int portNumber;
188 int retval; 191 int retval;
189 192
190 dbg("%s", __func__); 193 dbg("%s", __func__);
191 194
192 /* get the serial object associated with this tty pointer */ 195 /* get the serial object associated with this tty pointer */
@@ -207,15 +210,15 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
207 retval = -ERESTARTSYS; 210 retval = -ERESTARTSYS;
208 goto bailout_kref_put; 211 goto bailout_kref_put;
209 } 212 }
210 213
211 ++port->open_count; 214 ++port->port.count;
212 215
213 /* set up our port structure making the tty driver 216 /* set up our port structure making the tty driver
214 * remember our port object, and us it */ 217 * remember our port object, and us it */
215 tty->driver_data = port; 218 tty->driver_data = port;
216 port->tty = tty; 219 port->port.tty = tty;
217 220
218 if (port->open_count == 1) { 221 if (port->port.count == 1) {
219 222
220 /* lock this module before we call it 223 /* lock this module before we call it
221 * this may fail, which means we must bail out, 224 * this may fail, which means we must bail out,
@@ -228,9 +231,9 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
228 retval = usb_autopm_get_interface(serial->interface); 231 retval = usb_autopm_get_interface(serial->interface);
229 if (retval) 232 if (retval)
230 goto bailout_module_put; 233 goto bailout_module_put;
231 /* only call the device specific open if this 234 /* only call the device specific open if this
232 * is the first time the port is opened */ 235 * is the first time the port is opened */
233 retval = serial->type->open(port, filp); 236 retval = serial->type->open(tty, port, filp);
234 if (retval) 237 if (retval)
235 goto bailout_interface_put; 238 goto bailout_interface_put;
236 } 239 }
@@ -243,16 +246,16 @@ bailout_interface_put:
243bailout_module_put: 246bailout_module_put:
244 module_put(serial->type->driver.owner); 247 module_put(serial->type->driver.owner);
245bailout_mutex_unlock: 248bailout_mutex_unlock:
246 port->open_count = 0; 249 port->port.count = 0;
247 tty->driver_data = NULL; 250 tty->driver_data = NULL;
248 port->tty = NULL; 251 port->port.tty = NULL;
249 mutex_unlock(&port->mutex); 252 mutex_unlock(&port->mutex);
250bailout_kref_put: 253bailout_kref_put:
251 usb_serial_put(serial); 254 usb_serial_put(serial);
252 return retval; 255 return retval;
253} 256}
254 257
255static void serial_close(struct tty_struct *tty, struct file * filp) 258static void serial_close(struct tty_struct *tty, struct file *filp)
256{ 259{
257 struct usb_serial_port *port = tty->driver_data; 260 struct usb_serial_port *port = tty->driver_data;
258 261
@@ -263,27 +266,30 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
263 266
264 mutex_lock(&port->mutex); 267 mutex_lock(&port->mutex);
265 268
266 if (port->open_count == 0) { 269 if (port->port.count == 0) {
267 mutex_unlock(&port->mutex); 270 mutex_unlock(&port->mutex);
268 return; 271 return;
269 } 272 }
270 273
271 --port->open_count; 274 --port->port.count;
272 if (port->open_count == 0) 275 if (port->port.count == 0)
273 /* only call the device specific close if this 276 /* only call the device specific close if this
274 * port is being closed by the last owner */ 277 * port is being closed by the last owner */
275 port->serial->type->close(port, filp); 278 port->serial->type->close(tty, port, filp);
276 279
277 if (port->open_count == (port->console? 1 : 0)) { 280 if (port->port.count == (port->console? 1 : 0)) {
278 if (port->tty) { 281 if (port->port.tty) {
279 if (port->tty->driver_data) 282 if (port->port.tty->driver_data)
280 port->tty->driver_data = NULL; 283 port->port.tty->driver_data = NULL;
281 port->tty = NULL; 284 port->port.tty = NULL;
282 } 285 }
283 } 286 }
284 287
285 if (port->open_count == 0) { 288 if (port->port.count == 0) {
286 usb_autopm_put_interface(port->serial->interface); 289 mutex_lock(&port->serial->disc_mutex);
290 if (!port->serial->disconnected)
291 usb_autopm_put_interface(port->serial->interface);
292 mutex_unlock(&port->serial->disc_mutex);
287 module_put(port->serial->type->driver.owner); 293 module_put(port->serial->type->driver.owner);
288 } 294 }
289 295
@@ -291,7 +297,8 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
291 usb_serial_put(port->serial); 297 usb_serial_put(port->serial);
292} 298}
293 299
294static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count) 300static int serial_write(struct tty_struct *tty, const unsigned char *buf,
301 int count)
295{ 302{
296 struct usb_serial_port *port = tty->driver_data; 303 struct usb_serial_port *port = tty->driver_data;
297 int retval = -ENODEV; 304 int retval = -ENODEV;
@@ -301,107 +308,112 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int
301 308
302 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 309 dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
303 310
304 /* open_count is managed under the mutex lock for the tty so cannot 311 /* count is managed under the mutex lock for the tty so cannot
305 drop to zero until after the last close completes */ 312 drop to zero until after the last close completes */
306 WARN_ON(!port->open_count); 313 WARN_ON(!port->port.count);
307 314
308 /* pass on to the driver specific version of this function */ 315 /* pass on to the driver specific version of this function */
309 retval = port->serial->type->write(port, buf, count); 316 retval = port->serial->type->write(tty, port, buf, count);
310 317
311exit: 318exit:
312 return retval; 319 return retval;
313} 320}
314 321
315static int serial_write_room (struct tty_struct *tty) 322static int serial_write_room(struct tty_struct *tty)
316{ 323{
317 struct usb_serial_port *port = tty->driver_data; 324 struct usb_serial_port *port = tty->driver_data;
318 dbg("%s - port %d", __func__, port->number); 325 dbg("%s - port %d", __func__, port->number);
319 WARN_ON(!port->open_count); 326 WARN_ON(!port->port.count);
320 /* pass on to the driver specific version of this function */ 327 /* pass on to the driver specific version of this function */
321 return port->serial->type->write_room(port); 328 return port->serial->type->write_room(tty);
322} 329}
323 330
324static int serial_chars_in_buffer (struct tty_struct *tty) 331static int serial_chars_in_buffer(struct tty_struct *tty)
325{ 332{
326 struct usb_serial_port *port = tty->driver_data; 333 struct usb_serial_port *port = tty->driver_data;
327 dbg("%s = port %d", __func__, port->number); 334 dbg("%s = port %d", __func__, port->number);
328 335
329 WARN_ON(!port->open_count); 336 WARN_ON(!port->port.count);
330 /* pass on to the driver specific version of this function */ 337 /* pass on to the driver specific version of this function */
331 return port->serial->type->chars_in_buffer(port); 338 return port->serial->type->chars_in_buffer(tty);
332} 339}
333 340
334static void serial_throttle (struct tty_struct * tty) 341static void serial_throttle(struct tty_struct *tty)
335{ 342{
336 struct usb_serial_port *port = tty->driver_data; 343 struct usb_serial_port *port = tty->driver_data;
337 dbg("%s - port %d", __func__, port->number); 344 dbg("%s - port %d", __func__, port->number);
338 345
339 WARN_ON(!port->open_count); 346 WARN_ON(!port->port.count);
340 /* pass on to the driver specific version of this function */ 347 /* pass on to the driver specific version of this function */
341 if (port->serial->type->throttle) 348 if (port->serial->type->throttle)
342 port->serial->type->throttle(port); 349 port->serial->type->throttle(tty);
343} 350}
344 351
345static void serial_unthrottle (struct tty_struct * tty) 352static void serial_unthrottle(struct tty_struct *tty)
346{ 353{
347 struct usb_serial_port *port = tty->driver_data; 354 struct usb_serial_port *port = tty->driver_data;
348 dbg("%s - port %d", __func__, port->number); 355 dbg("%s - port %d", __func__, port->number);
349 356
350 WARN_ON(!port->open_count); 357 WARN_ON(!port->port.count);
351 /* pass on to the driver specific version of this function */ 358 /* pass on to the driver specific version of this function */
352 if (port->serial->type->unthrottle) 359 if (port->serial->type->unthrottle)
353 port->serial->type->unthrottle(port); 360 port->serial->type->unthrottle(tty);
354} 361}
355 362
356static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) 363static int serial_ioctl(struct tty_struct *tty, struct file *file,
364 unsigned int cmd, unsigned long arg)
357{ 365{
358 struct usb_serial_port *port = tty->driver_data; 366 struct usb_serial_port *port = tty->driver_data;
359 int retval = -ENODEV; 367 int retval = -ENODEV;
360 368
361 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); 369 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
362 370
363 WARN_ON(!port->open_count); 371 WARN_ON(!port->port.count);
364 372
365 /* pass on to the driver specific version of this function if it is available */ 373 /* pass on to the driver specific version of this function
374 if it is available */
366 if (port->serial->type->ioctl) { 375 if (port->serial->type->ioctl) {
367 lock_kernel(); 376 lock_kernel();
368 retval = port->serial->type->ioctl(port, file, cmd, arg); 377 retval = port->serial->type->ioctl(tty, file, cmd, arg);
369 unlock_kernel(); 378 unlock_kernel();
370 } 379 } else
371 else
372 retval = -ENOIOCTLCMD; 380 retval = -ENOIOCTLCMD;
373 return retval; 381 return retval;
374} 382}
375 383
376static void serial_set_termios (struct tty_struct *tty, struct ktermios * old) 384static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
377{ 385{
378 struct usb_serial_port *port = tty->driver_data; 386 struct usb_serial_port *port = tty->driver_data;
379 dbg("%s - port %d", __func__, port->number); 387 dbg("%s - port %d", __func__, port->number);
380 388
381 WARN_ON(!port->open_count); 389 WARN_ON(!port->port.count);
382 /* pass on to the driver specific version of this function if it is available */ 390 /* pass on to the driver specific version of this function
391 if it is available */
383 if (port->serial->type->set_termios) 392 if (port->serial->type->set_termios)
384 port->serial->type->set_termios(port, old); 393 port->serial->type->set_termios(tty, port, old);
385 else 394 else
386 tty_termios_copy_hw(tty->termios, old); 395 tty_termios_copy_hw(tty->termios, old);
387} 396}
388 397
389static void serial_break (struct tty_struct *tty, int break_state) 398static int serial_break(struct tty_struct *tty, int break_state)
390{ 399{
391 struct usb_serial_port *port = tty->driver_data; 400 struct usb_serial_port *port = tty->driver_data;
392 401
393 dbg("%s - port %d", __func__, port->number); 402 dbg("%s - port %d", __func__, port->number);
394 403
395 WARN_ON(!port->open_count); 404 WARN_ON(!port->port.count);
396 /* pass on to the driver specific version of this function if it is available */ 405 /* pass on to the driver specific version of this function
406 if it is available */
397 if (port->serial->type->break_ctl) { 407 if (port->serial->type->break_ctl) {
398 lock_kernel(); 408 lock_kernel();
399 port->serial->type->break_ctl(port, break_state); 409 port->serial->type->break_ctl(tty, break_state);
400 unlock_kernel(); 410 unlock_kernel();
401 } 411 }
412 return 0;
402} 413}
403 414
404static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) 415static int serial_read_proc(char *page, char **start, off_t off, int count,
416 int *eof, void *data)
405{ 417{
406 struct usb_serial *serial; 418 struct usb_serial *serial;
407 int length = 0; 419 int length = 0;
@@ -410,26 +422,29 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int
410 char tmp[40]; 422 char tmp[40];
411 423
412 dbg("%s", __func__); 424 dbg("%s", __func__);
413 length += sprintf (page, "usbserinfo:1.0 driver:2.0\n"); 425 length += sprintf(page, "usbserinfo:1.0 driver:2.0\n");
414 for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) { 426 for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) {
415 serial = usb_serial_get_by_index(i); 427 serial = usb_serial_get_by_index(i);
416 if (serial == NULL) 428 if (serial == NULL)
417 continue; 429 continue;
418 430
419 length += sprintf (page+length, "%d:", i); 431 length += sprintf(page+length, "%d:", i);
420 if (serial->type->driver.owner) 432 if (serial->type->driver.owner)
421 length += sprintf (page+length, " module:%s", module_name(serial->type->driver.owner)); 433 length += sprintf(page+length, " module:%s",
422 length += sprintf (page+length, " name:\"%s\"", serial->type->description); 434 module_name(serial->type->driver.owner));
423 length += sprintf (page+length, " vendor:%04x product:%04x", 435 length += sprintf(page+length, " name:\"%s\"",
424 le16_to_cpu(serial->dev->descriptor.idVendor), 436 serial->type->description);
425 le16_to_cpu(serial->dev->descriptor.idProduct)); 437 length += sprintf(page+length, " vendor:%04x product:%04x",
426 length += sprintf (page+length, " num_ports:%d", serial->num_ports); 438 le16_to_cpu(serial->dev->descriptor.idVendor),
427 length += sprintf (page+length, " port:%d", i - serial->minor + 1); 439 le16_to_cpu(serial->dev->descriptor.idProduct));
428 440 length += sprintf(page+length, " num_ports:%d",
441 serial->num_ports);
442 length += sprintf(page+length, " port:%d",
443 i - serial->minor + 1);
429 usb_make_path(serial->dev, tmp, sizeof(tmp)); 444 usb_make_path(serial->dev, tmp, sizeof(tmp));
430 length += sprintf (page+length, " path:%s", tmp); 445 length += sprintf(page+length, " path:%s", tmp);
431 446
432 length += sprintf (page+length, "\n"); 447 length += sprintf(page+length, "\n");
433 if ((length + begin) > (off + count)) { 448 if ((length + begin) > (off + count)) {
434 usb_serial_put(serial); 449 usb_serial_put(serial);
435 goto done; 450 goto done;
@@ -445,31 +460,31 @@ done:
445 if (off >= (length + begin)) 460 if (off >= (length + begin))
446 return 0; 461 return 0;
447 *start = page + (off-begin); 462 *start = page + (off-begin);
448 return ((count < begin+length-off) ? count : begin+length-off); 463 return (count < begin+length-off) ? count : begin+length-off;
449} 464}
450 465
451static int serial_tiocmget (struct tty_struct *tty, struct file *file) 466static int serial_tiocmget(struct tty_struct *tty, struct file *file)
452{ 467{
453 struct usb_serial_port *port = tty->driver_data; 468 struct usb_serial_port *port = tty->driver_data;
454 469
455 dbg("%s - port %d", __func__, port->number); 470 dbg("%s - port %d", __func__, port->number);
456 471
457 WARN_ON(!port->open_count); 472 WARN_ON(!port->port.count);
458 if (port->serial->type->tiocmget) 473 if (port->serial->type->tiocmget)
459 return port->serial->type->tiocmget(port, file); 474 return port->serial->type->tiocmget(tty, file);
460 return -EINVAL; 475 return -EINVAL;
461} 476}
462 477
463static int serial_tiocmset (struct tty_struct *tty, struct file *file, 478static int serial_tiocmset(struct tty_struct *tty, struct file *file,
464 unsigned int set, unsigned int clear) 479 unsigned int set, unsigned int clear)
465{ 480{
466 struct usb_serial_port *port = tty->driver_data; 481 struct usb_serial_port *port = tty->driver_data;
467 482
468 dbg("%s - port %d", __func__, port->number); 483 dbg("%s - port %d", __func__, port->number);
469 484
470 WARN_ON(!port->open_count); 485 WARN_ON(!port->port.count);
471 if (port->serial->type->tiocmset) 486 if (port->serial->type->tiocmset)
472 return port->serial->type->tiocmset(port, file, set, clear); 487 return port->serial->type->tiocmset(tty, file, set, clear);
473 return -EINVAL; 488 return -EINVAL;
474} 489}
475 490
@@ -482,6 +497,7 @@ void usb_serial_port_softint(struct usb_serial_port *port)
482{ 497{
483 schedule_work(&port->work); 498 schedule_work(&port->work);
484} 499}
500EXPORT_SYMBOL_GPL(usb_serial_port_softint);
485 501
486static void usb_serial_port_work(struct work_struct *work) 502static void usb_serial_port_work(struct work_struct *work)
487{ 503{
@@ -490,11 +506,11 @@ static void usb_serial_port_work(struct work_struct *work)
490 struct tty_struct *tty; 506 struct tty_struct *tty;
491 507
492 dbg("%s - port %d", __func__, port->number); 508 dbg("%s - port %d", __func__, port->number);
493 509
494 if (!port) 510 if (!port)
495 return; 511 return;
496 512
497 tty = port->tty; 513 tty = port->port.tty;
498 if (!tty) 514 if (!tty)
499 return; 515 return;
500 516
@@ -505,7 +521,7 @@ static void port_release(struct device *dev)
505{ 521{
506 struct usb_serial_port *port = to_usb_serial_port(dev); 522 struct usb_serial_port *port = to_usb_serial_port(dev);
507 523
508 dbg ("%s - %s", __func__, dev->bus_id); 524 dbg ("%s - %s", __func__, dev_name(dev));
509 port_free(port); 525 port_free(port);
510} 526}
511 527
@@ -543,9 +559,9 @@ static void port_free(struct usb_serial_port *port)
543 kfree(port); 559 kfree(port);
544} 560}
545 561
546static struct usb_serial * create_serial (struct usb_device *dev, 562static struct usb_serial *create_serial(struct usb_device *dev,
547 struct usb_interface *interface, 563 struct usb_interface *interface,
548 struct usb_serial_driver *driver) 564 struct usb_serial_driver *driver)
549{ 565{
550 struct usb_serial *serial; 566 struct usb_serial *serial;
551 567
@@ -564,7 +580,7 @@ static struct usb_serial * create_serial (struct usb_device *dev,
564} 580}
565 581
566static const struct usb_device_id *match_dynamic_id(struct usb_interface *intf, 582static const struct usb_device_id *match_dynamic_id(struct usb_interface *intf,
567 struct usb_serial_driver *drv) 583 struct usb_serial_driver *drv)
568{ 584{
569 struct usb_dynid *dynid; 585 struct usb_dynid *dynid;
570 586
@@ -596,7 +612,8 @@ exit:
596 return id; 612 return id;
597} 613}
598 614
599static struct usb_serial_driver *search_serial_device(struct usb_interface *iface) 615static struct usb_serial_driver *search_serial_device(
616 struct usb_interface *iface)
600{ 617{
601 const struct usb_device_id *id; 618 const struct usb_device_id *id;
602 struct usb_serial_driver *drv; 619 struct usb_serial_driver *drv;
@@ -614,7 +631,7 @@ static struct usb_serial_driver *search_serial_device(struct usb_interface *ifac
614int usb_serial_probe(struct usb_interface *interface, 631int usb_serial_probe(struct usb_interface *interface,
615 const struct usb_device_id *id) 632 const struct usb_device_id *id)
616{ 633{
617 struct usb_device *dev = interface_to_usbdev (interface); 634 struct usb_device *dev = interface_to_usbdev(interface);
618 struct usb_serial *serial = NULL; 635 struct usb_serial *serial = NULL;
619 struct usb_serial_port *port; 636 struct usb_serial_port *port;
620 struct usb_host_interface *iface_desc; 637 struct usb_host_interface *iface_desc;
@@ -625,7 +642,7 @@ int usb_serial_probe(struct usb_interface *interface,
625 struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS]; 642 struct usb_endpoint_descriptor *bulk_out_endpoint[MAX_NUM_PORTS];
626 struct usb_serial_driver *type = NULL; 643 struct usb_serial_driver *type = NULL;
627 int retval; 644 int retval;
628 int minor; 645 unsigned int minor;
629 int buffer_size; 646 int buffer_size;
630 int i; 647 int i;
631 int num_interrupt_in = 0; 648 int num_interrupt_in = 0;
@@ -643,7 +660,7 @@ int usb_serial_probe(struct usb_interface *interface,
643 return -ENODEV; 660 return -ENODEV;
644 } 661 }
645 662
646 serial = create_serial (dev, interface, type); 663 serial = create_serial(dev, interface, type);
647 if (!serial) { 664 if (!serial) {
648 unlock_kernel(); 665 unlock_kernel();
649 dev_err(&interface->dev, "%s - out of memory\n", __func__); 666 dev_err(&interface->dev, "%s - out of memory\n", __func__);
@@ -656,8 +673,9 @@ int usb_serial_probe(struct usb_interface *interface,
656 673
657 if (!try_module_get(type->driver.owner)) { 674 if (!try_module_get(type->driver.owner)) {
658 unlock_kernel(); 675 unlock_kernel();
659 dev_err(&interface->dev, "module get failed, exiting\n"); 676 dev_err(&interface->dev,
660 kfree (serial); 677 "module get failed, exiting\n");
678 kfree(serial);
661 return -EIO; 679 return -EIO;
662 } 680 }
663 681
@@ -667,8 +685,8 @@ int usb_serial_probe(struct usb_interface *interface,
667 685
668 if (retval) { 686 if (retval) {
669 unlock_kernel(); 687 unlock_kernel();
670 dbg ("sub driver rejected device"); 688 dbg("sub driver rejected device");
671 kfree (serial); 689 kfree(serial);
672 return retval; 690 return retval;
673 } 691 }
674 } 692 }
@@ -709,7 +727,7 @@ int usb_serial_probe(struct usb_interface *interface,
709 } 727 }
710 728
711#if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE) 729#if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE)
712 /* BEGIN HORRIBLE HACK FOR PL2303 */ 730 /* BEGIN HORRIBLE HACK FOR PL2303 */
713 /* this is needed due to the looney way its endpoints are set up */ 731 /* this is needed due to the looney way its endpoints are set up */
714 if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) && 732 if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) &&
715 (le16_to_cpu(dev->descriptor.idProduct) == PL2303_PRODUCT_ID)) || 733 (le16_to_cpu(dev->descriptor.idProduct) == PL2303_PRODUCT_ID)) ||
@@ -738,7 +756,7 @@ int usb_serial_probe(struct usb_interface *interface,
738 if (num_bulk_in == 0 || num_bulk_out == 0) { 756 if (num_bulk_in == 0 || num_bulk_out == 0) {
739 unlock_kernel(); 757 unlock_kernel();
740 dev_info(&interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n"); 758 dev_info(&interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n");
741 kfree (serial); 759 kfree(serial);
742 return -ENODEV; 760 return -ENODEV;
743 } 761 }
744 } 762 }
@@ -750,8 +768,9 @@ int usb_serial_probe(struct usb_interface *interface,
750 num_ports = num_bulk_out; 768 num_ports = num_bulk_out;
751 if (num_ports == 0) { 769 if (num_ports == 0) {
752 unlock_kernel(); 770 unlock_kernel();
753 dev_err(&interface->dev, "Generic device with no bulk out, not allowed.\n"); 771 dev_err(&interface->dev,
754 kfree (serial); 772 "Generic device with no bulk out, not allowed.\n");
773 kfree(serial);
755 return -EIO; 774 return -EIO;
756 } 775 }
757 } 776 }
@@ -761,11 +780,12 @@ int usb_serial_probe(struct usb_interface *interface,
761 if (type->calc_num_ports) { 780 if (type->calc_num_ports) {
762 if (!try_module_get(type->driver.owner)) { 781 if (!try_module_get(type->driver.owner)) {
763 unlock_kernel(); 782 unlock_kernel();
764 dev_err(&interface->dev, "module get failed, exiting\n"); 783 dev_err(&interface->dev,
765 kfree (serial); 784 "module get failed, exiting\n");
785 kfree(serial);
766 return -EIO; 786 return -EIO;
767 } 787 }
768 num_ports = type->calc_num_ports (serial); 788 num_ports = type->calc_num_ports(serial);
769 module_put(type->driver.owner); 789 module_put(type->driver.owner);
770 } 790 }
771 if (!num_ports) 791 if (!num_ports)
@@ -783,7 +803,8 @@ int usb_serial_probe(struct usb_interface *interface,
783 type->description); 803 type->description);
784 804
785 /* create our ports, we need as many as the max endpoints */ 805 /* create our ports, we need as many as the max endpoints */
786 /* we don't use num_ports here cauz some devices have more endpoint pairs than ports */ 806 /* we don't use num_ports here because some devices have more
807 endpoint pairs than ports */
787 max_endpoints = max(num_bulk_in, num_bulk_out); 808 max_endpoints = max(num_bulk_in, num_bulk_out);
788 max_endpoints = max(max_endpoints, num_interrupt_in); 809 max_endpoints = max(max_endpoints, num_interrupt_in);
789 max_endpoints = max(max_endpoints, num_interrupt_out); 810 max_endpoints = max(max_endpoints, num_interrupt_out);
@@ -791,7 +812,8 @@ int usb_serial_probe(struct usb_interface *interface,
791 serial->num_port_pointers = max_endpoints; 812 serial->num_port_pointers = max_endpoints;
792 unlock_kernel(); 813 unlock_kernel();
793 814
794 dbg("%s - setting up %d port structures for this device", __func__, max_endpoints); 815 dbg("%s - setting up %d port structures for this device",
816 __func__, max_endpoints);
795 for (i = 0; i < max_endpoints; ++i) { 817 for (i = 0; i < max_endpoints; ++i) {
796 port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); 818 port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
797 if (!port) 819 if (!port)
@@ -807,7 +829,7 @@ int usb_serial_probe(struct usb_interface *interface,
807 for (i = 0; i < num_bulk_in; ++i) { 829 for (i = 0; i < num_bulk_in; ++i) {
808 endpoint = bulk_in_endpoint[i]; 830 endpoint = bulk_in_endpoint[i];
809 port = serial->port[i]; 831 port = serial->port[i];
810 port->read_urb = usb_alloc_urb (0, GFP_KERNEL); 832 port->read_urb = usb_alloc_urb(0, GFP_KERNEL);
811 if (!port->read_urb) { 833 if (!port->read_urb) {
812 dev_err(&interface->dev, "No free urbs available\n"); 834 dev_err(&interface->dev, "No free urbs available\n");
813 goto probe_error; 835 goto probe_error;
@@ -815,17 +837,17 @@ int usb_serial_probe(struct usb_interface *interface,
815 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 837 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
816 port->bulk_in_size = buffer_size; 838 port->bulk_in_size = buffer_size;
817 port->bulk_in_endpointAddress = endpoint->bEndpointAddress; 839 port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
818 port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL); 840 port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
819 if (!port->bulk_in_buffer) { 841 if (!port->bulk_in_buffer) {
820 dev_err(&interface->dev, "Couldn't allocate bulk_in_buffer\n"); 842 dev_err(&interface->dev,
843 "Couldn't allocate bulk_in_buffer\n");
821 goto probe_error; 844 goto probe_error;
822 } 845 }
823 usb_fill_bulk_urb (port->read_urb, dev, 846 usb_fill_bulk_urb(port->read_urb, dev,
824 usb_rcvbulkpipe (dev, 847 usb_rcvbulkpipe(dev,
825 endpoint->bEndpointAddress), 848 endpoint->bEndpointAddress),
826 port->bulk_in_buffer, buffer_size, 849 port->bulk_in_buffer, buffer_size,
827 serial->type->read_bulk_callback, 850 serial->type->read_bulk_callback, port);
828 port);
829 } 851 }
830 852
831 for (i = 0; i < num_bulk_out; ++i) { 853 for (i = 0; i < num_bulk_out; ++i) {
@@ -839,17 +861,17 @@ int usb_serial_probe(struct usb_interface *interface,
839 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 861 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
840 port->bulk_out_size = buffer_size; 862 port->bulk_out_size = buffer_size;
841 port->bulk_out_endpointAddress = endpoint->bEndpointAddress; 863 port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
842 port->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL); 864 port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
843 if (!port->bulk_out_buffer) { 865 if (!port->bulk_out_buffer) {
844 dev_err(&interface->dev, "Couldn't allocate bulk_out_buffer\n"); 866 dev_err(&interface->dev,
867 "Couldn't allocate bulk_out_buffer\n");
845 goto probe_error; 868 goto probe_error;
846 } 869 }
847 usb_fill_bulk_urb (port->write_urb, dev, 870 usb_fill_bulk_urb(port->write_urb, dev,
848 usb_sndbulkpipe (dev, 871 usb_sndbulkpipe(dev,
849 endpoint->bEndpointAddress), 872 endpoint->bEndpointAddress),
850 port->bulk_out_buffer, buffer_size, 873 port->bulk_out_buffer, buffer_size,
851 serial->type->write_bulk_callback, 874 serial->type->write_bulk_callback, port);
852 port);
853 } 875 }
854 876
855 if (serial->type->read_int_callback) { 877 if (serial->type->read_int_callback) {
@@ -858,73 +880,82 @@ int usb_serial_probe(struct usb_interface *interface,
858 port = serial->port[i]; 880 port = serial->port[i];
859 port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); 881 port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
860 if (!port->interrupt_in_urb) { 882 if (!port->interrupt_in_urb) {
861 dev_err(&interface->dev, "No free urbs available\n"); 883 dev_err(&interface->dev,
884 "No free urbs available\n");
862 goto probe_error; 885 goto probe_error;
863 } 886 }
864 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 887 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
865 port->interrupt_in_endpointAddress = endpoint->bEndpointAddress; 888 port->interrupt_in_endpointAddress =
866 port->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL); 889 endpoint->bEndpointAddress;
890 port->interrupt_in_buffer = kmalloc(buffer_size,
891 GFP_KERNEL);
867 if (!port->interrupt_in_buffer) { 892 if (!port->interrupt_in_buffer) {
868 dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer\n"); 893 dev_err(&interface->dev,
894 "Couldn't allocate interrupt_in_buffer\n");
869 goto probe_error; 895 goto probe_error;
870 } 896 }
871 usb_fill_int_urb (port->interrupt_in_urb, dev, 897 usb_fill_int_urb(port->interrupt_in_urb, dev,
872 usb_rcvintpipe (dev, 898 usb_rcvintpipe(dev,
873 endpoint->bEndpointAddress), 899 endpoint->bEndpointAddress),
874 port->interrupt_in_buffer, buffer_size, 900 port->interrupt_in_buffer, buffer_size,
875 serial->type->read_int_callback, port, 901 serial->type->read_int_callback, port,
876 endpoint->bInterval); 902 endpoint->bInterval);
877 } 903 }
878 } else if (num_interrupt_in) { 904 } else if (num_interrupt_in) {
879 dbg("the device claims to support interrupt in transfers, but read_int_callback is not defined"); 905 dbg("the device claims to support interrupt in transfers, but read_int_callback is not defined");
880 } 906 }
881 907
882 if (serial->type->write_int_callback) { 908 if (serial->type->write_int_callback) {
883 for (i = 0; i < num_interrupt_out; ++i) { 909 for (i = 0; i < num_interrupt_out; ++i) {
884 endpoint = interrupt_out_endpoint[i]; 910 endpoint = interrupt_out_endpoint[i];
885 port = serial->port[i]; 911 port = serial->port[i];
886 port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); 912 port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
887 if (!port->interrupt_out_urb) { 913 if (!port->interrupt_out_urb) {
888 dev_err(&interface->dev, "No free urbs available\n"); 914 dev_err(&interface->dev,
915 "No free urbs available\n");
889 goto probe_error; 916 goto probe_error;
890 } 917 }
891 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 918 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
892 port->interrupt_out_size = buffer_size; 919 port->interrupt_out_size = buffer_size;
893 port->interrupt_out_endpointAddress = endpoint->bEndpointAddress; 920 port->interrupt_out_endpointAddress =
894 port->interrupt_out_buffer = kmalloc (buffer_size, GFP_KERNEL); 921 endpoint->bEndpointAddress;
922 port->interrupt_out_buffer = kmalloc(buffer_size,
923 GFP_KERNEL);
895 if (!port->interrupt_out_buffer) { 924 if (!port->interrupt_out_buffer) {
896 dev_err(&interface->dev, "Couldn't allocate interrupt_out_buffer\n"); 925 dev_err(&interface->dev,
926 "Couldn't allocate interrupt_out_buffer\n");
897 goto probe_error; 927 goto probe_error;
898 } 928 }
899 usb_fill_int_urb (port->interrupt_out_urb, dev, 929 usb_fill_int_urb(port->interrupt_out_urb, dev,
900 usb_sndintpipe (dev, 930 usb_sndintpipe(dev,
901 endpoint->bEndpointAddress), 931 endpoint->bEndpointAddress),
902 port->interrupt_out_buffer, buffer_size, 932 port->interrupt_out_buffer, buffer_size,
903 serial->type->write_int_callback, port, 933 serial->type->write_int_callback, port,
904 endpoint->bInterval); 934 endpoint->bInterval);
905 } 935 }
906 } else if (num_interrupt_out) { 936 } else if (num_interrupt_out) {
907 dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined"); 937 dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined");
908 } 938 }
909 939
910 /* if this device type has an attach function, call it */ 940 /* if this device type has an attach function, call it */
911 if (type->attach) { 941 if (type->attach) {
912 if (!try_module_get(type->driver.owner)) { 942 if (!try_module_get(type->driver.owner)) {
913 dev_err(&interface->dev, "module get failed, exiting\n"); 943 dev_err(&interface->dev,
944 "module get failed, exiting\n");
914 goto probe_error; 945 goto probe_error;
915 } 946 }
916 retval = type->attach (serial); 947 retval = type->attach(serial);
917 module_put(type->driver.owner); 948 module_put(type->driver.owner);
918 if (retval < 0) 949 if (retval < 0)
919 goto probe_error; 950 goto probe_error;
920 if (retval > 0) { 951 if (retval > 0) {
921 /* quietly accept this device, but don't bind to a serial port 952 /* quietly accept this device, but don't bind to a
922 * as it's about to disappear */ 953 serial port as it's about to disappear */
923 goto exit; 954 goto exit;
924 } 955 }
925 } 956 }
926 957
927 if (get_free_serial (serial, num_ports, &minor) == NULL) { 958 if (get_free_serial(serial, num_ports, &minor) == NULL) {
928 dev_err(&interface->dev, "No more free serial devices\n"); 959 dev_err(&interface->dev, "No more free serial devices\n");
929 goto probe_error; 960 goto probe_error;
930 } 961 }
@@ -938,19 +969,19 @@ int usb_serial_probe(struct usb_interface *interface,
938 port->dev.bus = &usb_serial_bus_type; 969 port->dev.bus = &usb_serial_bus_type;
939 port->dev.release = &port_release; 970 port->dev.release = &port_release;
940 971
941 snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number); 972 dev_set_name(&port->dev, "ttyUSB%d", port->number);
942 dbg ("%s - registering %s", __func__, port->dev.bus_id); 973 dbg ("%s - registering %s", __func__, dev_name(&port->dev));
943 retval = device_register(&port->dev); 974 retval = device_register(&port->dev);
944 if (retval) 975 if (retval)
945 dev_err(&port->dev, "Error registering port device, " 976 dev_err(&port->dev, "Error registering port device, "
946 "continuing\n"); 977 "continuing\n");
947 } 978 }
948 979
949 usb_serial_console_init (debug, minor); 980 usb_serial_console_init(debug, minor);
950 981
951exit: 982exit:
952 /* success */ 983 /* success */
953 usb_set_intfdata (interface, serial); 984 usb_set_intfdata(interface, serial);
954 return 0; 985 return 0;
955 986
956probe_error: 987probe_error:
@@ -986,29 +1017,30 @@ probe_error:
986 /* free up any memory that we allocated */ 1017 /* free up any memory that we allocated */
987 for (i = 0; i < serial->num_port_pointers; ++i) 1018 for (i = 0; i < serial->num_port_pointers; ++i)
988 kfree(serial->port[i]); 1019 kfree(serial->port[i]);
989 kfree (serial); 1020 kfree(serial);
990 return -EIO; 1021 return -EIO;
991} 1022}
1023EXPORT_SYMBOL_GPL(usb_serial_probe);
992 1024
993void usb_serial_disconnect(struct usb_interface *interface) 1025void usb_serial_disconnect(struct usb_interface *interface)
994{ 1026{
995 int i; 1027 int i;
996 struct usb_serial *serial = usb_get_intfdata (interface); 1028 struct usb_serial *serial = usb_get_intfdata(interface);
997 struct device *dev = &interface->dev; 1029 struct device *dev = &interface->dev;
998 struct usb_serial_port *port; 1030 struct usb_serial_port *port;
999 1031
1000 usb_serial_console_disconnect(serial); 1032 usb_serial_console_disconnect(serial);
1001 dbg ("%s", __func__); 1033 dbg("%s", __func__);
1002 1034
1003 mutex_lock(&serial->disc_mutex); 1035 mutex_lock(&serial->disc_mutex);
1004 usb_set_intfdata (interface, NULL); 1036 usb_set_intfdata(interface, NULL);
1005 /* must set a flag, to signal subdrivers */ 1037 /* must set a flag, to signal subdrivers */
1006 serial->disconnected = 1; 1038 serial->disconnected = 1;
1007 for (i = 0; i < serial->num_ports; ++i) { 1039 for (i = 0; i < serial->num_ports; ++i) {
1008 port = serial->port[i]; 1040 port = serial->port[i];
1009 if (port) { 1041 if (port) {
1010 if (port->tty) 1042 if (port->port.tty)
1011 tty_hangup(port->tty); 1043 tty_hangup(port->port.tty);
1012 kill_traffic(port); 1044 kill_traffic(port);
1013 } 1045 }
1014 } 1046 }
@@ -1018,6 +1050,7 @@ void usb_serial_disconnect(struct usb_interface *interface)
1018 usb_serial_put(serial); 1050 usb_serial_put(serial);
1019 dev_info(dev, "device disconnected\n"); 1051 dev_info(dev, "device disconnected\n");
1020} 1052}
1053EXPORT_SYMBOL_GPL(usb_serial_disconnect);
1021 1054
1022int usb_serial_suspend(struct usb_interface *intf, pm_message_t message) 1055int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
1023{ 1056{
@@ -1076,9 +1109,8 @@ static int __init usb_serial_init(void)
1076 return -ENOMEM; 1109 return -ENOMEM;
1077 1110
1078 /* Initialize our global data */ 1111 /* Initialize our global data */
1079 for (i = 0; i < SERIAL_TTY_MINORS; ++i) { 1112 for (i = 0; i < SERIAL_TTY_MINORS; ++i)
1080 serial_table[i] = NULL; 1113 serial_table[i] = NULL;
1081 }
1082 1114
1083 result = bus_register(&usb_serial_bus_type); 1115 result = bus_register(&usb_serial_bus_type);
1084 if (result) { 1116 if (result) {
@@ -1093,9 +1125,11 @@ static int __init usb_serial_init(void)
1093 usb_serial_tty_driver->minor_start = 0; 1125 usb_serial_tty_driver->minor_start = 0;
1094 usb_serial_tty_driver->type = TTY_DRIVER_TYPE_SERIAL; 1126 usb_serial_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
1095 usb_serial_tty_driver->subtype = SERIAL_TYPE_NORMAL; 1127 usb_serial_tty_driver->subtype = SERIAL_TYPE_NORMAL;
1096 usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 1128 usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW |
1129 TTY_DRIVER_DYNAMIC_DEV;
1097 usb_serial_tty_driver->init_termios = tty_std_termios; 1130 usb_serial_tty_driver->init_termios = tty_std_termios;
1098 usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 1131 usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD
1132 | HUPCL | CLOCAL;
1099 usb_serial_tty_driver->init_termios.c_ispeed = 9600; 1133 usb_serial_tty_driver->init_termios.c_ispeed = 9600;
1100 usb_serial_tty_driver->init_termios.c_ospeed = 9600; 1134 usb_serial_tty_driver->init_termios.c_ospeed = 9600;
1101 tty_set_operations(usb_serial_tty_driver, &serial_ops); 1135 tty_set_operations(usb_serial_tty_driver, &serial_ops);
@@ -1133,7 +1167,7 @@ exit_reg_driver:
1133 bus_unregister(&usb_serial_bus_type); 1167 bus_unregister(&usb_serial_bus_type);
1134 1168
1135exit_bus: 1169exit_bus:
1136 err ("%s - returning with error %d", __func__, result); 1170 err("%s - returning with error %d", __func__, result);
1137 put_tty_driver(usb_serial_tty_driver); 1171 put_tty_driver(usb_serial_tty_driver);
1138 return result; 1172 return result;
1139} 1173}
@@ -1160,7 +1194,7 @@ module_exit(usb_serial_exit);
1160 if (!type->function) { \ 1194 if (!type->function) { \
1161 type->function = usb_serial_generic_##function; \ 1195 type->function = usb_serial_generic_##function; \
1162 dbg("Had to override the " #function \ 1196 dbg("Had to override the " #function \
1163 " usb serial operation with the generic one.");\ 1197 " usb serial operation with the generic one.");\
1164 } \ 1198 } \
1165 } while (0) 1199 } while (0)
1166 1200
@@ -1177,8 +1211,9 @@ static void fixup_generic(struct usb_serial_driver *device)
1177 set_to_generic_if_null(device, resume); 1211 set_to_generic_if_null(device, resume);
1178} 1212}
1179 1213
1180int usb_serial_register(struct usb_serial_driver *driver) /* must be called with BKL held */ 1214int usb_serial_register(struct usb_serial_driver *driver)
1181{ 1215{
1216 /* must be called with BKL held */
1182 int retval; 1217 int retval;
1183 1218
1184 fixup_generic(driver); 1219 fixup_generic(driver);
@@ -1191,37 +1226,30 @@ int usb_serial_register(struct usb_serial_driver *driver) /* must be called with
1191 1226
1192 retval = usb_serial_bus_register(driver); 1227 retval = usb_serial_bus_register(driver);
1193 if (retval) { 1228 if (retval) {
1194 err("problem %d when registering driver %s", retval, driver->description); 1229 err("problem %d when registering driver %s",
1230 retval, driver->description);
1195 list_del(&driver->driver_list); 1231 list_del(&driver->driver_list);
1196 } 1232 } else
1197 else 1233 info("USB Serial support registered for %s",
1198 info("USB Serial support registered for %s", driver->description); 1234 driver->description);
1199 1235
1200 return retval; 1236 return retval;
1201} 1237}
1238EXPORT_SYMBOL_GPL(usb_serial_register);
1202 1239
1203 1240
1204void usb_serial_deregister(struct usb_serial_driver *device) /* must be called with BKL held */ 1241void usb_serial_deregister(struct usb_serial_driver *device)
1205{ 1242{
1243 /* must be called with BKL held */
1206 info("USB Serial deregistering driver %s", device->description); 1244 info("USB Serial deregistering driver %s", device->description);
1207 list_del(&device->driver_list); 1245 list_del(&device->driver_list);
1208 usb_serial_bus_deregister(device); 1246 usb_serial_bus_deregister(device);
1209} 1247}
1210
1211
1212
1213/* If the usb-serial core is built into the core, the usb-serial drivers
1214 need these symbols to load properly as modules. */
1215EXPORT_SYMBOL_GPL(usb_serial_register);
1216EXPORT_SYMBOL_GPL(usb_serial_deregister); 1248EXPORT_SYMBOL_GPL(usb_serial_deregister);
1217EXPORT_SYMBOL_GPL(usb_serial_probe);
1218EXPORT_SYMBOL_GPL(usb_serial_disconnect);
1219EXPORT_SYMBOL_GPL(usb_serial_port_softint);
1220
1221 1249
1222/* Module information */ 1250/* Module information */
1223MODULE_AUTHOR( DRIVER_AUTHOR ); 1251MODULE_AUTHOR(DRIVER_AUTHOR);
1224MODULE_DESCRIPTION( DRIVER_DESC ); 1252MODULE_DESCRIPTION(DRIVER_DESC);
1225MODULE_LICENSE("GPL"); 1253MODULE_LICENSE("GPL");
1226 1254
1227module_param(debug, bool, S_IRUGO | S_IWUSR); 1255module_param(debug, bool, S_IRUGO | S_IWUSR);