mirror of https://gitee.com/openkylin/linux.git
regmap: Simplify implementation of the regmap_read_poll_timeout() macro
Simplify the implementation of the macro regmap_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-2-zhengdejin5@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
3ada1b176e
commit
e44ab4e14d
|
@ -17,6 +17,7 @@
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/bug.h>
|
#include <linux/bug.h>
|
||||||
#include <linux/lockdep.h>
|
#include <linux/lockdep.h>
|
||||||
|
#include <linux/iopoll.h>
|
||||||
|
|
||||||
struct module;
|
struct module;
|
||||||
struct clk;
|
struct clk;
|
||||||
|
@ -130,26 +131,10 @@ struct reg_sequence {
|
||||||
*/
|
*/
|
||||||
#define regmap_read_poll_timeout(map, addr, val, cond, sleep_us, timeout_us) \
|
#define regmap_read_poll_timeout(map, addr, 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_read, __ret, __ret || (cond), \
|
||||||
ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
|
sleep_us, timeout_us, false, (map), (addr), &(val)); \
|
||||||
int __ret; \
|
__ret ?: __tmp; \
|
||||||
might_sleep_if(__sleep_us); \
|
|
||||||
for (;;) { \
|
|
||||||
__ret = regmap_read((map), (addr), &(val)); \
|
|
||||||
if (__ret) \
|
|
||||||
break; \
|
|
||||||
if (cond) \
|
|
||||||
break; \
|
|
||||||
if ((__timeout_us) && \
|
|
||||||
ktime_compare(ktime_get(), __timeout) > 0) { \
|
|
||||||
__ret = regmap_read((map), (addr), &(val)); \
|
|
||||||
break; \
|
|
||||||
} \
|
|
||||||
if (__sleep_us) \
|
|
||||||
usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
|
|
||||||
} \
|
|
||||||
__ret ?: ((cond) ? 0 : -ETIMEDOUT); \
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue