[PATCH] Update struct input_event

Deepa Dinamani deepa.kernel at gmail.com
Tue Jan 16 00:16:37 UTC 2018


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 <deepa.kernel at gmail.com>
---
 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 <sys/time.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
@@ -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



More information about the Input-tools mailing list