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@xxxxxxxxxx> Hi, here's one for the next merge window. It seems that people are actually using nonblocking IO and suffer if it doesn't work. The read path needs major changes and since this has to be perfect I am keeping chunks as small as possible to be easily reviewed. Regards Oliver -- commit 67ed4b935315662293d2a7d0415dc016d501b1bd Author: Oliver Neukum <oliver@xxxxxxxxxx> Date: Wed Sep 9 09:49:14 2009 +0200 usb:usb-skeleton: honor O_NONBLOCK in write path nonblocking writes are allowed by using down_trylock if necessary to reserve an URB diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 60ba631..7888c7e 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -248,9 +248,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); -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html