[1/2] regmap: ram: support noinc semantics
Commit Message
Support noinc semantics in RAM backed regmaps, for testing purposes. Add
a new callback that selects registers which should have noinc behavior.
Bulk writes to a noinc register will cause the last value in the buffer
to be assigned to the register, while bulk reads will copy the same
value repeatedly into the buffer.
This patch only adds support to regmap-raw-ram, since regmap-ram does
not support bulk operations.
Signed-off-by: Ben Wolsieffer <ben.wolsieffer@hefring.com>
---
drivers/base/regmap/internal.h | 1 +
drivers/base/regmap/regmap-raw-ram.c | 27 +++++++++++++++++++--------
2 files changed, 20 insertions(+), 8 deletions(-)
Comments
On Thu, 02 Nov 2023 16:30:38 -0400, Ben Wolsieffer wrote:
> Support noinc semantics in RAM backed regmaps, for testing purposes. Add
> a new callback that selects registers which should have noinc behavior.
> Bulk writes to a noinc register will cause the last value in the buffer
> to be assigned to the register, while bulk reads will copy the same
> value repeatedly into the buffer.
>
> This patch only adds support to regmap-raw-ram, since regmap-ram does
> not support bulk operations.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
Thanks!
[1/2] regmap: ram: support noinc semantics
commit: 02e3564a344064aca49f147e8a4eecbe5d3459fc
[2/2] regmap: kunit: add noinc write test
commit: d958d97848a6604d024221920d300d07869715a2
All 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
@@ -318,6 +318,7 @@ struct regmap_ram_data {
bool *read;
bool *written;
enum regmap_endian reg_endian;
+ bool (*noinc_reg)(struct regmap_ram_data *data, unsigned int reg);
};
/*
@@ -41,10 +41,15 @@ static int regmap_raw_ram_gather_write(void *context,
return -EINVAL;
r = decode_reg(data->reg_endian, reg);
- memcpy(&our_buf[r], val, val_len);
-
- for (i = 0; i < val_len / 2; i++)
- data->written[r + i] = true;
+ if (data->noinc_reg && data->noinc_reg(data, r)) {
+ memcpy(&our_buf[r], val + val_len - 2, 2);
+ data->written[r] = true;
+ } else {
+ memcpy(&our_buf[r], val, val_len);
+
+ for (i = 0; i < val_len / 2; i++)
+ data->written[r + i] = true;
+ }
return 0;
}
@@ -70,10 +75,16 @@ static int regmap_raw_ram_read(void *context,
return -EINVAL;
r = decode_reg(data->reg_endian, reg);
- memcpy(val, &our_buf[r], val_len);
-
- for (i = 0; i < val_len / 2; i++)
- data->read[r + i] = true;
+ if (data->noinc_reg && data->noinc_reg(data, r)) {
+ for (i = 0; i < val_len; i += 2)
+ memcpy(val + i, &our_buf[r], 2);
+ data->read[r] = true;
+ } else {
+ memcpy(val, &our_buf[r], val_len);
+
+ for (i = 0; i < val_len / 2; i++)
+ data->read[r + i] = true;
+ }
return 0;
}