diff options
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/oti6858.c | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index 933241f03fd8..cee9a52ca891 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -137,8 +137,8 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty); | |||
137 | static int oti6858_tiocmget(struct tty_struct *tty); | 137 | static int oti6858_tiocmget(struct tty_struct *tty); |
138 | static int oti6858_tiocmset(struct tty_struct *tty, | 138 | static int oti6858_tiocmset(struct tty_struct *tty, |
139 | unsigned int set, unsigned int clear); | 139 | unsigned int set, unsigned int clear); |
140 | static int oti6858_startup(struct usb_serial *serial); | 140 | static int oti6858_port_probe(struct usb_serial_port *port); |
141 | static void oti6858_release(struct usb_serial *serial); | 141 | static int oti6858_port_remove(struct usb_serial_port *port); |
142 | 142 | ||
143 | /* device info */ | 143 | /* device info */ |
144 | static struct usb_serial_driver oti6858_device = { | 144 | static struct usb_serial_driver oti6858_device = { |
@@ -161,8 +161,8 @@ static struct usb_serial_driver oti6858_device = { | |||
161 | .write_bulk_callback = oti6858_write_bulk_callback, | 161 | .write_bulk_callback = oti6858_write_bulk_callback, |
162 | .write_room = oti6858_write_room, | 162 | .write_room = oti6858_write_room, |
163 | .chars_in_buffer = oti6858_chars_in_buffer, | 163 | .chars_in_buffer = oti6858_chars_in_buffer, |
164 | .attach = oti6858_startup, | 164 | .port_probe = oti6858_port_probe, |
165 | .release = oti6858_release, | 165 | .port_remove = oti6858_port_remove, |
166 | }; | 166 | }; |
167 | 167 | ||
168 | static struct usb_serial_driver * const serial_drivers[] = { | 168 | static struct usb_serial_driver * const serial_drivers[] = { |
@@ -331,36 +331,33 @@ static void send_data(struct work_struct *work) | |||
331 | usb_serial_port_softint(port); | 331 | usb_serial_port_softint(port); |
332 | } | 332 | } |
333 | 333 | ||
334 | static int oti6858_startup(struct usb_serial *serial) | 334 | static int oti6858_port_probe(struct usb_serial_port *port) |
335 | { | 335 | { |
336 | struct usb_serial_port *port = serial->port[0]; | ||
337 | struct oti6858_private *priv; | 336 | struct oti6858_private *priv; |
338 | int i; | ||
339 | |||
340 | for (i = 0; i < serial->num_ports; ++i) { | ||
341 | priv = kzalloc(sizeof(struct oti6858_private), GFP_KERNEL); | ||
342 | if (!priv) | ||
343 | break; | ||
344 | |||
345 | spin_lock_init(&priv->lock); | ||
346 | init_waitqueue_head(&priv->intr_wait); | ||
347 | /* INIT_WORK(&priv->setup_work, setup_line, serial->port[i]); */ | ||
348 | /* INIT_WORK(&priv->write_work, send_data, serial->port[i]); */ | ||
349 | priv->port = port; | ||
350 | INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line); | ||
351 | INIT_DELAYED_WORK(&priv->delayed_write_work, send_data); | ||
352 | |||
353 | usb_set_serial_port_data(serial->port[i], priv); | ||
354 | } | ||
355 | if (i == serial->num_ports) | ||
356 | return 0; | ||
357 | 337 | ||
358 | for (--i; i >= 0; --i) { | 338 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
359 | priv = usb_get_serial_port_data(serial->port[i]); | 339 | if (!priv) |
360 | kfree(priv); | 340 | return -ENOMEM; |
361 | usb_set_serial_port_data(serial->port[i], NULL); | 341 | |
362 | } | 342 | spin_lock_init(&priv->lock); |
363 | return -ENOMEM; | 343 | init_waitqueue_head(&priv->intr_wait); |
344 | priv->port = port; | ||
345 | INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line); | ||
346 | INIT_DELAYED_WORK(&priv->delayed_write_work, send_data); | ||
347 | |||
348 | usb_set_serial_port_data(port, priv); | ||
349 | |||
350 | return 0; | ||
351 | } | ||
352 | |||
353 | static int oti6858_port_remove(struct usb_serial_port *port) | ||
354 | { | ||
355 | struct oti6858_private *priv; | ||
356 | |||
357 | priv = usb_get_serial_port_data(port); | ||
358 | kfree(priv); | ||
359 | |||
360 | return 0; | ||
364 | } | 361 | } |
365 | 362 | ||
366 | static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port, | 363 | static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port, |
@@ -709,15 +706,6 @@ static int oti6858_ioctl(struct tty_struct *tty, | |||
709 | return -ENOIOCTLCMD; | 706 | return -ENOIOCTLCMD; |
710 | } | 707 | } |
711 | 708 | ||
712 | |||
713 | static void oti6858_release(struct usb_serial *serial) | ||
714 | { | ||
715 | int i; | ||
716 | |||
717 | for (i = 0; i < serial->num_ports; ++i) | ||
718 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
719 | } | ||
720 | |||
721 | static void oti6858_read_int_callback(struct urb *urb) | 709 | static void oti6858_read_int_callback(struct urb *urb) |
722 | { | 710 | { |
723 | struct usb_serial_port *port = urb->context; | 711 | struct usb_serial_port *port = urb->context; |