On Friday 04 December 2015 22:24:55 Bamvor Jian Zhang wrote:
static DEFINE_MUTEX(pp_do_mutex);
+/* define fixed sized ioctl cmd for y2038 migration */ +#define PPGETTIME_unsafe _IOR(PP_IOCTL, 0x95, s32[2]) +#define PPSETTIME_unsafe _IOW(PP_IOCTL, 0x96, s32[2]) +#define PPGETTIME_safe _IOR(PP_IOCTL, 0x95, s64[2]) +#define PPSETTIME_safe _IOW(PP_IOCTL, 0x96, s64[2])
After looking at this again, I realized that 'unsafe' and 'safe' doesn't really describe them well: both are safe here, as the timeout is a relative time, so maybe PPGETTIME32/PPGETTIME64 would be a better description.
+static void pp_get_timeout(struct pardevice *pdev, s64 *tv_sec, s64 *tv_usec) +{
- u32 rem;
- *tv_sec = div_u64_rem((u64)(pdev->timeout) * TICK_USEC,
USEC_PER_SEC, &rem);
- *tv_usec = rem;
+}
TICK_USEC is the wrong constant here, because it refers to what user space thinks we use, not what we actually do. I think the simplest way here would be to call jiffies_to_timespec64() and use another NSEC_PER_USEC division to get to the usec value.
Arnd