summaryrefslogtreecommitdiff
path: root/include/linux/regmap.h
diff options
context:
space:
mode:
authorDejin Zheng <zhengdejin5@gmail.com>2020-04-20 16:46:47 +0300
committerMark Brown <broonie@kernel.org>2020-04-20 17:47:32 +0300
commit148c01d176237115d9c2805f6d29c0b6a72fbd10 (patch)
tree53e25c8a8d1502e6726d22911ee213d62d8bc417 /include/linux/regmap.h
parente44ab4e14d6f4c448ae555132090c1a116b19e5c (diff)
downloadlinux-148c01d176237115d9c2805f6d29c0b6a72fbd10.tar.xz
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: Dejin Zheng <zhengdejin5@gmail.com> Link: https://lore.kernel.org/r/20200420134647.9121-3-zhengdejin5@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'include/linux/regmap.h')
-rw-r--r--include/linux/regmap.h23
1 files changed, 4 insertions, 19 deletions
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index b50e930a9c18..4c4fbe4d41a6 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -202,25 +202,10 @@ struct reg_sequence {
*/
#define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \
({ \
- u64 __timeout_us = (timeout_us); \
- unsigned long __sleep_us = (sleep_us); \
- ktime_t timeout = ktime_add_us(ktime_get(), __timeout_us); \
- int pollret; \
- 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); \
+ int __ret, __tmp; \
+ __tmp = read_poll_timeout(regmap_field_read, __ret, __ret || (cond), \
+ sleep_us, timeout_us, false, (field), &(val)); \
+ __ret ?: __tmp; \
})
#ifdef CONFIG_REGMAP