Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Stefani Seibold and committed by
Linus Torvalds
119eecc8 c9f937e4

+10 -10
+6 -6
drivers/usb/serial/generic.c
··· 276 276 if (port->write_urb_busy) 277 277 start_io = false; 278 278 else { 279 - start_io = (kfifo_len(port->write_fifo) != 0); 279 + start_io = (kfifo_len(&port->write_fifo) != 0); 280 280 port->write_urb_busy = start_io; 281 281 } 282 282 spin_unlock_irqrestore(&port->lock, flags); ··· 285 285 return 0; 286 286 287 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 289 usb_serial_debug_data(debug, &port->dev, __func__, count, data); 290 290 291 291 /* set up our urb */ ··· 345 345 return usb_serial_multi_urb_write(tty, port, 346 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 349 result = usb_serial_generic_write_start(port); 350 350 351 351 if (result >= 0) ··· 370 370 (serial->type->max_in_flight_urbs - 371 371 port->urbs_in_flight); 372 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 374 spin_unlock_irqrestore(&port->lock, flags); 375 375 376 376 dbg("%s - returns %d", __func__, room); ··· 391 391 chars = port->tx_bytes_flight; 392 392 spin_unlock_irqrestore(&port->lock, flags); 393 393 } else if (serial->num_bulk_out) 394 - chars = kfifo_len(port->write_fifo); 394 + chars = kfifo_len(&port->write_fifo); 395 395 396 396 dbg("%s - returns %d", __func__, chars); 397 397 return chars; ··· 507 507 if (status) { 508 508 dbg("%s - nonzero multi-urb write bulk status " 509 509 "received: %d", __func__, status); 510 - kfifo_reset(port->write_fifo); 510 + kfifo_reset_out(&port->write_fifo); 511 511 } else 512 512 usb_serial_generic_write_start(port); 513 513 }
+2 -3
drivers/usb/serial/usb-serial.c
··· 595 595 usb_free_urb(port->write_urb); 596 596 usb_free_urb(port->interrupt_in_urb); 597 597 usb_free_urb(port->interrupt_out_urb); 598 - if (!IS_ERR(port->write_fifo) && port->write_fifo) 599 - kfifo_free(port->write_fifo); 598 + kfifo_free(&port->write_fifo); 600 599 kfree(port->bulk_in_buffer); 601 600 kfree(port->bulk_out_buffer); 602 601 kfree(port->interrupt_in_buffer); ··· 938 939 dev_err(&interface->dev, "No free urbs available\n"); 939 940 goto probe_error; 940 941 } 941 - if (kfifo_alloc(port->write_fifo, PAGE_SIZE, GFP_KERNEL)) 942 + if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL)) 942 943 goto probe_error; 943 944 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 944 945 port->bulk_out_size = buffer_size;
+2 -1
include/linux/usb/serial.h
··· 16 16 #include <linux/kref.h> 17 17 #include <linux/mutex.h> 18 18 #include <linux/sysrq.h> 19 + #include <linux/kfifo.h> 19 20 20 21 #define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ 21 22 #define SERIAL_TTY_MINORS 254 /* loads of devices :) */ ··· 95 94 unsigned char *bulk_out_buffer; 96 95 int bulk_out_size; 97 96 struct urb *write_urb; 98 - struct kfifo *write_fifo; 97 + struct kfifo write_fifo; 99 98 int write_urb_busy; 100 99 __u8 bulk_out_endpointAddress; 101 100