A few questions about SD/MMC drivers

Konstantin Belousov kostikbel at gmail.com
Mon Oct 6 17:15:28 UTC 2014


On Sun, Oct 05, 2014 at 07:05:16PM -0300, Martin Galvan wrote:
> 3) Finally, I noticed in the Linux driver they sometimes wrap a
> register read operation around a do-while loop waiting on both the
> result of that read and a timer, like this:
> 
> do {
>     read_value = read_a_register(some_register);
> } while ((read_value != desired_value) && (time_before(jiffies, expire));
> 
> where "expire" is an unsigned long whose value is computed as the sum
> of a global called "jiffies" and the result of a call to
> msecs_to_jiffies(). This is done so after the loop they can check
> whether the register holds the desired value or a timeout occurred. Do
> we have something similar on BSD? If not, what would be a safer way to
> implement a timeout mechanism than simply decreasing a counter?

Look at the _intel_wait_for() in the sys/dev/drm2/i915/intel_drv.h.
There is improved version of the macro in the i915 update I posted
several days ago.


More information about the freebsd-embedded mailing list