O_NONBLOCK in read path of skeleton

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

--

commit 5dab1a11bc706d1bd087b63d705db98e8c1913d2
Author: Oliver Neukum <oliver@xxxxxxxxxx>
Date:   Wed Sep 9 14:23:52 2009 +0200

    usb:usb-skeleton: nonblocking IO in the read path

diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 7441df2..ef8c877 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -268,6 +268,11 @@ retry:
 	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
@@ -351,8 +356,9 @@ retry:
 		rv = skel_do_read_io(dev, count);
 		if (rv < 0)
 			goto exit;
-		else
-			goto retry;	
+		else if (!file->f_flags & O_NONBLOCK)
+			goto retry;
+		rv = -EAGAIN;
 	}
 exit:
 	mutex_unlock(&dev->io_mutex);


--
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

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux