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 <aghayal@codeaurora.org>
This commit is contained in:
Anirudh Ghayal 2019-11-13 08:50:04 +05:30 committed by Gerrit - the friendly Code Review server
parent 9e9032d155
commit 3b6d6e9c81

View file

@ -340,6 +340,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);
}