linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap
@ 2021-05-19  7:50 Axel Lin
  2021-05-19 13:16 ` Mark Brown
  2021-05-19 16:10 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2021-05-19  7:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: Matti Vaittinen, Liam Girdwood, linux-kernel, Axel Lin

Return -EINVAL if ramp_delay_table is NULL.
Also add WARN_ON since the driver code needs fix if this happened.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/helpers.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c
index 0e16e31c968f..1e61fec4636e 100644
--- a/drivers/regulator/helpers.c
+++ b/drivers/regulator/helpers.c
@@ -948,8 +948,10 @@ int regulator_set_ramp_delay_regmap(struct regulator_dev *rdev, int ramp_delay)
 	int ret;
 	unsigned int sel;
 
-	if (!rdev->desc->n_ramp_values)
+	if (!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table) {
+		WARN_ON(!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table);
 		return -EINVAL;
+	}
 
 	ret = find_closest_bigger(ramp_delay, rdev->desc->ramp_delay_table,
 				  rdev->desc->n_ramp_values, &sel);
-- 
2.25.1


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

* Re: [PATCH] regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap
  2021-05-19  7:50 [PATCH] regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap Axel Lin
@ 2021-05-19 13:16 ` Mark Brown
  2021-05-19 16:10 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2021-05-19 13:16 UTC (permalink / raw)
  To: Axel Lin; +Cc: Matti Vaittinen, Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

On Wed, May 19, 2021 at 03:50:24PM +0800, Axel Lin wrote:

> +	if (!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table) {
> +		WARN_ON(!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table);

You can write "if (WARN_ON(..." there and it'll DTRT, though I'm never
sure it's great for readability.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap
  2021-05-19  7:50 [PATCH] regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap Axel Lin
  2021-05-19 13:16 ` Mark Brown
@ 2021-05-19 16:10 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2021-05-19 16:10 UTC (permalink / raw)
  To: Axel Lin; +Cc: Mark Brown, linux-kernel, Liam Girdwood, Matti Vaittinen

On Wed, 19 May 2021 15:50:24 +0800, Axel Lin wrote:
> Return -EINVAL if ramp_delay_table is NULL.
> Also add WARN_ON since the driver code needs fix if this happened.

Applied to

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

Thanks!

[1/1] regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap
      commit: 687c9e3b1a81d43b233482f781bd4e20561bc390

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] 3+ messages in thread

end of thread, other threads:[~2021-05-19 16:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19  7:50 [PATCH] regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap Axel Lin
2021-05-19 13:16 ` Mark Brown
2021-05-19 16:10 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).