Commit 6bb18339 authored by Cristian Ciocaltea's avatar Cristian Ciocaltea Committed by Mark Brown

regulator: fan53555: Improve vsel_mask computation

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: default avatarCristian Ciocaltea <cristian.ciocaltea@collabora.com>
Link: https://lore.kernel.org/r/20230406194158.963352-7-cristian.ciocaltea@collabora.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d2501661
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
// Copyright (c) 2012 Marvell Technology Ltd. // Copyright (c) 2012 Marvell Technology Ltd.
// Yunfan Zhang <yfzhang@marvell.com> // Yunfan Zhang <yfzhang@marvell.com>
#include <linux/bits.h> #include <linux/bitops.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -486,7 +486,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, ...@@ -486,7 +486,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
rdesc->min_uV = di->vsel_min; rdesc->min_uV = di->vsel_min;
rdesc->uV_step = di->vsel_step; rdesc->uV_step = di->vsel_step;
rdesc->vsel_reg = di->vol_reg; 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_reg = di->slew_reg;
rdesc->ramp_mask = di->slew_mask; rdesc->ramp_mask = di->slew_mask;
rdesc->ramp_delay_table = di->ramp_delay_table; rdesc->ramp_delay_table = di->ramp_delay_table;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment