Re: [PATCH] eeprom: at24: Fix unexpected timeout under high load

From: Andy Shevchenko
Date: Sat Aug 04 2018 - 16:52:04 EST


On Sat, Aug 4, 2018 at 8:43 PM, Mark Jonas <mark.jonas@xxxxxxxxxxxx> wrote:


> -#define at24_loop_until_timeout(tout, op_time) \
> - for (tout = jiffies + msecs_to_jiffies(at24_write_timeout), \
> - op_time = 0; \
> - op_time ? time_before(op_time, tout) : true; \
> - usleep_range(1000, 1500), op_time = jiffies)

This one understandble and represents one operation.

> +#define at24_loop_until_timeout_begin(tout, op_time) \
> + tout = jiffies + msecs_to_jiffies(at24_write_timeout); \
> + while (true) { \
> + op_time = jiffies;
> +
> +#define at24_loop_until_timeout_end(tout, op_time) \
> + if (time_before(tout, op_time)) \
> + break; \
> + usleep_range(1000, 1500); \
> + }

Besides `while (true)`, which is a red flag for timeout loops,
these are done in an hack way. Just open code them in both cases, or
rewrite original one to keel it's semantics.

--
With Best Regards,
Andy Shevchenko