Skip to content

Commit 6bb1833

Browse files
cristiccbroonie
authored andcommitted
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: Cristian Ciocaltea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent d250166 commit 6bb1833

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/regulator/fan53555.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Copyright (c) 2012 Marvell Technology Ltd.
99
// Yunfan Zhang <[email protected]>
1010

11-
#include <linux/bits.h>
11+
#include <linux/bitops.h>
1212
#include <linux/err.h>
1313
#include <linux/i2c.h>
1414
#include <linux/module.h>
@@ -486,7 +486,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
486486
rdesc->min_uV = di->vsel_min;
487487
rdesc->uV_step = di->vsel_step;
488488
rdesc->vsel_reg = di->vol_reg;
489-
rdesc->vsel_mask = di->vsel_count - 1;
489+
rdesc->vsel_mask = BIT(fls(di->vsel_count - 1)) - 1;
490490
rdesc->ramp_reg = di->slew_reg;
491491
rdesc->ramp_mask = di->slew_mask;
492492
rdesc->ramp_delay_table = di->ramp_delay_table;

0 commit comments

Comments
 (0)