]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/pps/pps.c
Merge branch 'akpm-current/current'
[karo-tx-linux.git] / drivers / pps / pps.c
index 2f07cd615665248b55164525b0c24087ce7411c9..983f50c4b7b462be3a3567a2068b272488179f4a 100644 (file)
@@ -152,35 +152,38 @@ static long pps_cdev_ioctl(struct file *file,
                if (err)
                        return -EFAULT;
 
-               ev = pps->last_ev;
-
-               /* Manage the timeout */
-               if (fdata.timeout.flags & PPS_TIME_INVALID)
-                       err = wait_event_interruptible(pps->queue,
-                                       ev != pps->last_ev);
-               else {
-                       unsigned long ticks;
-
-                       dev_dbg(pps->dev, "timeout %lld.%09d\n",
-                                       (long long) fdata.timeout.sec,
-                                       fdata.timeout.nsec);
-                       ticks = fdata.timeout.sec * HZ;
-                       ticks += fdata.timeout.nsec / (NSEC_PER_SEC / HZ);
-
-                       if (ticks != 0) {
-                               err = wait_event_interruptible_timeout(
-                                               pps->queue,
-                                               ev != pps->last_ev,
-                                               ticks);
-                               if (err == 0)
-                                       return -ETIMEDOUT;
+               if (!(file->f_flags & O_NONBLOCK)) {
+                       ev = pps->last_ev;
+
+                       /* Manage the timeout */
+                       if (fdata.timeout.flags & PPS_TIME_INVALID)
+                               err = wait_event_interruptible(pps->queue,
+                                               ev != pps->last_ev);
+                       else {
+                               unsigned long ticks;
+
+                               dev_dbg(pps->dev, "timeout %lld.%09d\n",
+                                               (long long) fdata.timeout.sec,
+                                               fdata.timeout.nsec);
+                               ticks = fdata.timeout.sec * HZ;
+                               ticks += fdata.timeout.nsec /
+                                       (NSEC_PER_SEC / HZ);
+
+                               if (ticks != 0) {
+                                       err = wait_event_interruptible_timeout(
+                                                       pps->queue,
+                                                       ev != pps->last_ev,
+                                                       ticks);
+                                       if (err == 0)
+                                               return -ETIMEDOUT;
+                               }
                        }
-               }
 
-               /* Check for pending signals */
-               if (err == -ERESTARTSYS) {
-                       dev_dbg(pps->dev, "pending signal caught\n");
-                       return -EINTR;
+                       /* Check for pending signals */
+                       if (err == -ERESTARTSYS) {
+                               dev_dbg(pps->dev, "pending signal caught\n");
+                               return -EINTR;
+                       }
                }
 
                /* Return the fetched timestamp */