Merge 5.4-rc5 into usb-next
We want the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
@@ -380,10 +380,7 @@ static int ld_usb_release(struct inode *inode, struct file *file)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (mutex_lock_interruptible(&dev->mutex)) {
|
||||
retval = -ERESTARTSYS;
|
||||
goto exit;
|
||||
}
|
||||
mutex_lock(&dev->mutex);
|
||||
|
||||
if (dev->open_count != 1) {
|
||||
retval = -ENODEV;
|
||||
@@ -467,7 +464,7 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
|
||||
|
||||
/* wait for data */
|
||||
spin_lock_irq(&dev->rbsl);
|
||||
if (dev->ring_head == dev->ring_tail) {
|
||||
while (dev->ring_head == dev->ring_tail) {
|
||||
dev->interrupt_in_done = 0;
|
||||
spin_unlock_irq(&dev->rbsl);
|
||||
if (file->f_flags & O_NONBLOCK) {
|
||||
@@ -477,12 +474,17 @@ static ssize_t ld_usb_read(struct file *file, char __user *buffer, size_t count,
|
||||
retval = wait_event_interruptible(dev->read_wait, dev->interrupt_in_done);
|
||||
if (retval < 0)
|
||||
goto unlock_exit;
|
||||
} else {
|
||||
spin_unlock_irq(&dev->rbsl);
|
||||
|
||||
spin_lock_irq(&dev->rbsl);
|
||||
}
|
||||
spin_unlock_irq(&dev->rbsl);
|
||||
|
||||
/* actual_buffer contains actual_length + interrupt_in_buffer */
|
||||
actual_buffer = (size_t *)(dev->ring_buffer + dev->ring_tail * (sizeof(size_t)+dev->interrupt_in_endpoint_size));
|
||||
if (*actual_buffer > dev->interrupt_in_endpoint_size) {
|
||||
retval = -EIO;
|
||||
goto unlock_exit;
|
||||
}
|
||||
bytes_to_read = min(count, *actual_buffer);
|
||||
if (bytes_to_read < *actual_buffer)
|
||||
dev_warn(&dev->intf->dev, "Read buffer overflow, %zd bytes dropped\n",
|
||||
@@ -693,10 +695,9 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
|
||||
dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n");
|
||||
|
||||
dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint);
|
||||
dev->ring_buffer =
|
||||
kmalloc_array(ring_buffer_size,
|
||||
sizeof(size_t) + dev->interrupt_in_endpoint_size,
|
||||
GFP_KERNEL);
|
||||
dev->ring_buffer = kcalloc(ring_buffer_size,
|
||||
sizeof(size_t) + dev->interrupt_in_endpoint_size,
|
||||
GFP_KERNEL);
|
||||
if (!dev->ring_buffer)
|
||||
goto error;
|
||||
dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);
|
||||
|
@@ -419,10 +419,7 @@ static int tower_release (struct inode *inode, struct file *file)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (mutex_lock_interruptible(&dev->lock)) {
|
||||
retval = -ERESTARTSYS;
|
||||
goto exit;
|
||||
}
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
if (dev->open_count != 1) {
|
||||
dev_dbg(&dev->udev->dev, "%s: device not opened exactly once\n",
|
||||
@@ -881,7 +878,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
|
||||
get_version_reply,
|
||||
sizeof(*get_version_reply),
|
||||
1000);
|
||||
if (result < sizeof(*get_version_reply)) {
|
||||
if (result != sizeof(*get_version_reply)) {
|
||||
if (result >= 0)
|
||||
result = -EIO;
|
||||
dev_err(idev, "get version request failed: %d\n", result);
|
||||
|
Reference in New Issue
Block a user