ath10k: fix checkpatch warnings about parenthesis alignment
[cascardo/linux.git] / fs / timerfd.c
index 77183f0..80c3502 100644 (file)
@@ -93,7 +93,7 @@ static enum alarmtimer_restart timerfd_alarmproc(struct alarm *alarm,
  */
 void timerfd_clock_was_set(void)
 {
-       ktime_t moffs = ktime_get_monotonic_offset();
+       ktime_t moffs = ktime_mono_to_real((ktime_t){ .tv64 = 0 });
        struct timerfd_ctx *ctx;
        unsigned long flags;
 
@@ -126,7 +126,7 @@ static bool timerfd_canceled(struct timerfd_ctx *ctx)
 {
        if (!ctx->might_cancel || ctx->moffs.tv64 != KTIME_MAX)
                return false;
-       ctx->moffs = ktime_get_monotonic_offset();
+       ctx->moffs = ktime_mono_to_real((ktime_t){ .tv64 = 0 });
        return true;
 }
 
@@ -315,12 +315,49 @@ static int timerfd_show(struct seq_file *m, struct file *file)
 #define timerfd_show NULL
 #endif
 
+#ifdef CONFIG_CHECKPOINT_RESTORE
+static long timerfd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       struct timerfd_ctx *ctx = file->private_data;
+       int ret = 0;
+
+       switch (cmd) {
+       case TFD_IOC_SET_TICKS: {
+               u64 ticks;
+
+               if (copy_from_user(&ticks, (u64 __user *)arg, sizeof(ticks)))
+                       return -EFAULT;
+               if (!ticks)
+                       return -EINVAL;
+
+               spin_lock_irq(&ctx->wqh.lock);
+               if (!timerfd_canceled(ctx)) {
+                       ctx->ticks = ticks;
+                       if (ticks)
+                               wake_up_locked(&ctx->wqh);
+               } else
+                       ret = -ECANCELED;
+               spin_unlock_irq(&ctx->wqh.lock);
+               break;
+       }
+       default:
+               ret = -ENOTTY;
+               break;
+       }
+
+       return ret;
+}
+#else
+#define timerfd_ioctl NULL
+#endif
+
 static const struct file_operations timerfd_fops = {
        .release        = timerfd_release,
        .poll           = timerfd_poll,
        .read           = timerfd_read,
        .llseek         = noop_llseek,
        .show_fdinfo    = timerfd_show,
+       .unlocked_ioctl = timerfd_ioctl,
 };
 
 static int timerfd_fget(int fd, struct fd *p)
@@ -368,7 +405,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
        else
                hrtimer_init(&ctx->t.tmr, clockid, HRTIMER_MODE_ABS);
 
-       ctx->moffs = ktime_get_monotonic_offset();
+       ctx->moffs = ktime_mono_to_real((ktime_t){ .tv64 = 0 });
 
        ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx,
                               O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS));