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>
This commit is contained in:
Bartosz Golaszewski 2024-11-08 16:07:37 +02:00 committed by Mark Brown
parent 953e549471
commit d1f4390dd2
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -1335,6 +1335,15 @@ static inline int regmap_clear_bits(struct regmap *map,
return regmap_update_bits_base(map, reg, bits, 0, NULL, false, false);
}
static inline int regmap_assign_bits(struct regmap *map, unsigned int reg,
unsigned int bits, bool value)
{
if (value)
return regmap_set_bits(map, reg, bits);
else
return regmap_clear_bits(map, reg, bits);
}
int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits);
/**
@ -1803,6 +1812,13 @@ static inline int regmap_clear_bits(struct regmap *map,
return -EINVAL;
}
static inline int regmap_assign_bits(struct regmap *map, unsigned int reg,
unsigned int bits, bool value)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}
static inline int regmap_test_bits(struct regmap *map,
unsigned int reg, unsigned int bits)
{