On Tue, Jun 30, 2015 at 07:25:57PM +0800, Axel Lin wrote:
2015-06-30 18:46 GMT+08:00 Mark Brown broonie@kernel.org:
static const struct regmap_config ak4642_regmap = { .reg_bits = 8, .val_bits = 8,
.max_register = ARRAY_SIZE(ak4642_reg) + 1,
.max_register = FIL1_3, .reg_defaults = ak4642_reg,
.num_reg_defaults = ARRAY_SIZE(ak4642_reg),
.num_reg_defaults = FIL1_3 + 1,
This change is incorrect, the number of register defaults must match the size of the array of register defaults being passed in. Why are you changing this?
Because I reuse the same reg_default for ak4642 and ak4643. According to the datasheet: For ak4642, the valid registers are 0x0 ~ 0x1f (FIL1_3) For ak4643, the valid registers are 0x0 ~ 0x24 (SPK_MS) The default registers for 0x0 ~ 0x1f are the same for ak4642 and ak4643.
Ah, I see. That definitely deserves a comment since it's very unusual - possibly also with a BUILD_BUG_ON() for the define being less than ARRAY_SIZE().
Or do you prefer having separate reg_default for ak4642 and ak4643? (Then it can use ARRAY_SIZE() here.)
No, what you're doing is OK but really ought to have comments so it's clearer.