diff options
author | Stefani Seibold <stefani@seibold.net> | 2009-12-23 03:10:48 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-23 11:53:31 -0500 |
commit | 119eecc831a42bd090543568932e440c6831f1bb (patch) | |
tree | fc57e3afc6e419522c1294787b03e3798f69ea43 | |
parent | c9f937e4a3f4ebf9924ec21d80632e5eb61d949c (diff) |
Fix usb_serial_probe() problem introduced by the recent kfifo changes
The USB serial code was a new user of the kfifo API, and it was missed
when porting things to the new kfifo API.
Please make the write_fifo in place. Here is my patch to fix the
regression and full ported version.
Signed-off-by: Stefani Seibold <stefani@seibold.net>
Reported-and-tested-by: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Greg KH <greg@kroah.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/usb/serial/generic.c | 12 | ||||
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 5 | ||||
-rw-r--r-- | include/linux/usb/serial.h | 3 |
3 files changed, 10 insertions, 10 deletions
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index b0f1183755c9..f1ea3a33b6e6 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -276,7 +276,7 @@ static int usb_serial_generic_write_start(struct usb_serial_port *port) | |||
276 | if (port->write_urb_busy) | 276 | if (port->write_urb_busy) |
277 | start_io = false; | 277 | start_io = false; |
278 | else { | 278 | else { |
279 | start_io = (kfifo_len(port->write_fifo) != 0); | 279 | start_io = (kfifo_len(&port->write_fifo) != 0); |
280 | port->write_urb_busy = start_io; | 280 | port->write_urb_busy = start_io; |
281 | } | 281 | } |
282 | spin_unlock_irqrestore(&port->lock, flags); | 282 | spin_unlock_irqrestore(&port->lock, flags); |
@@ -285,7 +285,7 @@ static int usb_serial_generic_write_start(struct usb_serial_port *port) | |||
285 | return 0; | 285 | return 0; |
286 | 286 | ||
287 | data = port->write_urb->transfer_buffer; | 287 | data = port->write_urb->transfer_buffer; |
288 | count = kfifo_out_locked(port->write_fifo, data, port->bulk_out_size, &port->lock); | 288 | count = kfifo_out_locked(&port->write_fifo, data, port->bulk_out_size, &port->lock); |
289 | usb_serial_debug_data(debug, &port->dev, __func__, count, data); | 289 | usb_serial_debug_data(debug, &port->dev, __func__, count, data); |
290 | 290 | ||
291 | /* set up our urb */ | 291 | /* set up our urb */ |
@@ -345,7 +345,7 @@ int usb_serial_generic_write(struct tty_struct *tty, | |||
345 | return usb_serial_multi_urb_write(tty, port, | 345 | return usb_serial_multi_urb_write(tty, port, |
346 | buf, count); | 346 | buf, count); |
347 | 347 | ||
348 | count = kfifo_in_locked(port->write_fifo, buf, count, &port->lock); | 348 | count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock); |
349 | result = usb_serial_generic_write_start(port); | 349 | result = usb_serial_generic_write_start(port); |
350 | 350 | ||
351 | if (result >= 0) | 351 | if (result >= 0) |
@@ -370,7 +370,7 @@ int usb_serial_generic_write_room(struct tty_struct *tty) | |||
370 | (serial->type->max_in_flight_urbs - | 370 | (serial->type->max_in_flight_urbs - |
371 | port->urbs_in_flight); | 371 | port->urbs_in_flight); |
372 | } else if (serial->num_bulk_out) | 372 | } else if (serial->num_bulk_out) |
373 | room = port->write_fifo->size - kfifo_len(port->write_fifo); | 373 | room = kfifo_avail(&port->write_fifo); |
374 | spin_unlock_irqrestore(&port->lock, flags); | 374 | spin_unlock_irqrestore(&port->lock, flags); |
375 | 375 | ||
376 | dbg("%s - returns %d", __func__, room); | 376 | dbg("%s - returns %d", __func__, room); |
@@ -391,7 +391,7 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty) | |||
391 | chars = port->tx_bytes_flight; | 391 | chars = port->tx_bytes_flight; |
392 | spin_unlock_irqrestore(&port->lock, flags); | 392 | spin_unlock_irqrestore(&port->lock, flags); |
393 | } else if (serial->num_bulk_out) | 393 | } else if (serial->num_bulk_out) |
394 | chars = kfifo_len(port->write_fifo); | 394 | chars = kfifo_len(&port->write_fifo); |
395 | 395 | ||
396 | dbg("%s - returns %d", __func__, chars); | 396 | dbg("%s - returns %d", __func__, chars); |
397 | return chars; | 397 | return chars; |
@@ -507,7 +507,7 @@ void usb_serial_generic_write_bulk_callback(struct urb *urb) | |||
507 | if (status) { | 507 | if (status) { |
508 | dbg("%s - nonzero multi-urb write bulk status " | 508 | dbg("%s - nonzero multi-urb write bulk status " |
509 | "received: %d", __func__, status); | 509 | "received: %d", __func__, status); |
510 | kfifo_reset(port->write_fifo); | 510 | kfifo_reset_out(&port->write_fifo); |
511 | } else | 511 | } else |
512 | usb_serial_generic_write_start(port); | 512 | usb_serial_generic_write_start(port); |
513 | } | 513 | } |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 636a4f23445e..33c85f7084f8 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -595,8 +595,7 @@ static void port_release(struct device *dev) | |||
595 | usb_free_urb(port->write_urb); | 595 | usb_free_urb(port->write_urb); |
596 | usb_free_urb(port->interrupt_in_urb); | 596 | usb_free_urb(port->interrupt_in_urb); |
597 | usb_free_urb(port->interrupt_out_urb); | 597 | usb_free_urb(port->interrupt_out_urb); |
598 | if (!IS_ERR(port->write_fifo) && port->write_fifo) | 598 | kfifo_free(&port->write_fifo); |
599 | kfifo_free(port->write_fifo); | ||
600 | kfree(port->bulk_in_buffer); | 599 | kfree(port->bulk_in_buffer); |
601 | kfree(port->bulk_out_buffer); | 600 | kfree(port->bulk_out_buffer); |
602 | kfree(port->interrupt_in_buffer); | 601 | kfree(port->interrupt_in_buffer); |
@@ -939,7 +938,7 @@ int usb_serial_probe(struct usb_interface *interface, | |||
939 | dev_err(&interface->dev, "No free urbs available\n"); | 938 | dev_err(&interface->dev, "No free urbs available\n"); |
940 | goto probe_error; | 939 | goto probe_error; |
941 | } | 940 | } |
942 | if (kfifo_alloc(port->write_fifo, PAGE_SIZE, GFP_KERNEL)) | 941 | if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL)) |
943 | goto probe_error; | 942 | goto probe_error; |
944 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); | 943 | buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); |
945 | port->bulk_out_size = buffer_size; | 944 | port->bulk_out_size = buffer_size; |
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index acf6e457c04b..1819396ed501 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/kref.h> | 16 | #include <linux/kref.h> |
17 | #include <linux/mutex.h> | 17 | #include <linux/mutex.h> |
18 | #include <linux/sysrq.h> | 18 | #include <linux/sysrq.h> |
19 | #include <linux/kfifo.h> | ||
19 | 20 | ||
20 | #define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ | 21 | #define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ |
21 | #define SERIAL_TTY_MINORS 254 /* loads of devices :) */ | 22 | #define SERIAL_TTY_MINORS 254 /* loads of devices :) */ |
@@ -94,7 +95,7 @@ struct usb_serial_port { | |||
94 | unsigned char *bulk_out_buffer; | 95 | unsigned char *bulk_out_buffer; |
95 | int bulk_out_size; | 96 | int bulk_out_size; |
96 | struct urb *write_urb; | 97 | struct urb *write_urb; |
97 | struct kfifo *write_fifo; | 98 | struct kfifo write_fifo; |
98 | int write_urb_busy; | 99 | int write_urb_busy; |
99 | __u8 bulk_out_endpointAddress; | 100 | __u8 bulk_out_endpointAddress; |
100 | 101 | ||