Commit 8a2ceac6 authored by Mark Brown's avatar Mark Brown

regmap: Split raw writes that cross window boundaries

If a block write covers a paged memory region and crosses a window
boundary then rather than failing the write split the transfer up
into multiple writes, making the whole process more transparent for
drivers.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 0ff3e62f
...@@ -852,8 +852,30 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg, ...@@ -852,8 +852,30 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg,
range = _regmap_range_lookup(map, reg); range = _regmap_range_lookup(map, reg);
if (range) { if (range) {
ret = _regmap_select_page(map, &reg, range, int val_num = val_len / map->format.val_bytes;
val_len / map->format.val_bytes); int win_offset = (reg - range->range_min) % range->window_len;
int win_residue = range->window_len - win_offset;
/* If the write goes beyond the end of the window split it */
while (val_num > win_residue) {
dev_dbg(map->dev, "Writing window %d/%d\n",
win_residue, val_len / map->format.val_bytes);
ret = _regmap_raw_write(map, reg, val, win_residue *
map->format.val_bytes);
if (ret != 0)
return ret;
reg += win_residue;
val_num -= win_residue;
val += win_residue * map->format.val_bytes;
val_len -= win_residue * map->format.val_bytes;
win_offset = (reg - range->range_min) %
range->window_len;
win_residue = range->window_len - win_offset;
}
ret = _regmap_select_page(map, &reg, range, val_num);
if (ret != 0) if (ret != 0)
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment