mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regmap: add WARN_ONCE when invalid mask is provided to regmap_field_init()
@ 2022-07-08  1:31 Matt Ranostay
  2022-07-08 20:47 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Ranostay @ 2022-07-08  1:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: Matt Ranostay, Mark Brown, Nishanth Menon

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>
---
 drivers/base/regmap/regmap.c | 3 +++
 1 file changed, 3 insertions(+)

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;
 }
-- 
2.36.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] regmap: add WARN_ONCE when invalid mask is provided to regmap_field_init()
  2022-07-08  1:31 [PATCH] regmap: add WARN_ONCE when invalid mask is provided to regmap_field_init() Matt Ranostay
@ 2022-07-08 20:47 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2022-07-08 20:47 UTC (permalink / raw)
  To: mranostay, linux-kernel; +Cc: nm

On Thu, 7 Jul 2022 18:31:25 -0700, Matt Ranostay wrote:
> 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap: add WARN_ONCE when invalid mask is provided to regmap_field_init()
      commit: cf39ed2e8ecddbee38e02691d6293b812e98e397

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-08 20:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08  1:31 [PATCH] regmap: add WARN_ONCE when invalid mask is provided to regmap_field_init() Matt Ranostay
2022-07-08 20:47 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®