use read_poll_timeout macro to simplify code
cover use read_poll_timeout macro to simplify code
redefined regmap_read_poll_timeout and regmap_field_read_poll_timeout by read_poll_timeout to simplify code, they have many similar codes.
Dejin Zheng (2):
regmap: redefined regmap_read_poll_timeout to simplify code
regmap: redefined regmap_field_read_poll_timeout to simplify code
include/linux/regmap.h | 48 ++++++++---------------------------------- 1 file changed, 9 insertions(+), 39 deletions(-)
Signature · 1 line
2.25.0
PATCH 1/2 regmap: redefined regmap_read_poll_timeout to simplify code
use read_poll_timeout macro to redefined regmap_read_poll_timeout and also remove the duplicate code.
--- include/linux/regmap.h | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
include/linux/regmap.h +5 -20
@@ -17,6 +17,7 @@#include <linux/err.h> #include <linux/bug.h> #include <linux/lockdep.h> +#include <linux/iopoll.h> struct module ;struct clk ;
@@ -122,26 +123,10 @@ struct reg_sequence {*/ #define regmap_read_poll_timeout (map, addr, 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 __ret; \ - 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); \ + int __ret, __tmp; \ + __tmp = read_poll_timeout(regmap_read, __ret, __ret || (cond), \ + sleep_us, timeout_us, false, (map), (addr), &(val)); \ + __ret ?: __tmp; \ })/**
Signature · 1 line
2.25.0
PATCH 2/2 regmap: redefined regmap_field_read_poll_timeout to simplify code
In reply to Dejin Zhenguse read_poll_timeout macro to redefined regmap_field_read_poll_timeout and also remove the duplicate code.
--- include/linux/regmap.h | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)
include/linux/regmap.h +4 -19
@@ -194,25 +194,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
Signature · 1 line
2.25.0
Mark Brown
maintainerQuoted 8 lines · Dejin Zheng
redefined
regmap_read_poll_timeoutandregmap_field_read_poll_timeoutbyread_poll_timeoutto simplify code, they have many similar codes.Dejin Zheng (2):
regmap: redefinedregmap_read_poll_timeoutto simplify code
regmap: redefinedregmap_field_read_poll_timeoutto simplify code[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-5.8
Thanks!
[1/2] regmap: Simplify implementation of the regmap_read_poll_timeout() macro
commit: e44ab4e14d6f4c448ae555132090c1a116b19e5c
[2/2] regmap: Simplify implementation of the regmap_field_read_poll_timeout() macro
commit: 148c01d176237115d9c2805f6d29c0b6a72fbd10All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark