> +     void __iomem *reg;
> +     int timeout = 100;
> +     u64 reg_val;
> +
> +     reg = rvu->afreg_base + ((block << 28) | offset);
> +     while (timeout) {
> +             reg_val = readq(reg);
> +             if (zero && !(reg_val & mask))
> +                     return 0;
> +             if (!zero && (reg_val & mask))
> +                     return 0;
> +             usleep_range(1, 2);
> +             timeout--;
> +     }

One more clarification here: if you loop around a usleep_range(),
I would suggest using 'while (time_before(jiffies, end))'
or 'ktime_before(ktime_get(), end)' as the loop condition, otherwise
the maximum timeout can be fairly large depending on the
actual configuration and presence of timers. Then you can
also make the range much wider, e.g. 'usleep_range(1, 10)'

Aside from that, this looks much better than the delay loop
you had before.

      Arnd

Reply via email to