Skip to content

Commit

Permalink
USB: O_NONBLOCK in read path of skeleton
Browse files Browse the repository at this point in the history
Non blocking IO is supported in the read path of usb-skeleton.
This is done by just not blocking. As support for handling signals
without stopping IO is already there, it can be used for O_NONBLOCK, too.

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Oliver Neukum authored and Greg Kroah-Hartman committed Sep 23, 2009
1 parent 7981998 commit 8cd0166
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/usb/usb-skeleton.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count, loff_t *
spin_unlock_irq(&dev->err_lock);

if (ongoing_io) {
/* nonblocking IO shall not wait */
if (file->f_flags & O_NONBLOCK) {
rv = -EAGAIN;
goto exit;
}
/*
* IO may take forever
* hence wait in an interruptible state
Expand Down Expand Up @@ -351,8 +356,9 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count, loff_t *
rv = skel_do_read_io(dev, count);
if (rv < 0)
goto exit;
else
else if (!file->f_flags & O_NONBLOCK)
goto retry;
rv = -EAGAIN;
}
exit:
mutex_unlock(&dev->io_mutex);
Expand Down

0 comments on commit 8cd0166

Please sign in to comment.