Re: [Y2038] [PATCH] Update struct input_event

2018-05-02 Thread Peter Hutterer
On Mon, Jan 15, 2018 at 04:16:37PM -0800, Deepa Dinamani wrote:
> The struct input_event is not y2038 safe.
> Update the struct according to the kernel patch:
> https://lkml.org/lkml/2018/1/6/324
> 
> Signed-off-by: Deepa Dinamani 

fwiw, this patch is now pushed to libinput, see commit
ee163ef63e003f7d23a6e43dcb5f52a92dfebca7. Thanks!

Cheers,
   Peter

> ---
>  include/linux/input.h   | 14 +-
>  src/evdev-mt-touchpad.c | 11 +--
>  src/evdev-tablet.c  | 12 
>  3 files changed, 30 insertions(+), 7 deletions(-)
> 
> diff --git a/include/linux/input.h b/include/linux/input.h
> index 06316b27..8274c292 100644
> --- a/include/linux/input.h
> +++ b/include/linux/input.h
> @@ -1,3 +1,4 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
>  /*
>   * Copyright (c) 1999-2002 Vojtech Pavlik
>   *
> @@ -8,6 +9,7 @@
>  #ifndef _INPUT_H
>  #define _INPUT_H
>  
> +
>  #include 
>  #include 
>  #include 
> @@ -17,10 +19,20 @@
>  
>  /*
>   * The event structure itself
> + * Note that __USE_TIME_BITS64 is defined by libc based on
> + * application's request to use 64 bit time_t.
>   */
> -
>  struct input_event {
> +#if  (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && 
> !defined(__KERNEL)
>   struct timeval time;
> +#define input_event_sec time.tv_sec
> +#define input_event_usec time.tv_usec
> +#else
> + __kernel_ulong_t __sec;
> + __kernel_ulong_t __usec;
> +#define input_event_sec  __sec
> +#define input_event_usec __usec
> +#endif
>   __u16 type;
>   __u16 code;
>   __s32 value;
> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> index 52df8fd2..7190df1c 100644
> --- a/src/evdev-mt-touchpad.c
> +++ b/src/evdev-mt-touchpad.c
> @@ -522,7 +522,13 @@ tp_process_trackpoint_button(struct tp_dispatch *tp,
>  {
>   struct evdev_dispatch *dispatch;
>   struct input_event event;
> - struct input_event syn_report = {{ 0, 0 }, EV_SYN, SYN_REPORT, 0 };
> + struct input_event syn_report = {
> +  .input_event_sec = 0,
> +  .input_event_usec = 0,
> +  .type = EV_SYN,
> +  .code = SYN_REPORT,
> +  .value = 0 };
> +
>  
>   if (!tp->buttons.trackpoint)
>   return;
> @@ -530,7 +536,8 @@ tp_process_trackpoint_button(struct tp_dispatch *tp,
>   dispatch = tp->buttons.trackpoint->dispatch;
>  
>   event = *e;
> - syn_report.time = e->time;
> + syn_report.input_event_sec = e->input_event_sec;
> + syn_report.input_event_usec = e->input_event_usec;
>  
>   switch (event.code) {
>   case BTN_0:
> diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
> index 8188686c..f81ad862 100644
> --- a/src/evdev-tablet.c
> +++ b/src/evdev-tablet.c
> @@ -1650,12 +1650,15 @@ static void
>  tablet_proximity_out_quirk_timer_func(uint64_t now, void *data)
>  {
>   struct tablet_dispatch *tablet = data;
> + struct timeval tv = us2tv(now);
>   struct input_event events[2] = {
> - { .time = us2tv(now),
> + { .input_event_sec = tv.tv_sec,
> +   .input_event_usec = tv.tv_usec,
> .type = EV_KEY,
> .code = BTN_TOOL_PEN,
> .value = 0 },
> - { .time = us2tv(now),
> + { .input_event_sec = tv.tv_sec,
> +   .input_event_usec = tv.tv_usec,
> .type = EV_SYN,
> .code = SYN_REPORT,
> .value = 0 },
> @@ -1708,9 +1711,10 @@ tablet_proximity_out_quirk_update(struct 
> tablet_dispatch *tablet,
>   /* If the timer function forced prox out before,
>  fake a BTN_TOOL_PEN event */
>   if (tablet->quirks.proximity_out_forced) {
> -
> + struct timeval tv = us2tv(time);
>   struct input_event fake_event = {
> - .time = us2tv(time),
> + .input_event_sec = tv.tv_sec,
> + .input_event_usec = tv.tv_usec,
>   .type = EV_KEY,
>   .code = BTN_TOOL_PEN,
>   .value = 1,
> -- 
> 2.14.1
> 
> ___
> Input-tools mailing list
> input-to...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/input-tools
> 
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH] Update struct input_event

2018-01-30 Thread Deepa Dinamani
On Tue, Jan 30, 2018 at 9:50 AM, Martin Kepplinger  wrote:
> Am 16.01.2018 01:16 schrieb Deepa Dinamani:
>>
>> The struct input_event is not y2038 safe.
>> Update the struct according to the kernel patch:
>> https://lkml.org/lkml/2018/1/6/324
>>
>
> For me, this patch doesn't even apply -.- Could be my fault, but what are
> you creating
> this against?

These patches were based on

mtdev commit 5f9caa26b81155feede6ff71c9b14fa0e8980fbd
mtdev-matching.c: declare global variables static
evemu commit 8cde0770ac4e45a93d4bcb0710c44b3ffe547a6f tools:
s/evtest/evemu/ in the evemu-describe man page
libevdev commit 022b2bc3b03320131966a465c464f989fa91905e include: sync
with kernel 4.13


> Other than that, I would really not pull in changes that aren't even in
> Linus' tree yet.
> We'd have a lot of unnecessary work here if we track an experimental input
> tree
> before it's ever released in Linux.

The patch is in linux-next:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=152194fe9c3f03232b9c0d0264793a7fa4af82f8
.
Adding Dmitry to clarify when he plans to merge this.

Apart from kernel, there should also be coordination between libraries.
I'm not sure how this has been done in the past.

-Deepa
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


Re: [Y2038] [PATCH] Update struct input_event

2018-01-30 Thread Dmitry Torokhov
On Tue, Jan 30, 2018 at 05:45:55PM -0800, Deepa Dinamani wrote:
> On Tue, Jan 30, 2018 at 9:50 AM, Martin Kepplinger  wrote:
> > Am 16.01.2018 01:16 schrieb Deepa Dinamani:
> >>
> >> The struct input_event is not y2038 safe.
> >> Update the struct according to the kernel patch:
> >> https://lkml.org/lkml/2018/1/6/324
> >>
> >
> > For me, this patch doesn't even apply -.- Could be my fault, but what are
> > you creating
> > this against?
> 
> These patches were based on
> 
> mtdev commit 5f9caa26b81155feede6ff71c9b14fa0e8980fbd
> mtdev-matching.c: declare global variables static
> evemu commit 8cde0770ac4e45a93d4bcb0710c44b3ffe547a6f tools:
> s/evtest/evemu/ in the evemu-describe man page
> libevdev commit 022b2bc3b03320131966a465c464f989fa91905e include: sync
> with kernel 4.13
> 
> 
> > Other than that, I would really not pull in changes that aren't even in
> > Linus' tree yet.
> > We'd have a lot of unnecessary work here if we track an experimental input
> > tree
> > before it's ever released in Linux.
> 
> The patch is in linux-next:
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=152194fe9c3f03232b9c0d0264793a7fa4af82f8
> .
> Adding Dmitry to clarify when he plans to merge this.

It will be merged in this merge window that just opened.

Thanks.

-- 
Dmitry
___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH] Update struct input_event

2018-01-15 Thread Deepa Dinamani
The struct input_event is not y2038 safe.
Update the struct according to the kernel patch:
https://lkml.org/lkml/2018/1/6/324

Signed-off-by: Deepa Dinamani 
---
 src/core.c| 3 ++-
 test/mtdev-test.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/core.c b/src/core.c
index 87ef420..c3f7a68 100644
--- a/src/core.c
+++ b/src/core.c
@@ -251,7 +251,8 @@ static void push_slot_changes(struct mtdev_state *state,
count++;
if (!count)
return;
-   ev.time = syn->time;
+   ev.input_event_sec = syn->input_event_sec;
+   ev.input_event_usec = syn->input_event_usec;
ev.type = EV_ABS;
ev.code = ABS_MT_SLOT;
ev.value = slot;
diff --git a/test/mtdev-test.c b/test/mtdev-test.c
index 1b3e4f2..9055863 100644
--- a/test/mtdev-test.c
+++ b/test/mtdev-test.c
@@ -47,7 +47,7 @@ static void print_event(const struct input_event *ev)
 {
static const mstime_t ms = 1000;
static int slot;
-   mstime_t evtime = ev->time.tv_usec / ms + ev->time.tv_sec * ms;
+   mstime_t evtime = ev->input_event_usec / ms + ev->input_event_sec * ms;
if (ev->type == EV_ABS && ev->code == ABS_MT_SLOT)
slot = ev->value;
fprintf(stderr, "%012llx %02d %01d %04x %d\n",
-- 
2.14.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH] Update struct input_event

2018-01-15 Thread Deepa Dinamani
The struct input_event is not y2038 safe.
Update the struct according to the kernel patch:
https://lkml.org/lkml/2018/1/6/324

Signed-off-by: Deepa Dinamani 
---
 include/linux/input.h   | 14 +-
 src/evdev-mt-touchpad.c | 11 +--
 src/evdev-tablet.c  | 12 
 3 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/include/linux/input.h b/include/linux/input.h
index 06316b27..8274c292 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 /*
  * Copyright (c) 1999-2002 Vojtech Pavlik
  *
@@ -8,6 +9,7 @@
 #ifndef _INPUT_H
 #define _INPUT_H
 
+
 #include 
 #include 
 #include 
@@ -17,10 +19,20 @@
 
 /*
  * The event structure itself
+ * Note that __USE_TIME_BITS64 is defined by libc based on
+ * application's request to use 64 bit time_t.
  */
-
 struct input_event {
+#if(__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && 
!defined(__KERNEL)
struct timeval time;
+#define input_event_sec time.tv_sec
+#define input_event_usec time.tv_usec
+#else
+   __kernel_ulong_t __sec;
+   __kernel_ulong_t __usec;
+#define input_event_sec  __sec
+#define input_event_usec __usec
+#endif
__u16 type;
__u16 code;
__s32 value;
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 52df8fd2..7190df1c 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -522,7 +522,13 @@ tp_process_trackpoint_button(struct tp_dispatch *tp,
 {
struct evdev_dispatch *dispatch;
struct input_event event;
-   struct input_event syn_report = {{ 0, 0 }, EV_SYN, SYN_REPORT, 0 };
+   struct input_event syn_report = {
+.input_event_sec = 0,
+.input_event_usec = 0,
+.type = EV_SYN,
+.code = SYN_REPORT,
+.value = 0 };
+
 
if (!tp->buttons.trackpoint)
return;
@@ -530,7 +536,8 @@ tp_process_trackpoint_button(struct tp_dispatch *tp,
dispatch = tp->buttons.trackpoint->dispatch;
 
event = *e;
-   syn_report.time = e->time;
+   syn_report.input_event_sec = e->input_event_sec;
+   syn_report.input_event_usec = e->input_event_usec;
 
switch (event.code) {
case BTN_0:
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 8188686c..f81ad862 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -1650,12 +1650,15 @@ static void
 tablet_proximity_out_quirk_timer_func(uint64_t now, void *data)
 {
struct tablet_dispatch *tablet = data;
+   struct timeval tv = us2tv(now);
struct input_event events[2] = {
-   { .time = us2tv(now),
+   { .input_event_sec = tv.tv_sec,
+ .input_event_usec = tv.tv_usec,
  .type = EV_KEY,
  .code = BTN_TOOL_PEN,
  .value = 0 },
-   { .time = us2tv(now),
+   { .input_event_sec = tv.tv_sec,
+ .input_event_usec = tv.tv_usec,
  .type = EV_SYN,
  .code = SYN_REPORT,
  .value = 0 },
@@ -1708,9 +1711,10 @@ tablet_proximity_out_quirk_update(struct tablet_dispatch 
*tablet,
/* If the timer function forced prox out before,
   fake a BTN_TOOL_PEN event */
if (tablet->quirks.proximity_out_forced) {
-
+   struct timeval tv = us2tv(time);
struct input_event fake_event = {
-   .time = us2tv(time),
+   .input_event_sec = tv.tv_sec,
+   .input_event_usec = tv.tv_usec,
.type = EV_KEY,
.code = BTN_TOOL_PEN,
.value = 1,
-- 
2.14.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038


[Y2038] [PATCH] Update struct input_event

2018-01-15 Thread Deepa Dinamani
The struct input_event is not y2038 safe.
Update the struct according to the kernel patch:
https://lkml.org/lkml/2018/1/6/324

Signed-off-by: Deepa Dinamani 
---
 include/linux/input.h   | 14 +-
 src/evdev-mt-touchpad.c | 11 +--
 src/evdev-tablet.c  | 12 
 3 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/include/linux/input.h b/include/linux/input.h
index 06316b27..8274c292 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 /*
  * Copyright (c) 1999-2002 Vojtech Pavlik
  *
@@ -8,6 +9,7 @@
 #ifndef _INPUT_H
 #define _INPUT_H
 
+
 #include 
 #include 
 #include 
@@ -17,10 +19,20 @@
 
 /*
  * The event structure itself
+ * Note that __USE_TIME_BITS64 is defined by libc based on
+ * application's request to use 64 bit time_t.
  */
-
 struct input_event {
+#if(__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && 
!defined(__KERNEL)
struct timeval time;
+#define input_event_sec time.tv_sec
+#define input_event_usec time.tv_usec
+#else
+   __kernel_ulong_t __sec;
+   __kernel_ulong_t __usec;
+#define input_event_sec  __sec
+#define input_event_usec __usec
+#endif
__u16 type;
__u16 code;
__s32 value;
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 52df8fd2..7190df1c 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -522,7 +522,13 @@ tp_process_trackpoint_button(struct tp_dispatch *tp,
 {
struct evdev_dispatch *dispatch;
struct input_event event;
-   struct input_event syn_report = {{ 0, 0 }, EV_SYN, SYN_REPORT, 0 };
+   struct input_event syn_report = {
+.input_event_sec = 0,
+.input_event_usec = 0,
+.type = EV_SYN,
+.code = SYN_REPORT,
+.value = 0 };
+
 
if (!tp->buttons.trackpoint)
return;
@@ -530,7 +536,8 @@ tp_process_trackpoint_button(struct tp_dispatch *tp,
dispatch = tp->buttons.trackpoint->dispatch;
 
event = *e;
-   syn_report.time = e->time;
+   syn_report.input_event_sec = e->input_event_sec;
+   syn_report.input_event_usec = e->input_event_usec;
 
switch (event.code) {
case BTN_0:
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 8188686c..f81ad862 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -1650,12 +1650,15 @@ static void
 tablet_proximity_out_quirk_timer_func(uint64_t now, void *data)
 {
struct tablet_dispatch *tablet = data;
+   struct timeval tv = us2tv(now);
struct input_event events[2] = {
-   { .time = us2tv(now),
+   { .input_event_sec = tv.tv_sec,
+ .input_event_usec = tv.tv_usec,
  .type = EV_KEY,
  .code = BTN_TOOL_PEN,
  .value = 0 },
-   { .time = us2tv(now),
+   { .input_event_sec = tv.tv_sec,
+ .input_event_usec = tv.tv_usec,
  .type = EV_SYN,
  .code = SYN_REPORT,
  .value = 0 },
@@ -1708,9 +1711,10 @@ tablet_proximity_out_quirk_update(struct tablet_dispatch 
*tablet,
/* If the timer function forced prox out before,
   fake a BTN_TOOL_PEN event */
if (tablet->quirks.proximity_out_forced) {
-
+   struct timeval tv = us2tv(time);
struct input_event fake_event = {
-   .time = us2tv(time),
+   .input_event_sec = tv.tv_sec,
+   .input_event_usec = tv.tv_usec,
.type = EV_KEY,
.code = BTN_TOOL_PEN,
.value = 1,
-- 
2.14.1

___
Y2038 mailing list
Y2038@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/y2038