All of lore.kernel.org
 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 3/4] input: Deprecate real timestamps beyond year 2106
Date: Tue, 13 Sep 2016 16:59:28 +0200	[thread overview]
Message-ID: <295456784.VzTNlDXujm@wuerfel> (raw)
In-Reply-To: <1473775805-2242-4-git-send-email-deepa.kernel@gmail.com>

On Tuesday, September 13, 2016 7:10:04 AM CEST Deepa Dinamani wrote:
> struct timeval is not y2038 safe.
> All usage of timeval in the kernel will be replaced by
> y2038 safe structures.
> 
> struct input_event maintains time for each input event.
> Real time timestamps are not ideal for input as this
> time can go backwards as noted in the patch a80b83b7b8
> by John Stultz. Hence, having the input_event.time fields
> only big enough for monotonic and boot times are
> sufficient.
> 
> Leave the original input_event as is. This is to maintain
> backward compatibility with existing userspace interfaces
> that use input_event.
> Introduce a new replacement struct raw_input_event.
> This replaces timeval with struct input_timeval. This structure
> maintains time in __kernel_ulong_t or compat_ulong_t to allow
> for architectures to override types as in the case of x32.
> 
> The change requires any userspace utilities reading or writing
> from event nodes to update their reading format to match
> raw_input_event.The changes to the popular libraries will be
> posted along with the kernel changes.
> The driver version is also updated to reflect the change in
> event format.
> 
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>

Looks very nice!

Two small suggestions from my side:

> diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
> index e794f7b..1379899 100644
> --- a/include/uapi/linux/input.h
> +++ b/include/uapi/linux/input.h
> @@ -21,7 +21,23 @@
>  /*
>   * The event structure itself
>   */
> +struct input_timeval {
> +	__kernel_ulong_t tv_sec;
> +	__kernel_ulong_t tv_usec;
> +};
> +
> +struct raw_input_event {
> +	struct input_timeval time;
> +	__u16 type;
> +	__u16 code;
> +	__s32 value;
> +};

Maybe a comment here that this is intentionally "unsigned" so we
can count until 2106 instead of 2038.

> +/* Userspace structure.
> + * Definition maintained here for userspace that is not yet updated to use
> + * struct raw_input_event.
> + * Not to be used anywhere within the kernel.
> + */
>  struct input_event {
>  	struct timeval time;
>  	__u16 type;
> @@ -29,11 +45,32 @@ struct input_event {
>  	__s32 value;
>  };
>  
> +static inline void
> +raw_input_to_input_event(struct raw_input_event *raw, struct input_event *ev)
> +{
> +	ev->time.tv_sec = raw->time.tv_sec;
> +	ev->time.tv_usec = raw->time.tv_usec;
> +	ev->type = raw->type;
> +	ev->code = raw->code;
> +	ev->value = raw->value;
> +}
> +
> +static inline void
> +input_to_raw_event(struct input_event *ev, struct raw_input_event *raw)
> +{
> +	raw->time.tv_sec = ev->time.tv_sec;
> +	raw->time.tv_usec = ev->time.tv_usec;
> +	raw->type = ev->type;
> +	raw->code = ev->code;
> +	raw->value = ev->value;
> +}

Here, an "#ifndef __KERNEL__" guard might help to enforce what you
write in the comment.

	Arnd

  reply	other threads:[~2016-09-13 14:59 UTC|newest]

Thread overview: 18+ 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 14:10   ` Deepa Dinamani
2016-09-13 15:07   ` Arnd Bergmann
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 [this message]
2016-09-13 16:06   ` kbuild test robot
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 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=295456784.VzTNlDXujm@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.