diff options
Diffstat (limited to 'drivers/usb/serial/mct_u232.c')
-rw-r--r-- | drivers/usb/serial/mct_u232.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index f3947712e137..a8bce134ffba 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -49,7 +49,8 @@ | |||
49 | * Function prototypes | 49 | * Function prototypes |
50 | */ | 50 | */ |
51 | static int mct_u232_startup(struct usb_serial *serial); | 51 | static int mct_u232_startup(struct usb_serial *serial); |
52 | static void mct_u232_release(struct usb_serial *serial); | 52 | static int mct_u232_port_probe(struct usb_serial_port *port); |
53 | static int mct_u232_port_remove(struct usb_serial_port *remove); | ||
53 | static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port); | 54 | static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port); |
54 | static void mct_u232_close(struct usb_serial_port *port); | 55 | static void mct_u232_close(struct usb_serial_port *port); |
55 | static void mct_u232_dtr_rts(struct usb_serial_port *port, int on); | 56 | static void mct_u232_dtr_rts(struct usb_serial_port *port, int on); |
@@ -99,7 +100,8 @@ static struct usb_serial_driver mct_u232_device = { | |||
99 | .tiocmget = mct_u232_tiocmget, | 100 | .tiocmget = mct_u232_tiocmget, |
100 | .tiocmset = mct_u232_tiocmset, | 101 | .tiocmset = mct_u232_tiocmset, |
101 | .attach = mct_u232_startup, | 102 | .attach = mct_u232_startup, |
102 | .release = mct_u232_release, | 103 | .port_probe = mct_u232_port_probe, |
104 | .port_remove = mct_u232_port_remove, | ||
103 | .ioctl = mct_u232_ioctl, | 105 | .ioctl = mct_u232_ioctl, |
104 | .get_icount = mct_u232_get_icount, | 106 | .get_icount = mct_u232_get_icount, |
105 | }; | 107 | }; |
@@ -388,18 +390,8 @@ static void mct_u232_msr_to_state(struct usb_serial_port *port, | |||
388 | 390 | ||
389 | static int mct_u232_startup(struct usb_serial *serial) | 391 | static int mct_u232_startup(struct usb_serial *serial) |
390 | { | 392 | { |
391 | struct mct_u232_private *priv; | ||
392 | struct usb_serial_port *port, *rport; | 393 | struct usb_serial_port *port, *rport; |
393 | 394 | ||
394 | priv = kzalloc(sizeof(struct mct_u232_private), GFP_KERNEL); | ||
395 | if (!priv) | ||
396 | return -ENOMEM; | ||
397 | spin_lock_init(&priv->lock); | ||
398 | init_waitqueue_head(&priv->msr_wait); | ||
399 | usb_set_serial_port_data(serial->port[0], priv); | ||
400 | |||
401 | init_waitqueue_head(&serial->port[0]->write_wait); | ||
402 | |||
403 | /* Puh, that's dirty */ | 395 | /* Puh, that's dirty */ |
404 | port = serial->port[0]; | 396 | port = serial->port[0]; |
405 | rport = serial->port[1]; | 397 | rport = serial->port[1]; |
@@ -412,18 +404,31 @@ static int mct_u232_startup(struct usb_serial *serial) | |||
412 | return 0; | 404 | return 0; |
413 | } /* mct_u232_startup */ | 405 | } /* mct_u232_startup */ |
414 | 406 | ||
407 | static int mct_u232_port_probe(struct usb_serial_port *port) | ||
408 | { | ||
409 | struct mct_u232_private *priv; | ||
410 | |||
411 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
412 | if (!priv) | ||
413 | return -ENOMEM; | ||
415 | 414 | ||
416 | static void mct_u232_release(struct usb_serial *serial) | 415 | spin_lock_init(&priv->lock); |
416 | init_waitqueue_head(&priv->msr_wait); | ||
417 | |||
418 | usb_set_serial_port_data(port, priv); | ||
419 | |||
420 | return 0; | ||
421 | } | ||
422 | |||
423 | static int mct_u232_port_remove(struct usb_serial_port *port) | ||
417 | { | 424 | { |
418 | struct mct_u232_private *priv; | 425 | struct mct_u232_private *priv; |
419 | int i; | ||
420 | 426 | ||
421 | for (i = 0; i < serial->num_ports; ++i) { | 427 | priv = usb_get_serial_port_data(port); |
422 | /* My special items, the standard routines free my urbs */ | 428 | kfree(priv); |
423 | priv = usb_get_serial_port_data(serial->port[i]); | 429 | |
424 | kfree(priv); | 430 | return 0; |
425 | } | 431 | } |
426 | } /* mct_u232_release */ | ||
427 | 432 | ||
428 | static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port) | 433 | static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port) |
429 | { | 434 | { |