ret = -ENOTSUPP;
goto out;
}
-- if (map->max_raw_read && map->max_raw_read < val_len) {
-- ret = -E2BIG;
-- goto out;
-- }
-- /* Physical block read if there's no cache involved */
-- ret = _regmap_raw_read(map, reg, val, val_len);
++ if (map->use_single_read)
++ chunk_regs = 1;
++ else if (map->max_raw_read && val_len > map->max_raw_read)
++ chunk_regs = map->max_raw_read / val_bytes;
++
++ chunk_count = val_count / chunk_regs;
++ chunk_bytes = chunk_regs * val_bytes;
+
++ /* Read bytes that fit into whole chunks */
++ for (i = 0; i < chunk_count; i++) {
++ ret = _regmap_raw_read(map, reg, val, chunk_bytes);
++ if (ret != 0)
++ goto out;
++
++ reg += regmap_get_offset(map, chunk_regs);
++ val += chunk_bytes;
++ val_len -= chunk_bytes;
++ }
+
++ /* Read remaining bytes */
++ if (val_len) {
++ ret = _regmap_raw_read(map, reg, val, val_len);
++ if (ret != 0)
++ goto out;
++ }
} else {
/* Otherwise go word by word for the cache; should be low
* cost as we expect to hit the cache.