regmap: Updates for v6.8
This was a very quiet release for regmap, we added kunit test coverage for a noinc fix that was merged during v6.7 and a couple of other trivial cleanups. -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmWbHBMACgkQJNaLcl1U h9BR8Af/RS9TYUkKvbBZGZSZIddhyENOOQ8EDGuxIPk+P2/gi1KaZeyTkxnUNUB/ noVNmHhcgfc0hATF/cBNuo7ASxjg58EadzR7FpJYyfCJ4rFFksEr3lKnuJqzU//8 nV91OBJf1iv2Y+UV1OdMTvcyo6Rew2K/5vcxMzRZ20RueIRaiMgBpZUEsgTgU6ol Zc2FJefdw9VrMfAYcdvrle14xzKfQdUJNkt76pcBG+P6Sus/5aUKrZskzOh6rOso MpQYvdtTfe6AxojWWZjOdzeeVJp1PMv+hLTNbIkMjJTr311FxTi9kqwbKdU2MVQL wxaqNyIl/ucYc6BYYTlmErlN0QWDHg== =QYK1 -----END PGP SIGNATURE----- Merge tag 'regmap-v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap Pull regmap updates from Mark Brown: "This was a very quiet release for regmap, we added kunit test coverage for a noinc fix that was merged during v6.7 and a couple of other trivial cleanups" * tag 'regmap-v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: regmap: fix kcalloc() arguments order regmap: fix regmap_noinc_write() description regmap: kunit: add noinc write test regmap: ram: support noinc semantics
This commit is contained in:
commit
83130ff423
@ -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);
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -1186,6 +1186,65 @@ static void raw_write(struct kunit *test)
|
||||
regmap_exit(map);
|
||||
}
|
||||
|
||||
static bool reg_zero(struct device *dev, unsigned int reg)
|
||||
{
|
||||
return reg == 0;
|
||||
}
|
||||
|
||||
static bool ram_reg_zero(struct regmap_ram_data *data, unsigned int reg)
|
||||
{
|
||||
return reg == 0;
|
||||
}
|
||||
|
||||
static void raw_noinc_write(struct kunit *test)
|
||||
{
|
||||
struct raw_test_types *t = (struct raw_test_types *)test->param_value;
|
||||
struct regmap *map;
|
||||
struct regmap_config config;
|
||||
struct regmap_ram_data *data;
|
||||
unsigned int val, val_test, val_last;
|
||||
u16 val_array[BLOCK_TEST_SIZE];
|
||||
|
||||
config = raw_regmap_config;
|
||||
config.volatile_reg = reg_zero;
|
||||
config.writeable_noinc_reg = reg_zero;
|
||||
config.readable_noinc_reg = reg_zero;
|
||||
|
||||
map = gen_raw_regmap(&config, t, &data);
|
||||
KUNIT_ASSERT_FALSE(test, IS_ERR(map));
|
||||
if (IS_ERR(map))
|
||||
return;
|
||||
|
||||
data->noinc_reg = ram_reg_zero;
|
||||
|
||||
get_random_bytes(&val_array, sizeof(val_array));
|
||||
|
||||
if (config.val_format_endian == REGMAP_ENDIAN_BIG) {
|
||||
val_test = be16_to_cpu(val_array[1]) + 100;
|
||||
val_last = be16_to_cpu(val_array[BLOCK_TEST_SIZE - 1]);
|
||||
} else {
|
||||
val_test = le16_to_cpu(val_array[1]) + 100;
|
||||
val_last = le16_to_cpu(val_array[BLOCK_TEST_SIZE - 1]);
|
||||
}
|
||||
|
||||
/* Put some data into the register following the noinc register */
|
||||
KUNIT_EXPECT_EQ(test, 0, regmap_write(map, 1, val_test));
|
||||
|
||||
/* Write some data to the noinc register */
|
||||
KUNIT_EXPECT_EQ(test, 0, regmap_noinc_write(map, 0, val_array,
|
||||
sizeof(val_array)));
|
||||
|
||||
/* We should read back the last value written */
|
||||
KUNIT_EXPECT_EQ(test, 0, regmap_read(map, 0, &val));
|
||||
KUNIT_ASSERT_EQ(test, val_last, val);
|
||||
|
||||
/* Make sure we didn't touch the register after the noinc register */
|
||||
KUNIT_EXPECT_EQ(test, 0, regmap_read(map, 1, &val));
|
||||
KUNIT_ASSERT_EQ(test, val_test, val);
|
||||
|
||||
regmap_exit(map);
|
||||
}
|
||||
|
||||
static void raw_sync(struct kunit *test)
|
||||
{
|
||||
struct raw_test_types *t = (struct raw_test_types *)test->param_value;
|
||||
@ -1284,6 +1343,7 @@ static struct kunit_case regmap_test_cases[] = {
|
||||
KUNIT_CASE_PARAM(raw_read_defaults, raw_test_types_gen_params),
|
||||
KUNIT_CASE_PARAM(raw_write_read_single, raw_test_types_gen_params),
|
||||
KUNIT_CASE_PARAM(raw_write, raw_test_types_gen_params),
|
||||
KUNIT_CASE_PARAM(raw_noinc_write, raw_test_types_gen_params),
|
||||
KUNIT_CASE_PARAM(raw_sync, raw_test_cache_types_gen_params),
|
||||
{}
|
||||
};
|
||||
|
@ -65,12 +65,12 @@ struct regmap *__regmap_init_ram(const struct regmap_config *config,
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
data->read = kcalloc(sizeof(bool), config->max_register + 1,
|
||||
data->read = kcalloc(config->max_register + 1, sizeof(bool),
|
||||
GFP_KERNEL);
|
||||
if (!data->read)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
data->written = kcalloc(sizeof(bool), config->max_register + 1,
|
||||
data->written = kcalloc(config->max_register + 1, sizeof(bool),
|
||||
GFP_KERNEL);
|
||||
if (!data->written)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
@ -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);
|
||||
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;
|
||||
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);
|
||||
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;
|
||||
for (i = 0; i < val_len / 2; i++)
|
||||
data->read[r + i] = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -111,12 +122,12 @@ struct regmap *__regmap_init_raw_ram(const struct regmap_config *config,
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
data->read = kcalloc(sizeof(bool), config->max_register + 1,
|
||||
data->read = kcalloc(config->max_register + 1, sizeof(bool),
|
||||
GFP_KERNEL);
|
||||
if (!data->read)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
data->written = kcalloc(sizeof(bool), config->max_register + 1,
|
||||
data->written = kcalloc(config->max_register + 1, sizeof(bool),
|
||||
GFP_KERNEL);
|
||||
if (!data->written)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
@ -2136,7 +2136,7 @@ static int regmap_noinc_readwrite(struct regmap *map, unsigned int reg,
|
||||
}
|
||||
|
||||
/**
|
||||
* regmap_noinc_write(): Write data from a register without incrementing the
|
||||
* regmap_noinc_write(): Write data to a register without incrementing the
|
||||
* register number
|
||||
*
|
||||
* @map: Register map to write to
|
||||
|
Loading…
Reference in New Issue
Block a user