[v2] regulator: lp873x: Use bitfield helpers

Message ID 15edeaa9a644c4025234088da3dabb023fce04ac.1708002503.git.geert+renesas@glider.be
State New
Headers
Series [v2] regulator: lp873x: Use bitfield helpers |

Commit Message

Geert Uytterhoeven Feb. 15, 2024, 1:09 p.m. UTC
  Use the FIELD_PREP() helper, instead open-coding the same operation.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Mark Brown <broonie@kernel.org>
---
Compile-tested only.

v2:
  - Add Acked-by.
---
 drivers/regulator/lp873x-regulator.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Mark Brown Feb. 15, 2024, 1:13 p.m. UTC | #1
On Thu, Feb 15, 2024 at 02:09:18PM +0100, Geert Uytterhoeven wrote:
> Use the FIELD_PREP() helper, instead open-coding the same operation.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Acked-by: Mark Brown <broonie@kernel.org>

Presumably there's some dependency or something which means I would have
acked this rather than applying it?
  
Geert Uytterhoeven Feb. 15, 2024, 1:32 p.m. UTC | #2
Hi Mark,

On Thu, Feb 15, 2024 at 2:13 PM Mark Brown <broonie@kernel.org> wrote:
> On Thu, Feb 15, 2024 at 02:09:18PM +0100, Geert Uytterhoeven wrote:
> > Use the FIELD_PREP() helper, instead open-coding the same operation.
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > Acked-by: Mark Brown <broonie@kernel.org>
>
> Presumably there's some dependency or something which means I would have
> acked this rather than applying it?

Not that I am aware of.

Looking at [1], presumably you were misguided by the bogus threading?
(due to an attempt of mine to send several patches with a single
 git-send-email command? I don't remember)

[1] https://lore.kernel.org/all/YZvGFHLWf3GM1jVl@sirena.org.uk

Gr{oetje,eeting}s,

                        Geert
  
Mark Brown Feb. 15, 2024, 3:30 p.m. UTC | #3
On Thu, 15 Feb 2024 14:09:18 +0100, Geert Uytterhoeven wrote:
> Use the FIELD_PREP() helper, instead open-coding the same operation.
> 
> 

Applied to

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

Thanks!

[1/1] regulator: lp873x: Use bitfield helpers
      commit: 2601b6fb7d715fe5a808d12232ed9ae05fb86eef

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
  

Patch

diff --git a/drivers/regulator/lp873x-regulator.c b/drivers/regulator/lp873x-regulator.c
index 8dfdd1db20709e18..84a134cfcd9c98d7 100644
--- a/drivers/regulator/lp873x-regulator.c
+++ b/drivers/regulator/lp873x-regulator.c
@@ -5,6 +5,7 @@ 
  * Copyright (C) 2016 Texas Instruments Incorporated - https://www.ti.com/
  */
 
+#include <linux/bitfield.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
@@ -93,7 +94,7 @@  static int lp873x_buck_set_ramp_delay(struct regulator_dev *rdev,
 
 	ret = regmap_update_bits(lp873->regmap, regulators[id].ctrl2_reg,
 				 LP873X_BUCK0_CTRL_2_BUCK0_SLEW_RATE,
-				 reg << __ffs(LP873X_BUCK0_CTRL_2_BUCK0_SLEW_RATE));
+				 FIELD_PREP(LP873X_BUCK0_CTRL_2_BUCK0_SLEW_RATE, reg));
 	if (ret) {
 		dev_err(lp873->dev, "SLEW RATE write failed: %d\n", ret);
 		return ret;