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

USB: O_NONBLOCK in read path of skeleton

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>

authored by

Oliver Neukum and committed by
Greg Kroah-Hartman
8cd01664 79819986

+7 -1
+7 -1
drivers/usb/usb-skeleton.c
··· 268 268 spin_unlock_irq(&dev->err_lock); 269 269 270 270 if (ongoing_io) { 271 + /* nonblocking IO shall not wait */ 272 + if (file->f_flags & O_NONBLOCK) { 273 + rv = -EAGAIN; 274 + goto exit; 275 + } 271 276 /* 272 277 * IO may take forever 273 278 * hence wait in an interruptible state ··· 356 351 rv = skel_do_read_io(dev, count); 357 352 if (rv < 0) 358 353 goto exit; 359 - else 354 + else if (!file->f_flags & O_NONBLOCK) 360 355 goto retry; 356 + rv = -EAGAIN; 361 357 } 362 358 exit: 363 359 mutex_unlock(&dev->io_mutex);