On Monday 16 November 2015 07:31:12 Bamvor Jian Zhang wrote:
@@ -322,6 +329,32 @@ static enum ieee1284_phase init_phase (int mode) return IEEE1284_PH_FWD_IDLE; } +static int pp_set_timeout(struct pardevice *pdev, __kernel_time_t tv_sec,
__kernel_suseconds_t tv_usec)
+{
- 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;
- pdev->timeout = to_jiffies;
- return 0;
+}
The code looks good, but now your prototype has a '__kernel_time_t', and we are in the process of removing all instances of that from the kernel so we can eventually remove the definition and make sure that no drivers start using it.
Better just use 'long' for tv_sec and tv_usec.
+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;
+}
- case PPGETTIME_unsafe:
pp_get_timeout(pp->pdev, (s64*)&time32[0], (s64*)&time32[1]);
This does not do the right thing: You pass a pointer to a 32-bit variable into a function that takes a pointer to a 64-bit variable, so you get a stack overflow writing to the second half!
Arnd