diff options
author | YAMANE Toshiaki <yamanetoshi@gmail.com> | 2012-11-10 06:34:11 +0900 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-13 13:15:25 -0800 |
commit | 04e9d11beb49538458af005f703cb666fc1d3ccf (patch) | |
tree | 38515ced390c3436d5baa7a45beaf81a83e6b2bd /drivers/staging/serqt_usb2 | |
parent | bbbd527b4f828a92c12ce619180820f1721d32ab (diff) |
staging/serqt_usb2: refactor qt_open() in serqt_usb2.c
Modified to eliminate the deep nesting.
Signed-off-by: YAMANE Toshiaki <yamanetoshi@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/serqt_usb2')
-rw-r--r-- | drivers/staging/serqt_usb2/serqt_usb2.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index 0395bdfeab10..4c475edebc6a 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -840,6 +840,31 @@ static void qt_release(struct usb_serial *serial) } +static void qt_submit_urb_from_open(struct usb_serial *serial, + struct usb_serial_port *port) +{ + int result; + struct usb_serial_port *port0 = serial->port[0]; + + /* set up interrupt urb */ + usb_fill_int_urb(port0->interrupt_in_urb, + serial->dev, + usb_rcvintpipe(serial->dev, + port0->interrupt_in_endpointAddress), + port0->interrupt_in_buffer, + port0->interrupt_in_urb->transfer_buffer_length, + qt_interrupt_callback, serial, + port0->interrupt_in_urb->interval); + + result = usb_submit_urb(port0->interrupt_in_urb, + GFP_KERNEL); + if (result) { + dev_err(&port->dev, + "%s - Error %d submitting interrupt urb\n", + __func__, result); + } +} + static int qt_open(struct tty_struct *tty, struct usb_serial_port *port) { @@ -900,30 +925,8 @@ static int qt_open(struct tty_struct *tty, /* Check to see if we've set up our endpoint info yet */ if (port0->open_ports == 1) { - if (serial->port[0]->interrupt_in_buffer == NULL) { - /* set up interrupt urb */ - usb_fill_int_urb(serial->port[0]->interrupt_in_urb, - serial->dev, - usb_rcvintpipe(serial->dev, - serial->port[0]->interrupt_in_endpointAddress), - serial->port[0]->interrupt_in_buffer, - serial->port[0]-> - interrupt_in_urb->transfer_buffer_length, - qt_interrupt_callback, serial, - serial->port[0]-> - interrupt_in_urb->interval); - - result = - usb_submit_urb(serial->port[0]->interrupt_in_urb, - GFP_KERNEL); - if (result) { - dev_err(&port->dev, - "%s - Error %d submitting " - "interrupt urb\n", __func__, result); - } - - } - + if (serial->port[0]->interrupt_in_buffer == NULL) + qt_submit_urb_from_open(serial, port); } dev_dbg(&port->dev, "port number is %d\n", port->number); |