Merge remote-tracking branch 'y2038/y2038'
authorStephen Rothwell <sfr@canb.auug.org.au>
Thu, 5 Nov 2015 04:25:04 +0000 (15:25 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 5 Nov 2015 04:25:04 +0000 (15:25 +1100)
drivers/staging/gdm72xx/gdm_sdio.c
drivers/staging/gdm72xx/gdm_sdio.h
drivers/staging/media/lirc/lirc_parallel.c
drivers/staging/media/lirc/lirc_sasem.c
drivers/staging/media/lirc/lirc_serial.c
fs/coredump.c
kernel/cpuset.c

index b0521da..1f5a087 100644 (file)
@@ -36,7 +36,7 @@
 #define RX_BUF_SIZE    (25*1024)
 
 #define TX_HZ          2000
-#define TX_INTERVAL    (1000000/TX_HZ)
+#define TX_INTERVAL    (NSEC_PER_SEC/TX_HZ)
 
 static struct sdio_tx *alloc_tx_struct(struct tx_cxt *tx)
 {
@@ -303,7 +303,7 @@ static void send_sdu(struct sdio_func *func, struct tx_cxt *tx)
                put_tx_struct(t->tx_cxt, t);
        }
 
-       do_gettimeofday(&tx->sdu_stamp);
+       tx->sdu_stamp = ktime_get();
        spin_unlock_irqrestore(&tx->lock, flags);
 }
 
@@ -330,7 +330,7 @@ static void do_tx(struct work_struct *work)
        struct sdio_func *func = sdev->func;
        struct tx_cxt *tx = &sdev->tx;
        struct sdio_tx *t = NULL;
-       struct timeval now, *before;
+       ktime_t now, before;
        int is_sdu = 0;
        long diff;
        unsigned long flags;
