RE: [PATCH] [SCSI] osst: remove double conversion of timeout

From: Seymour, Shane M
Date: Thu Jan 07 2016 - 19:02:25 EST


Hi Nicholas,

> - msleep(jiffies_to_msecs(initial_delay));
> + schedule_timeout_uninterruptible(initial_delay);

The code to msleep looks like this:

/**
* msleep - sleep safely even with waitqueue interruptions
* @msecs: Time in milliseconds to sleep for
*/
void msleep(unsigned int msecs)
{
unsigned long timeout = msecs_to_jiffies(msecs) + 1;

while (timeout)
timeout = schedule_timeout_uninterruptible(timeout);
}

So msleep will wait for the requested amount of time to pass even if woken early but your change may not. To make it equivalent you would need to borrow code from msleep and remove the "if (initial_delay > 0)" and just have:

while (initial_delay)
initial_delay = schedule_timeout_uninterruptible(initial_delay);

We can change initial_delay since it's not used elsewhere in the function and if initial_delay is 0 we won't ever call schedule_timeout_uninterruptible in the while loop so there's no need to test if it's > 0 or not.

Thanks
Shane