diff options
author | Johan Hovold <jhovold@gmail.com> | 2009-10-07 14:05:06 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-10-09 16:52:05 -0400 |
commit | e63e278b4d2d867893962d3c7cd13a3a24ceb3f1 (patch) | |
tree | 356dffc7b4eb65e7052e58aabf523363e37867c1 | |
parent | 63b0061246b54b849da8f189ae048e8110d8ce7d (diff) |
USB: ftdi_sio: clean up read completion handler
Remove superfluous error checks in completion handler:
- No need to check private data and urb pointers as we check urb-status
before dereferencing priv (which is not freed until urb has been killed
on close).
- No need to check tty as it is checked again when processing.
- No need to check urb->number_of_packets on bulk urb.
Note that both private data and tty are checked again before processing
(possibly from work queue which also is cancelled on close).
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/serial/ftdi_sio.c | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index bfb23d64bc6a..75c84d9b080d 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -2008,39 +2008,14 @@ static int ftdi_chars_in_buffer(struct tty_struct *tty) | |||
2008 | static void ftdi_read_bulk_callback(struct urb *urb) | 2008 | static void ftdi_read_bulk_callback(struct urb *urb) |
2009 | { | 2009 | { |
2010 | struct usb_serial_port *port = urb->context; | 2010 | struct usb_serial_port *port = urb->context; |
2011 | struct tty_struct *tty; | ||
2012 | struct ftdi_private *priv; | 2011 | struct ftdi_private *priv; |
2013 | int status = urb->status; | 2012 | int status = urb->status; |
2014 | 2013 | ||
2015 | if (urb->number_of_packets > 0) { | ||
2016 | dev_err(&port->dev, "%s transfer_buffer_length %d " | ||
2017 | "actual_length %d number of packets %d\n", __func__, | ||
2018 | urb->transfer_buffer_length, | ||
2019 | urb->actual_length, urb->number_of_packets); | ||
2020 | dev_err(&port->dev, "%s transfer_flags %x\n", __func__, | ||
2021 | urb->transfer_flags); | ||
2022 | } | ||
2023 | |||
2024 | dbg("%s - port %d", __func__, port->number); | 2014 | dbg("%s - port %d", __func__, port->number); |
2025 | 2015 | ||
2026 | if (port->port.count <= 0) | 2016 | if (port->port.count <= 0) |
2027 | return; | 2017 | return; |
2028 | 2018 | ||
2029 | tty = tty_port_tty_get(&port->port); | ||
2030 | if (!tty) { | ||
2031 | dbg("%s - bad tty pointer - exiting", __func__); | ||
2032 | return; | ||
2033 | } | ||
2034 | |||
2035 | priv = usb_get_serial_port_data(port); | ||
2036 | if (!priv) { | ||
2037 | dbg("%s - bad port private data pointer - exiting", __func__); | ||
2038 | goto out; | ||
2039 | } | ||
2040 | |||
2041 | if (urb != port->read_urb) | ||
2042 | dev_err(&port->dev, "%s - Not my urb!\n", __func__); | ||
2043 | |||
2044 | if (status) { | 2019 | if (status) { |
2045 | /* This will happen at close every time so it is a dbg not an | 2020 | /* This will happen at close every time so it is a dbg not an |
2046 | err */ | 2021 | err */ |
@@ -2048,9 +2023,8 @@ static void ftdi_read_bulk_callback(struct urb *urb) | |||
2048 | goto out; | 2023 | goto out; |
2049 | } | 2024 | } |
2050 | 2025 | ||
2026 | priv = usb_get_serial_port_data(port); | ||
2051 | ftdi_process_read(&priv->rx_work.work); | 2027 | ftdi_process_read(&priv->rx_work.work); |
2052 | out: | ||
2053 | tty_kref_put(tty); | ||
2054 | } /* ftdi_read_bulk_callback */ | 2028 | } /* ftdi_read_bulk_callback */ |
2055 | 2029 | ||
2056 | 2030 | ||