Re: [RESEND PATCH 05/14] eeprom: at24: hide the read/write loop behind a macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +/*
> + * 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.

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux