Skip to content

Commit d1f4390

Browse files
brglbroonie
authored andcommitted
regmap: provide regmap_assign_bits()
Add another bits helper to regmap API: this one sets given bits if value is true and clears them if it's false. Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Link: https://patch.msgid.link/20241108-assign-bits-v1-1-382790562d99@ideasonboard.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 953e549 commit d1f4390

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

include/linux/regmap.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,15 @@ static inline int regmap_clear_bits(struct regmap *map,
13351335
return regmap_update_bits_base(map, reg, bits, 0, NULL, false, false);
13361336
}
13371337

1338+
static inline int regmap_assign_bits(struct regmap *map, unsigned int reg,
1339+
unsigned int bits, bool value)
1340+
{
1341+
if (value)
1342+
return regmap_set_bits(map, reg, bits);
1343+
else
1344+
return regmap_clear_bits(map, reg, bits);
1345+
}
1346+
13381347
int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits);
13391348

13401349
/**
@@ -1803,6 +1812,13 @@ static inline int regmap_clear_bits(struct regmap *map,
18031812
return -EINVAL;
18041813
}
18051814

1815+
static inline int regmap_assign_bits(struct regmap *map, unsigned int reg,
1816+
unsigned int bits, bool value)
1817+
{
1818+
WARN_ONCE(1, "regmap API is disabled");
1819+
return -EINVAL;
1820+
}
1821+
18061822
static inline int regmap_test_bits(struct regmap *map,
18071823
unsigned int reg, unsigned int bits)
18081824
{

0 commit comments

Comments
 (0)