summaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap
diff options
context:
space:
mode:
authorMatt Ranostay <mranostay@ti.com>2022-07-07 18:31:25 -0700
committerMark Brown <broonie@kernel.org>2022-07-08 11:51:56 +0100
commitcf39ed2e8ecddbee38e02691d6293b812e98e397 (patch)
tree42930713999679199507129726f57d84b6d84a9b /drivers/base/regmap
parent773d09b4c3acafd35f8b6e90848a39cedc03c52b (diff)
downloadlinux-cf39ed2e8ecddbee38e02691d6293b812e98e397.tar.bz2
regmap: add WARN_ONCE when invalid mask is provided to regmap_field_init()
In regmap_field_init() when a invalid mask is provided it still initializes with any warnings. An example of this is when the LSB is greater than MSB a mask of zero is produced. WARN_ONCE() is not ideal for this but requires less changes to core regmap code. Cc: Mark Brown <broonie@kernel.org> Cc: Nishanth Menon <nm@ti.com> Signed-off-by: Matt Ranostay <mranostay@ti.com> Link: https://lore.kernel.org/r/20220708013125.313892-1-mranostay@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/base/regmap')
-rw-r--r--drivers/base/regmap/regmap.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 4cf59e10d01b..0caa5690c560 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1298,6 +1298,9 @@ static void regmap_field_init(struct regmap_field *rm_field,
rm_field->reg = reg_field.reg;
rm_field->shift = reg_field.lsb;
rm_field->mask = GENMASK(reg_field.msb, reg_field.lsb);
+
+ WARN_ONCE(rm_field->mask == 0, "invalid empty mask defined\n");
+
rm_field->id_size = reg_field.id_size;
rm_field->id_offset = reg_field.id_offset;
}