Here is the sixth version for converting parport device(ppdev) to y2038 safe. The first four could found at [1][2][3][4][5].
An y2038 safe application/kernel use 64bit time_t(aka time64_t) instead of 32bit time_t. Given that some time relative struct(e.g. timeval in ppdev.c) is mainly the offset of the real time, the old 32bit time_t in such application is safe. We need to handle the 32bit time_t and 64bit time_t application at the same time.
My approach here is handle them as different ioctl command for different size of timeval.
Build successful on arm64 and arm.
Changes since v5: 1. Replace PP[GS]ETTIME_safe/unsafe with PP[GS]ETTIME32/64. 2. Rewirte PPSETTIME ioctl with jiffies_to_timespec64 in order to replace user fake HZ(TICK_USEC) to kernel HZ(TICK_NSEC). 3. define tv_sec as long and tv_usec as int in pp_set_timeout. It should be enough for the timeout.
Change since v4: 1. change type of tv_sec and tv_usec to s64 in pp_set_timeout. Use s64 could avoid s64 cast to s32 in arm 32bit.
Changes since V3: 1. create pp_set_timeout, pp_get_timeout to reduce the duplicated code in my patch according to the suggestion of arnd. I use div_u64_rem instead of jiffies_to_timespec64 because it could save a divide operaion.
[1] https://lists.linaro.org/pipermail/y2038/2015-June/000522.html [2] https://lists.linaro.org/pipermail/y2038/2015-June/000567.html [3] https://lists.linaro.org/pipermail/y2038/2015-November/001093.html [4] https://lists.linaro.org/pipermail/y2038/2015-November/001132.html [5] https://lists.linaro.org/pipermail/y2038/2015-December/001201.html
Bamvor Jian Zhang (2): ppdev: convert to y2038 safe ppdev: add support for compat ioctl
drivers/char/ppdev.c | 86 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 20 deletions(-)