linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	y2038@lists.linaro.org
Subject: Re: [PATCH 1/4] uinput: Add ioctl for using monotonic/ boot times
Date: Tue, 13 Sep 2016 17:07:56 +0200	[thread overview]
Message-ID: <2791498.1bf6TGcxHc@wuerfel> (raw)
In-Reply-To: <1473775805-2242-2-git-send-email-deepa.kernel@gmail.com>

On Tuesday, September 13, 2016 7:10:02 AM CEST Deepa Dinamani wrote:
> --- a/drivers/input/misc/uinput.c
> +++ b/drivers/input/misc/uinput.c
> @@ -46,11 +46,28 @@ static int uinput_dev_event(struct input_dev *dev,
>                             unsigned int type, unsigned int code, int value)
>  {
>         struct uinput_device    *udev = input_get_drvdata(dev);
> +       struct timespec64       ts;
> +       ktime_t kt;
>  
>         udev->buff[udev->head].type = type;
>         udev->buff[udev->head].code = code;
>         udev->buff[udev->head].value = value;
> -       do_gettimeofday(&udev->buff[udev->head].time);
> +
> +       kt = ktime_get();
> +       switch (udev->clk_type) {
> +       case CLOCK_REALTIME:
> +               ts = ktime_to_timespec64(ktime_mono_to_real(kt));
> +               break;
> +       case CLOCK_MONOTONIC:
> +               ts = ktime_to_timespec64(kt);
> +               break;
> +       case CLOCK_BOOTTIME:
> +               ts = ktime_to_timespec64(ktime_mono_to_any(kt, TK_OFFS_BOOT));
> +               break;
> +       }
> +
> +       udev->buff[udev->head].time.tv_sec = ts.tv_sec;
> +       udev->buff[udev->head].time.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
> 

This is a bit inefficient. I think it's better to use
ktime_get_real_ts64(), ktime_get_ts64() and get_monotonic_boottime64().

I see that we do the same thing in evdev_events(), so maybe that isn't
overly critical though. Or we might want to change both.

The last one of these also uses the slow ktime_to_timespec64(), but
that is something we can improve later in the common code.

	Arnd

  reply	other threads:[~2016-09-13 15:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-13 14:10 [PATCH 0/4] Make input drivers y2038 safe Deepa Dinamani
2016-09-13 14:10 ` [PATCH 1/4] uinput: Add ioctl for using monotonic/ boot times Deepa Dinamani
2016-09-13 15:07   ` Arnd Bergmann [this message]
2016-09-15 17:11     ` Deepa Dinamani
2016-09-13 14:10 ` [PATCH 2/4] input: evdev: Replace timeval with timespec64 Deepa Dinamani
2016-09-13 15:08   ` Arnd Bergmann
2016-09-13 14:10 ` [PATCH 3/4] input: Deprecate real timestamps beyond year 2106 Deepa Dinamani
2016-09-13 14:59   ` Arnd Bergmann
2016-09-13 16:06   ` kbuild test robot
2016-09-13 16:34     ` Deepa Dinamani
2016-09-13 20:10       ` Deepa Dinamani
2016-09-13 20:40         ` Arnd Bergmann
2016-09-13 14:10 ` [PATCH 4/4] input: serio: Replace timeval by timespec64 Deepa Dinamani
2016-09-13 15:13   ` Arnd Bergmann
2016-09-15 17:21     ` Deepa Dinamani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2791498.1bf6TGcxHc@wuerfel \
    --to=arnd@arndb.de \
    --cc=deepa.kernel@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=y2038@lists.linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).