@@ -346,11 +346,10 @@ static void do_tx(struct work_struct *work)
                list_del(&t->list);
                is_sdu = 0;
        } else if (!tx->stop_sdu_tx && !list_empty(&tx->sdu_list)) {
-               do_gettimeofday(&now);
-               before = &tx->sdu_stamp;
+               now = ktime_get();
+               before = tx->sdu_stamp;
 
-               diff = (now.tv_sec - before->tv_sec) * 1000000 +
-                       (now.tv_usec - before->tv_usec);
+               diff = ktime_to_ns(ktime_sub(now, before));
                if (diff >= 0 && diff < TX_INTERVAL) {
                        schedule_work(&sdev->ws);
                        spin_unlock_irqrestore(&tx->lock, flags);
index 77ad9d6..aa7dad2 100644 (file)
@@ -15,7 +15,7 @@
 #define __GDM72XX_GDM_SDIO_H__
 
 #include <linux/types.h>
-#include <linux/time.h>
+#include <linux/ktime.h>
 
 #define MAX_NR_SDU_BUF  64
 
@@ -32,7 +32,7 @@ struct tx_cxt {
        struct list_head        free_list;
        struct list_head        sdu_list;
        struct list_head        hci_list;
-       struct timeval          sdu_stamp;
+       ktime_t                 sdu_stamp;
        u8                      *sdu_buf;
        spinlock_t              lock;
        int                     can_send;
index c140834..c7987c0 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/fs.h>
 #include <linux/kernel.h>
 #include <linux/ioport.h>
-#include <linux/time.h>
+#include <linux/ktime.h>
 #include <linux/mm.h>
 #include <linux/delay.h>
 
@@ -144,25 +144,22 @@ static void lirc_off(void)
 
 static unsigned int init_lirc_timer(void)
 {
-       struct timeval tv, now;
+       ktime_t kt, now, timeout;
        unsigned int level, newlevel, timeelapsed, newtimer;
        int count = 0;
 
-       do_gettimeofday(&tv);
-       tv.tv_sec++;                     /* wait max. 1 sec. */
+       kt = ktime_get();
+       /* wait max. 1 sec. */
+       timeout = ktime_add_ns(kt, NSEC_PER_SEC);
        level = lirc_get_timer();
        do {
                newlevel = lirc_get_timer();
                if (level == 0 && newlevel != 0)
                        count++;
                level = newlevel;
-               do_gettimeofday(&now);
-       } while (count < 1000 && (now.tv_sec < tv.tv_sec
-                            || (now.tv_sec == tv.tv_sec
-                                && now.tv_usec < tv.tv_usec)));
-
-       timeelapsed = (now.tv_sec + 1 - tv.tv_sec)*1000000
-                    + (now.tv_usec - tv.tv_usec);
+               now = ktime_get();
+       } while (count < 1000 && (ktime_before(now, timeout)));
+       timeelapsed = ktime_us_delta(now, kt);
        if (count >= 1000 && timeelapsed > 0) {
                if (default_timer == 0) {
                        /* autodetect timer */
@@ -220,8 +217,8 @@ static void rbuf_write(int signal)
 
 static void lirc_lirc_irq_handler(void *blah)
 {
-       struct timeval tv;
-       static struct timeval lasttv;
+       ktime_t kt, delkt;
+       static ktime_t lastkt;
        static int init;
        long signal;
        int data;
@@ -244,16 +241,14 @@ static void lirc_lirc_irq_handler(void *blah)
 
 #ifdef LIRC_TIMER
        if (init) {
-               do_gettimeofday(&tv);
+               kt = ktime_get();
 
-               signal = tv.tv_sec - lasttv.tv_sec;
-               if (signal > 15)
+               delkt = ktime_sub(kt, lastkt);
+               if (ktime_compare(delkt, ktime_set(15, 0)) > 0)
                        /* really long time */
                        data = PULSE_MASK;
                else
-                       data = (int) (signal*1000000 +
-                                        tv.tv_usec - lasttv.tv_usec +
-                                        LIRC_SFH506_DELAY);
+                       data = (int) (ktime_to_us(delkt) + LIRC_SFH506_DELAY);
 
                rbuf_write(data); /* space */
        } else {
@@ -301,7 +296,7 @@ static void lirc_lirc_irq_handler(void *blah)
                        data = 1;
                rbuf_write(PULSE_BIT|data); /* pulse */
        }
-       do_gettimeofday(&lasttv);
+       lastkt = ktime_get();
 #else
        /* add your code here */
 #endif
index f2dca69..2218d00 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 #include <linux/usb.h>
+#include <linux/ktime.h>
 
 #include <media/lirc.h>
 #include <media/lirc_dev.h>
@@ -111,7 +112,7 @@ struct sasem_context {
        } tx;
 
        /* for dealing with repeat codes (wish there was a toggle bit!) */
-       struct timeval presstime;
+       ktime_t presstime;
        char lastcode[8];
        int codesaved;
 };
@@ -566,8 +567,8 @@ static void incoming_packet(struct sasem_context *context,
 {
        int len = urb->actual_length;
        unsigned char *buf = urb->transfer_buffer;
-       long ms;
-       struct timeval tv;
+       u64 ns;
+       ktime_t kt;
 
        if (len != 8) {
                dev_warn(&context->dev->dev,
@@ -584,9 +585,8 @@ static void incoming_packet(struct sasem_context *context,
         */
 
        /* get the time since the last button press */
-       do_gettimeofday(&tv);
-       ms = (tv.tv_sec - context->presstime.tv_sec) * 1000 +
-            (tv.tv_usec - context->presstime.tv_usec) / 1000;
+       kt = ktime_get();
+       ns = ktime_to_ns(ktime_sub(kt, context->presstime));
 
        if (memcmp(buf, "\x08\0\0\0\0\0\0\0", 8) == 0) {
                /*
@@ -600,10 +600,9 @@ static void incoming_packet(struct sasem_context *context,
                 *   in that time and then get a false repeat of the previous
                 *   press but it is long enough for a genuine repeat
                 */
-               if ((ms < 250) && (context->codesaved != 0)) {
+               if ((ns < 250 * NSEC_PER_MSEC) && (context->codesaved != 0)) {
                        memcpy(buf, &context->lastcode, 8);
-                       context->presstime.tv_sec = tv.tv_sec;
-                       context->presstime.tv_usec = tv.tv_usec;
+                       context->presstime = kt;
                }
        } else {
                /* save the current valid code for repeats */
@@ -613,8 +612,7 @@ static void incoming_packet(struct sasem_context *context,
                 * just for safety reasons
                 */
                context->codesaved = 1;
-               context->presstime.tv_sec = tv.tv_sec;
-               context->presstime.tv_usec = tv.tv_usec;
+               context->presstime = kt;
        }
 
        lirc_buffer_write(context->driver->rbuf, buf);
index 64a7b2f..b798b31 100644 (file)
@@ -59,7 +59,7 @@
 #include <linux/ioport.h>
 #include <linux/kernel.h>
 #include <linux/serial_reg.h>
-#include <linux/time.h>
+#include <linux/ktime.h>
 #include <linux/string.h>
 #include <linux/types.h>
 #include <linux/wait.h>
@@ -204,7 +204,7 @@ static struct lirc_serial hardware[] = {
 
 #define RBUF_LEN 256
 
-static struct timeval lasttv = {0, 0};
+static ktime_t lastkt;
 
 static struct lirc_buffer rbuf;
 
@@ -542,10 +542,10 @@ static void frbwrite(int l)
 
 static irqreturn_t lirc_irq_handler(int i, void *blah)
 {
-       struct timeval tv;
+       ktime_t kt;
        int counter, dcd;
        u8 status;
-       long deltv;
+       ktime_t delkt;
        int data;
        static int last_dcd = -1;
 
@@ -565,7 +565,7 @@ static irqreturn_t lirc_irq_handler(int i, void *blah)
                if ((status & hardware[type].signal_pin_change)
                    && sense != -1) {
                        /* get current time */
-                       do_gettimeofday(&tv);
+                       kt = ktime_get();
 
                        /* New mode, written by Trent Piepho
                           <xyzzy@u.washington.edu>. */
@@ -594,34 +594,20 @@ static irqreturn_t lirc_irq_handler(int i, void *blah)
                        dcd = (status & hardware[type].signal_pin) ? 1 : 0;
 
                        if (dcd == last_dcd) {
-                               pr_warn("ignoring spike: %d %d %lx %lx %lx %lx\n",
-                                       dcd, sense,
-                                       tv.tv_sec, lasttv.tv_sec,
-                                       (unsigned long)tv.tv_usec,
-                                       (unsigned long)lasttv.tv_usec);
+                               pr_warn("ignoring spike: %d %d %llx %llx\n",
+                                       dcd, sense, ktime_to_us(kt),
+                                       ktime_to_us(lastkt));
                                continue;
                        }
 
-                       deltv = tv.tv_sec-lasttv.tv_sec;
-                       if (tv.tv_sec < lasttv.tv_sec ||
-                           (tv.tv_sec == lasttv.tv_sec &&
-                            tv.tv_usec < lasttv.tv_usec)) {
-                               pr_warn("AIEEEE: your clock just jumped backwards\n");
-                               pr_warn("%d %d %lx %lx %lx %lx\n",
-                                       dcd, sense,
-                                       tv.tv_sec, lasttv.tv_sec,
-                                       (unsigned long)tv.tv_usec,
-                                       (unsigned long)lasttv.tv_usec);
-                               data = PULSE_MASK;
-                       } else if (deltv > 15) {
+                       delkt = ktime_sub(kt, lastkt);
+                       if (ktime_compare(delkt, ktime_set(15, 0)) > 0) {
                                data = PULSE_MASK; /* really long time */
                                if (!(dcd^sense)) {
                                        /* sanity check */
-                                       pr_warn("AIEEEE: %d %d %lx %lx %lx %lx\n",
-                                               dcd, sense,
-                                               tv.tv_sec, lasttv.tv_sec,
-                                               (unsigned long)tv.tv_usec,
-                                               (unsigned long)lasttv.tv_usec);
+                                       pr_warn("AIEEEE: %d %d %llx %llx\n",
+                                               dcd, sense, ktime_to_us(kt),
+                                               ktime_to_us(lastkt));
                                        /*
                                         * detecting pulse while this
                                         * MUST be a space!
@@ -629,11 +615,9 @@ static irqreturn_t lirc_irq_handler(int i, void *blah)
                                        sense = sense ? 0 : 1;
                                }
                        } else
-                               data = (int) (deltv*1000000 +
-                                              tv.tv_usec -
-                                              lasttv.tv_usec);
+                               data = (int) ktime_to_us(delkt);
                        frbwrite(dcd^sense ? data : (data|PULSE_BIT));
-                       lasttv = tv;
+                       lastkt = kt;
                        last_dcd = dcd;
                        wake_up_interruptible(&rbuf.wait_poll);
                }
@@ -790,7 +774,7 @@ static int set_use_inc(void *data)
        unsigned long flags;
 
        /* initialize timestamp */
-       do_gettimeofday(&lasttv);
+       lastkt = ktime_get();
 
        spin_lock_irqsave(&hardware[type].lock, flags);
 
@@ -979,7 +963,7 @@ static int lirc_serial_resume(struct platform_device *dev)
 
        spin_lock_irqsave(&hardware[type].lock, flags);
        /* Enable Interrupt */
-       do_gettimeofday(&lasttv);
+       lastkt = ktime_get();
        soutp(UART_IER, sinp(UART_IER)|UART_IER_MSI);
        off();
 
index a8f7564..53d7d46 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/pipe_fs_i.h>
 #include <linux/oom.h>
 #include <linux/compat.h>
+#include <linux/timekeeping.h>
 
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
@@ -232,9 +233,10 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
                                break;
                        /* UNIX time of coredump */
                        case 't': {
-                               struct timeval tv;
-                               do_gettimeofday(&tv);
-                               err = cn_printf(cn, "%lu", tv.tv_sec);
+                               time64_t time;
+
+                               time = ktime_get_real_seconds();
+                               err = cn_printf(cn, "%lld", time);
                                break;
                        }
                        /* hostname */
index d7ccb87..c02d677 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/time.h>
+#include <linux/time64.h>
 #include <linux/backing-dev.h>
 #include <linux/sort.h>
 
@@ -68,7 +69,7 @@ struct static_key cpusets_enabled_key __read_mostly = STATIC_KEY_INIT_FALSE;
 struct fmeter {
        int cnt;                /* unprocessed events count */
        int val;                /* most recent output value */
-       time_t time;            /* clock (secs) when val computed */
+       time64_t time;          /* clock (secs) when val computed */
        spinlock_t lock;        /* guards read or write of above */
 };
 
@@ -1374,7 +1375,7 @@ out:
  */
 
 #define FM_COEF 933            /* coefficient for half-life of 10 secs */
-#define FM_MAXTICKS ((time_t)99) /* useless computing more ticks than this */
+#define FM_MAXTICKS ((u32)99)   /* useless computing more ticks than this */
 #define FM_MAXCNT 1000000      /* limit cnt to avoid overflow */
 #define FM_SCALE 1000          /* faux fixed point scale */
 
@@ -1390,8 +1391,11 @@ static void fmeter_init(struct fmeter *fmp)
 /* Internal meter update - process cnt events and update value */
 static void fmeter_update(struct fmeter *fmp)
 {
-       time_t now = get_seconds();
-       time_t ticks = now - fmp->time;
+       time64_t now;
+       u32 ticks;
+
+       now = ktime_get_seconds();
+       ticks = now - fmp->time;
 
        if (ticks == 0)
                return;