diff options
Diffstat (limited to 'drivers/usb/serial/opticon.c')
| -rw-r--r-- | drivers/usb/serial/opticon.c | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index c6bfb83efb1..4856fb7e637 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c @@ -12,7 +12,6 @@ */ #include <linux/kernel.h> -#include <linux/init.h> #include <linux/tty.h> #include <linux/tty_driver.h> #include <linux/slab.h> @@ -51,15 +50,8 @@ struct opticon_private { static void opticon_process_data_packet(struct usb_serial_port *port, const unsigned char *buf, size_t len) { - struct tty_struct *tty; - - tty = tty_port_tty_get(&port->port); - if (!tty) - return; - - tty_insert_flip_string(tty, buf, len); - tty_flip_buffer_push(tty); - tty_kref_put(tty); + tty_insert_flip_string(&port->port, buf, len); + tty_flip_buffer_push(&port->port); } static void opticon_process_status_packet(struct usb_serial_port *port, @@ -127,7 +119,10 @@ static int send_control_msg(struct usb_serial_port *port, u8 requesttype, 0, 0, buffer, 1, 0); kfree(buffer); - return retval; + if (retval < 0) + return retval; + + return 0; } static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port) @@ -143,7 +138,7 @@ static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port) /* Clear RTS line */ send_control_msg(port, CONTROL_RTS, 0); - /* clear the halt status of the enpoint */ + /* clear the halt status of the endpoint */ usb_clear_halt(port->serial->dev, port->read_urb->pipe); res = usb_serial_generic_open(tty, port); @@ -204,15 +199,12 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, buffer = kmalloc(count, GFP_ATOMIC); if (!buffer) { - dev_err(&port->dev, "out of memory\n"); count = -ENOMEM; - goto error_no_buffer; } urb = usb_alloc_urb(0, GFP_ATOMIC); if (!urb) { - dev_err(&port->dev, "no more free urbs\n"); count = -ENOMEM; goto error_no_urb; } @@ -221,11 +213,10 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, usb_serial_debug_data(&port->dev, __func__, count, buffer); - /* The conncected devices do not have a bulk write endpoint, + /* The connected devices do not have a bulk write endpoint, * to transmit data to de barcode device the control endpoint is used */ dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); if (!dr) { - dev_err(&port->dev, "out of memory\n"); count = -ENOMEM; goto error_no_dr; } @@ -313,7 +304,6 @@ static int opticon_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear) { struct usb_serial_port *port = tty->driver_data; - struct usb_serial *serial = port->serial; struct opticon_private *priv = usb_get_serial_port_data(port); unsigned long flags; bool rts; @@ -334,15 +324,11 @@ static int opticon_tiocmset(struct tty_struct *tty, if (!changed) return 0; - /* Send the new RTS state to the connected device */ - mutex_lock(&serial->disc_mutex); - if (!serial->disconnected) - ret = send_control_msg(port, CONTROL_RTS, !rts); - else - ret = -ENODEV; - mutex_unlock(&serial->disc_mutex); + ret = send_control_msg(port, CONTROL_RTS, !rts); + if (ret) + return usb_translate_errors(ret); - return ret; + return 0; } static int get_serial_info(struct usb_serial_port *port, @@ -357,7 +343,7 @@ static int get_serial_info(struct usb_serial_port *port, /* fake emulate a 16550 uart to make userspace code happy */ tmp.type = PORT_16550A; - tmp.line = port->serial->minor; + tmp.line = port->minor; tmp.port = 0; tmp.irq = 0; tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; @@ -376,8 +362,6 @@ static int opticon_ioctl(struct tty_struct *tty, { struct usb_serial_port *port = tty->driver_data; - dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd); - switch (cmd) { case TIOCGSERIAL: return get_serial_info(port, |
