mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Heiko Stuebner <heiko@sntech.de>,
	Bjorn Andersson <andersson@kernel.org>,
	Joseph Chen <chenjh@rock-chips.com>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	kernel@collabora.com
Subject: [PATCH v2 6/8] regulator: fan53555: Improve vsel_mask computation
Date: Thu,  6 Apr 2023 20:18:04 +0300	[thread overview]
Message-ID: <20230406171806.948290-7-cristian.ciocaltea@collabora.com> (raw)
In-Reply-To: <20230406171806.948290-1-cristian.ciocaltea@collabora.com>

In preparation for introducing support for additional regulators which
do not use the maximum number of voltage selectors available for a given
mask, improve the mask computation formula by using fls().

Note fls() requires the bitops header, hence include it explicitly and
drop bits.h which is already pulled by bitops.h.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/regulator/fan53555.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 181e5eb00e7a..39c9c29f4ff6 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -8,7 +8,7 @@
 // Copyright (c) 2012 Marvell Technology Ltd.
 // Yunfan Zhang <yfzhang@marvell.com>
 
-#include <linux/bits.h>
+#include <linux/bitops.h>
 #include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
@@ -486,7 +486,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
 	rdesc->min_uV = di->vsel_min;
 	rdesc->uV_step = di->vsel_step;
 	rdesc->vsel_reg = di->vol_reg;
-	rdesc->vsel_mask = di->vsel_count - 1;
+	rdesc->vsel_mask = BIT(fls(di->vsel_count - 1)) - 1;
 	rdesc->ramp_reg = di->slew_reg;
 	rdesc->ramp_mask = di->slew_mask;
 	rdesc->ramp_delay_table = di->ramp_delay_table;
-- 
2.40.0


  parent reply	other threads:[~2023-04-06 17:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-06 17:17 [PATCH v2 0/8] Add support for Rockchip RK860X regulators Cristian Ciocaltea
2023-04-06 17:17 ` [PATCH v2 1/8] regulator: dt-bindings: fcs,fan53555: Add support for RK860X Cristian Ciocaltea
2023-04-06 18:14   ` Krzysztof Kozlowski
2023-04-06 19:17     ` Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 2/8] regulator: fan53555: Explicitly include bits header Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 3/8] regulator: fan53555: Fix wrong TCS_SLEW_MASK Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 4/8] regulator: fan53555: Remove unused *_SLEW_SHIFT definitions Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 5/8] regulator: fan53555: Make use of the bit macros Cristian Ciocaltea
2023-04-06 17:18 ` Cristian Ciocaltea [this message]
2023-04-06 17:18 ` [PATCH v2 7/8] regulator: fan53555: Use dev_err_probe Cristian Ciocaltea
2023-04-06 17:18 ` [PATCH v2 8/8] regulator: fan53555: Add support for RK860X Cristian Ciocaltea
2023-04-06 18:15   ` Krzysztof Kozlowski
2023-04-06 21:31 ` (subset) [PATCH v2 0/8] Add support for Rockchip RK860X regulators Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230406171806.948290-7-cristian.ciocaltea@collabora.com \
    --to=cristian.ciocaltea@collabora.com \
    --cc=andersson@kernel.org \
    --cc=broonie@kernel.org \
    --cc=chenjh@rock-chips.com \
    --cc=devicetree@vger.kernel.org \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=heiko@sntech.de \
    --cc=kernel@collabora.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®