diff options
author | David S. Miller <davem@davemloft.net> | 2014-07-16 17:09:34 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-16 17:09:34 -0400 |
commit | 1a98c69af1ecd97bfd1f4e4539924a9192434e36 (patch) | |
tree | a243defcf921ea174f8e43fce11d06830a6a9c36 /drivers/net/usb/hso.c | |
parent | 7a575f6b907ea5d207d2b5010293c189616eae34 (diff) | |
parent | b6603fe574af289dbe9eb9fb4c540bca04f5a053 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb/hso.c')
-rw-r--r-- | drivers/net/usb/hso.c | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 50b36b299946..a36401802cec 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
@@ -258,10 +258,8 @@ struct hso_serial { | |||
258 | * so as not to drop characters on the floor. | 258 | * so as not to drop characters on the floor. |
259 | */ | 259 | */ |
260 | int curr_rx_urb_idx; | 260 | int curr_rx_urb_idx; |
261 | u16 curr_rx_urb_offset; | ||
262 | u8 rx_urb_filled[MAX_RX_URBS]; | 261 | u8 rx_urb_filled[MAX_RX_URBS]; |
263 | struct tasklet_struct unthrottle_tasklet; | 262 | struct tasklet_struct unthrottle_tasklet; |
264 | struct work_struct retry_unthrottle_workqueue; | ||
265 | }; | 263 | }; |
266 | 264 | ||
267 | struct hso_device { | 265 | struct hso_device { |
@@ -1252,14 +1250,6 @@ static void hso_unthrottle(struct tty_struct *tty) | |||
1252 | tasklet_hi_schedule(&serial->unthrottle_tasklet); | 1250 | tasklet_hi_schedule(&serial->unthrottle_tasklet); |
1253 | } | 1251 | } |
1254 | 1252 | ||
1255 | static void hso_unthrottle_workfunc(struct work_struct *work) | ||
1256 | { | ||
1257 | struct hso_serial *serial = | ||
1258 | container_of(work, struct hso_serial, | ||
1259 | retry_unthrottle_workqueue); | ||
1260 | hso_unthrottle_tasklet(serial); | ||
1261 | } | ||
1262 | |||
1263 | /* open the requested serial port */ | 1253 | /* open the requested serial port */ |
1264 | static int hso_serial_open(struct tty_struct *tty, struct file *filp) | 1254 | static int hso_serial_open(struct tty_struct *tty, struct file *filp) |
1265 | { | 1255 | { |
@@ -1295,8 +1285,6 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp) | |||
1295 | tasklet_init(&serial->unthrottle_tasklet, | 1285 | tasklet_init(&serial->unthrottle_tasklet, |
1296 | (void (*)(unsigned long))hso_unthrottle_tasklet, | 1286 | (void (*)(unsigned long))hso_unthrottle_tasklet, |
1297 | (unsigned long)serial); | 1287 | (unsigned long)serial); |
1298 | INIT_WORK(&serial->retry_unthrottle_workqueue, | ||
1299 | hso_unthrottle_workfunc); | ||
1300 | result = hso_start_serial_device(serial->parent, GFP_KERNEL); | 1288 | result = hso_start_serial_device(serial->parent, GFP_KERNEL); |
1301 | if (result) { | 1289 | if (result) { |
1302 | hso_stop_serial_device(serial->parent); | 1290 | hso_stop_serial_device(serial->parent); |
@@ -1345,7 +1333,6 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp) | |||
1345 | if (!usb_gone) | 1333 | if (!usb_gone) |
1346 | hso_stop_serial_device(serial->parent); | 1334 | hso_stop_serial_device(serial->parent); |
1347 | tasklet_kill(&serial->unthrottle_tasklet); | 1335 | tasklet_kill(&serial->unthrottle_tasklet); |
1348 | cancel_work_sync(&serial->retry_unthrottle_workqueue); | ||
1349 | } | 1336 | } |
1350 | 1337 | ||
1351 | if (!usb_gone) | 1338 | if (!usb_gone) |
@@ -2013,8 +2000,7 @@ static void ctrl_callback(struct urb *urb) | |||
2013 | static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) | 2000 | static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) |
2014 | { | 2001 | { |
2015 | struct tty_struct *tty; | 2002 | struct tty_struct *tty; |
2016 | int write_length_remaining = 0; | 2003 | int count; |
2017 | int curr_write_len; | ||
2018 | 2004 | ||
2019 | /* Sanity check */ | 2005 | /* Sanity check */ |
2020 | if (urb == NULL || serial == NULL) { | 2006 | if (urb == NULL || serial == NULL) { |
@@ -2024,29 +2010,28 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) | |||
2024 | 2010 | ||
2025 | tty = tty_port_tty_get(&serial->port); | 2011 | tty = tty_port_tty_get(&serial->port); |
2026 | 2012 | ||
2013 | if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { | ||
2014 | tty_kref_put(tty); | ||
2015 | return -1; | ||
2016 | } | ||
2017 | |||
2027 | /* Push data to tty */ | 2018 | /* Push data to tty */ |
2028 | write_length_remaining = urb->actual_length - | ||
2029 | serial->curr_rx_urb_offset; | ||
2030 | D1("data to push to tty"); | 2019 | D1("data to push to tty"); |
2031 | while (write_length_remaining) { | 2020 | count = tty_buffer_request_room(&serial->port, urb->actual_length); |
2032 | if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { | 2021 | if (count >= urb->actual_length) { |
2033 | tty_kref_put(tty); | 2022 | tty_insert_flip_string(&serial->port, urb->transfer_buffer, |
2034 | return -1; | 2023 | urb->actual_length); |
2035 | } | ||
2036 | curr_write_len = tty_insert_flip_string(&serial->port, | ||
2037 | urb->transfer_buffer + serial->curr_rx_urb_offset, | ||
2038 | write_length_remaining); | ||
2039 | serial->curr_rx_urb_offset += curr_write_len; | ||
2040 | write_length_remaining -= curr_write_len; | ||
2041 | tty_flip_buffer_push(&serial->port); | 2024 | tty_flip_buffer_push(&serial->port); |
2025 | } else { | ||
2026 | dev_warn(&serial->parent->usb->dev, | ||
2027 | "dropping data, %d bytes lost\n", urb->actual_length); | ||
2042 | } | 2028 | } |
2029 | |||
2043 | tty_kref_put(tty); | 2030 | tty_kref_put(tty); |
2044 | 2031 | ||
2045 | if (write_length_remaining == 0) { | 2032 | serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; |
2046 | serial->curr_rx_urb_offset = 0; | 2033 | |
2047 | serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; | 2034 | return 0; |
2048 | } | ||
2049 | return write_length_remaining; | ||
2050 | } | 2035 | } |
2051 | 2036 | ||
2052 | 2037 | ||
@@ -2217,7 +2202,6 @@ static int hso_stop_serial_device(struct hso_device *hso_dev) | |||
2217 | } | 2202 | } |
2218 | } | 2203 | } |
2219 | serial->curr_rx_urb_idx = 0; | 2204 | serial->curr_rx_urb_idx = 0; |
2220 | serial->curr_rx_urb_offset = 0; | ||
2221 | 2205 | ||
2222 | if (serial->tx_urb) | 2206 | if (serial->tx_urb) |
2223 | usb_kill_urb(serial->tx_urb); | 2207 | usb_kill_urb(serial->tx_urb); |