Commit 148c01d1 authored by Dejin Zheng's avatar Dejin Zheng Committed by Mark Brown

regmap: Simplify implementation of the regmap_field_read_poll_timeout() macro

Simplify the implementation of the macro regmap_field_read_poll_timeout()
by using the macro read_poll_timeout().
Signed-off-by: default avatarDejin Zheng <zhengdejin5@gmail.com>
Link: https://lore.kernel.org/r/20200420134647.9121-3-zhengdejin5@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e44ab4e1
...@@ -202,25 +202,10 @@ struct reg_sequence { ...@@ -202,25 +202,10 @@ struct reg_sequence {
*/ */
#define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \ #define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \
({ \ ({ \
u64 __timeout_us = (timeout_us); \ int __ret, __tmp; \
unsigned long __sleep_us = (sleep_us); \ __tmp = read_poll_timeout(regmap_field_read, __ret, __ret || (cond), \
ktime_t timeout = ktime_add_us(ktime_get(), __timeout_us); \ sleep_us, timeout_us, false, (field), &(val)); \
int pollret; \ __ret ?: __tmp; \
might_sleep_if(__sleep_us); \
for (;;) { \
pollret = regmap_field_read((field), &(val)); \
if (pollret) \
break; \
if (cond) \
break; \
if (__timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
pollret = regmap_field_read((field), &(val)); \
break; \
} \
if (__sleep_us) \
usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
} \
pollret ?: ((cond) ? 0 : -ETIMEDOUT); \
}) })
#ifdef CONFIG_REGMAP #ifdef CONFIG_REGMAP
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment