These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / comedi / drivers / serial2002.c
index 304ebff..7a1defc 100644 (file)
@@ -1,30 +1,29 @@
 /*
   comedi/drivers/serial2002.c
-    Skeleton code for a Comedi driver
-
   COMEDI - Linux Control and Measurement Device Interface
   Copyright (C) 2002 Anders Blomdell <anders.blomdell@control.lth.se>
-
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
-
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
-*/
serial2002.c
+ * Comedi driver for serial connected hardware
+ *
* COMEDI - Linux Control and Measurement Device Interface
* Copyright (C) 2002 Anders Blomdell <anders.blomdell@control.lth.se>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
+ */
 
 /*
-Driver: serial2002
-Description: Driver for serial connected hardware
-Devices:
-Author: Anders Blomdell
-Updated: Fri,  7 Jun 2002 12:56:45 -0700
-Status: in development
-
-*/
+ * Driver: serial2002
+ * Description: Driver for serial connected hardware
+ * Devices:
+ * Author: Anders Blomdell
+ * Updated: Fri,  7 Jun 2002 12:56:45 -0700
+ * Status: in development
+ */
 
 #include <linux/module.h>
 #include "../comedidev.h"
@@ -32,6 +31,7 @@ Status: in development
 #include <linux/delay.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/ktime.h>
 
 #include <linux/termios.h>
 #include <asm/ioctls.h>
@@ -101,7 +101,7 @@ static long serial2002_tty_ioctl(struct file *f, unsigned op,
        if (f->f_op->unlocked_ioctl)
                return f->f_op->unlocked_ioctl(f, op, param);
 
-       return -ENOSYS;
+       return -ENOTTY;
 }
 
 static int serial2002_tty_write(struct file *f, unsigned char *buf, int count)
@@ -121,9 +121,9 @@ static int serial2002_tty_write(struct file *f, unsigned char *buf, int count)
 static void serial2002_tty_read_poll_wait(struct file *f, int timeout)
 {
        struct poll_wqueues table;
-       struct timeval start, now;
+       ktime_t start, now;
 
-       do_gettimeofday(&start);
+       start = ktime_get();
        poll_initwait(&table);
        while (1) {
                long elapsed;
@@ -134,9 +134,8 @@ static void serial2002_tty_read_poll_wait(struct file *f, int timeout)
                            POLLHUP | POLLERR)) {
                        break;
                }
-               do_gettimeofday(&now);
-               elapsed = 1000000 * (now.tv_sec - start.tv_sec) +
-                         now.tv_usec - start.tv_usec;
+               now = ktime_get();
+               elapsed = ktime_us_delta(now, start);
                if (elapsed > timeout)
                        break;
                set_current_state(TASK_INTERRUPTIBLE);
@@ -176,7 +175,7 @@ static int serial2002_tty_read(struct file *f, int timeout)
                                        result = ch;
                                        break;
                                }
-                               udelay(100);
+                               usleep_range(100, 1000);
                        }
                }
                set_fs(oldfs);
@@ -373,7 +372,7 @@ static int serial2002_setup_subdevice(struct comedi_subdevice *s,
                if (cfg[j].kind == kind) {
                        if (mapping)
                                mapping[chan] = j;
-                       if (range) {
+                       if (range && range_table_list) {
                                range[j].length = 1;
                                range[j].range.min = cfg[j].min;
                                range[j].range.max = cfg[j].max;