lkml.org 
[lkml]   [2016]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RESEND PATCH 05/14] eeprom: at24: hide the read/write loop behind a macro
2016-07-15 14:24 GMT+02:00 Wolfram Sang <wsa@the-dreams.de>:
>> +/*
>> + * Both reads and writes fail if the previous write didn't complete yet. This
>> + * macro loops a few times waiting at least long enough for one entire page
>> + * write to work.
>> + *
>> + * It takes two parameters: a variable in which the future timeout in jiffies
>> + * will be stored and a temporary variable holding the time of the last
>> + * iteration of processing the request. Both should be unsigned integers
>> + * holding at least 32 bits.
>> + */
>> +#define loop_until_timeout(tout, op_time) \
>> + for (tout = jiffies + msecs_to_jiffies(write_timeout), \
>> + op_time = jiffies; \
>> + time_before(op_time, tout); \
>> + usleep_range(1000, 1500), op_time = jiffies)
>
> There is one subtle change coming with this change: the do-while loop is
> guaranteed to run at least once while the for-loop doesn't.
>

While it's technically possible, it will never happen as long as
write_timeout is set to some sensible value.

Thanks,
Bartosz

\
 
 \ /
  Last update: 2016-07-15 15:41    [W:1.188 / U:0.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site