On Saturday 05 December 2015 23:57:59 Bamvor Jian Zhang wrote:
+{
- long to_jiffies;
- if ((tv_sec < 0) || (tv_usec < 0))
return -EINVAL;
- to_jiffies = usecs_to_jiffies(tv_usec);
- to_jiffies += tv_sec * (long)HZ;
- if (to_jiffies <= 0)
return -EINVAL;
- lp_table[minor].timeout = to_jiffies;
- return 0;
+}
I think tv_sec can also be shorter, as we ignore the upper bits after the multiplication with HZ.
Given that long is 64bit in 64bit architecture, shall I keep tv_sec as s64 and cast HZ to s64 as well?
to_jiffies += tv_sec * (s64)HZ;
I would just leave tv_sec as 'long' then.
You don't need a cast for HZ at all.
Neither of them is important, since it only matters if the timeout is more than 50 days, and that is not a setting we need to worry about.
Arnd