From 40e7dc2fd6d8722d0f550cb251fc5abd1f14d0fb Mon Sep 17 00:00:00 2001 From: Anirudh Ghayal Date: Wed, 13 Nov 2019 08:50:04 +0530 Subject: [PATCH] regmap: Quit the read-loop based on position of file-offset Some implementation's of the 'cat' command pass the absolute position of the file-offset. In the current implementation of 'regmap_data_read_file' this leads to dumping all the registers from offset 0. Avoid this by quitting the read loop if the file-offset requested is lower than actual read-offset. Change-Id: I7c6c31958e92f16387bf4cb5de7fbf4572fcce21 Signed-off-by: Anirudh Ghayal --- drivers/base/regmap/regmap-debugfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index bae7dfddde2d..08fb93286f29 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c @@ -355,6 +355,9 @@ static ssize_t regmap_data_read_file(struct file *file, char __user *user_buf, else if (*ppos >= map->dump_address * map->debugfs_tot_len + map->dump_count * map->debugfs_tot_len) return 0; + else if (*ppos < map->dump_address * map->debugfs_tot_len) + return 0; + return regmap_read_debugfs(map, 0, map->max_register, user_buf, new_count, ppos); }