Skip to content

Commit 148c01d

Browse files
Dejin Zhengbroonie
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent e44ab4e commit 148c01d

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

include/linux/regmap.h

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,10 @@ struct reg_sequence {
202202
*/
203203
#define regmap_field_read_poll_timeout(field, val, cond, sleep_us, timeout_us) \
204204
({ \
205-
u64 __timeout_us = (timeout_us); \
206-
unsigned long __sleep_us = (sleep_us); \
207-
ktime_t timeout = ktime_add_us(ktime_get(), __timeout_us); \
208-
int pollret; \
209-
might_sleep_if(__sleep_us); \
210-
for (;;) { \
211-
pollret = regmap_field_read((field), &(val)); \
212-
if (pollret) \
213-
break; \
214-
if (cond) \
215-
break; \
216-
if (__timeout_us && ktime_compare(ktime_get(), timeout) > 0) { \
217-
pollret = regmap_field_read((field), &(val)); \
218-
break; \
219-
} \
220-
if (__sleep_us) \
221-
usleep_range((__sleep_us >> 2) + 1, __sleep_us); \
222-
} \
223-
pollret ?: ((cond) ? 0 : -ETIMEDOUT); \
205+
int __ret, __tmp; \
206+
__tmp = read_poll_timeout(regmap_field_read, __ret, __ret || (cond), \
207+
sleep_us, timeout_us, false, (field), &(val)); \
208+
__ret ?: __tmp; \
224209
})
225210

226211
#ifdef CONFIG_REGMAP

0 commit comments

Comments
 (0)