diff options
author | Oliver Neukum <oliver@neukum.org> | 2009-09-09 10:23:35 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-23 15:46:40 +0200 |
commit | 798199867385417ba6494472e39c016e3340758c (patch) | |
tree | 0be421533a966075130254d41ba0ae7ea0a25e71 /drivers/usb | |
parent | USB: skel_read really sucks royally (diff) | |
download | linux-798199867385417ba6494472e39c016e3340758c.tar.xz linux-798199867385417ba6494472e39c016e3340758c.zip |
USB: make usb-skeleton honor O_NONBLOCK in write path
usb:usb-skeleton: honor O_NONBLOCK in write path
nonblocking writes are allowed by using down_trylock if necessary
to reserve an URB
Signed-off-by: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/usb-skeleton.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 5ffa3e246856..768fda9064e9 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -399,9 +399,16 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou goto exit; /* limit the number of URBs in flight to stop a user from using up all RAM */ - if (down_interruptible(&dev->limit_sem)) { - retval = -ERESTARTSYS; - goto exit; + if (!file->f_flags & O_NONBLOCK) { + if (down_interruptible(&dev->limit_sem)) { + retval = -ERESTARTSYS; + goto exit; + } + } else { + if (down_trylock(&dev->limit_sem)) { + retval = -EAGAIN; + goto exit; + } } spin_lock_irq(&dev->err_lock); |