v4l2-core: make VIDIOC_DQEVENT y2038 safe

The v4l2_event structure contains a 'struct timespec' member that is
defined by the user space C library, creating an ABI incompatibility
when that gets updated to a 64-bit time_t.

While passing a 32-bit time_t here would be sufficient for CLOCK_MONOTONIC
timestamps, simply redefining the structure to use the kernel's
__kernel_old_timespec would not work for any library that uses a copy
of the linux/videodev2.h header file rather than including the copy from
the latest kernel headers.

This means the kernel has to be changed to handle both versions of the
structure layout on a 32-bit architecture.

For the compat code, another imcompatibility arises: while almost all
32-bit architectures now use the same layout as 64-bit architectures
and the commands can simply be passed through, on x86 the internal
alignment of v4l2_event is different because of the 64-bit member
in v4l2_event_ctrl. To handle all architectures, this now requires
defining four different versions of the structure to cover all
possible combinations. The compat handling for VIDIOC_DQEVENT32 and
VIDIOC_DQEVENT32_TIME32 is now inside of an #ifdef so it does not get
used on architectures other than x86.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
6 files changed