USB: serial: ir-usb: make set_termios synchronous
Use a synchronous usb_bulk_msg() when switching link speed in set_termios(). This way we do not need to keep track of outstanding URBs in order to be able to stop them at close. Note that there's no need to set URB_ZERO_PACKET as the one-byte transfer will always be short. Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org>
This commit is contained in:
parent
38c0d5bdf4
commit
e7542bc382
@ -376,23 +376,15 @@ static void ir_process_read_urb(struct urb *urb)
|
|||||||
tty_flip_buffer_push(&port->port);
|
tty_flip_buffer_push(&port->port);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ir_set_termios_callback(struct urb *urb)
|
|
||||||
{
|
|
||||||
kfree(urb->transfer_buffer);
|
|
||||||
|
|
||||||
if (urb->status)
|
|
||||||
dev_dbg(&urb->dev->dev, "%s - non-zero urb status: %d\n",
|
|
||||||
__func__, urb->status);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ir_set_termios(struct tty_struct *tty,
|
static void ir_set_termios(struct tty_struct *tty,
|
||||||
struct usb_serial_port *port, struct ktermios *old_termios)
|
struct usb_serial_port *port, struct ktermios *old_termios)
|
||||||
{
|
{
|
||||||
struct urb *urb;
|
struct usb_device *udev = port->serial->dev;
|
||||||
unsigned char *transfer_buffer;
|
unsigned char *transfer_buffer;
|
||||||
int result;
|
int actual_length;
|
||||||
speed_t baud;
|
speed_t baud;
|
||||||
int ir_baud;
|
int ir_baud;
|
||||||
|
int ret;
|
||||||
|
|
||||||
baud = tty_get_baud_rate(tty);
|
baud = tty_get_baud_rate(tty);
|
||||||
|
|
||||||
@ -447,42 +439,22 @@ static void ir_set_termios(struct tty_struct *tty,
|
|||||||
/*
|
/*
|
||||||
* send the baud change out on an "empty" data packet
|
* send the baud change out on an "empty" data packet
|
||||||
*/
|
*/
|
||||||
urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
||||||
if (!urb)
|
|
||||||
return;
|
|
||||||
|
|
||||||
transfer_buffer = kmalloc(1, GFP_KERNEL);
|
transfer_buffer = kmalloc(1, GFP_KERNEL);
|
||||||
if (!transfer_buffer)
|
if (!transfer_buffer)
|
||||||
goto err_buf;
|
return;
|
||||||
|
|
||||||
*transfer_buffer = ir_xbof | ir_baud;
|
*transfer_buffer = ir_xbof | ir_baud;
|
||||||
|
|
||||||
usb_fill_bulk_urb(
|
ret = usb_bulk_msg(udev,
|
||||||
urb,
|
usb_sndbulkpipe(udev, port->bulk_out_endpointAddress),
|
||||||
port->serial->dev,
|
transfer_buffer, 1, &actual_length, 5000);
|
||||||
usb_sndbulkpipe(port->serial->dev,
|
if (ret || actual_length != 1) {
|
||||||
port->bulk_out_endpointAddress),
|
if (actual_length != 1)
|
||||||
transfer_buffer,
|
ret = -EIO;
|
||||||
1,
|
dev_err(&port->dev, "failed to change line speed: %d\n", ret);
|
||||||
ir_set_termios_callback,
|
|
||||||
port);
|
|
||||||
|
|
||||||
urb->transfer_flags = URB_ZERO_PACKET;
|
|
||||||
|
|
||||||
result = usb_submit_urb(urb, GFP_KERNEL);
|
|
||||||
if (result) {
|
|
||||||
dev_err(&port->dev, "%s - failed to submit urb: %d\n",
|
|
||||||
__func__, result);
|
|
||||||
goto err_subm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_free_urb(urb);
|
|
||||||
|
|
||||||
return;
|
|
||||||
err_subm:
|
|
||||||
kfree(transfer_buffer);
|
kfree(transfer_buffer);
|
||||||
err_buf:
|
|
||||||
usb_free_urb(urb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init ir_init(void)
|
static int __init ir_init(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user