regmap: provide regmap_assign_bits()
PATCH 1/1 regmap: provide regmap_assign_bits()
From: Bartosz Golaszewski <[email protected]>
Add another bits helper to regmap API: this one sets given bits if value is true and clears them if it's false.
---
Hi Mark,
I'm sending this patch without any user yet but we have a use-case over in the GPIO subsystem where this will come in handy soon.
Bartosz
include/linux/regmap.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
include/linux/regmap.h +16 -0
@@ -1148,6 +1148,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);/**
@@ -1554,6 +1563,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) {
Signature · 1 line
2.29.1
Mark Brown
maintainerQuoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Add another bits helper to regmap API: this one sets given bits if value is true and clears them if it's false.
What's the use case?
Review
Quoted 2 lines
(quoted diff) +2
-0+static inline int regmap_assign_bits(struct regmap *map, unsigned int reg, + unsigned int bits, bool value)
I don't have a great suggestion but this naming feels prone to confusion with _update_bits().
Quoted 9 lines · Mark Brown
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Add another bits helper to regmap API: this one sets given bits if value is true and clears them if it's false.
What's the use case?
Basically what the function does: set bits if a condition is true, clear them if false. I think this is a common enough use-case to warrant a helper.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static inline int regmap_assign_bits(struct regmap *map, unsigned int reg, + unsigned int bits, bool value)I don't have a great suggestion but this naming feels prone to confusion with
_update_bits().
This is already used in bitops - we have set_bit(), clear_bit() and assign_bit(). People are used to it and I thought I'd stay consistent with this naming.
Bartosz
Mark Brown
maintainerQuoted 11 lines · Bartosz Golaszewski
Quoted 6 lines · Mark Brown
Quoted 2 lines · Bartosz Golaszewski
Add another bits helper to regmap API: this one sets given bits if value is true and clears them if it's false.
What's the use case?
Basically what the function does: set bits if a condition is true, clear them if false. I think this is a common enough use-case to warrant a helper.
I can tell what the function does, I can't tell why you'd want it and simply stating that it's common isn't helping me here :(
Quoted 8 lines · Mark Brown
Quoted 5 lines · Bartosz Golaszewski
Quoted 4 lines · Mark Brown
Quoted 2 lines · Bartosz Golaszewski
Add another bits helper to regmap API: this one sets given bits if value is true and clears them if it's false.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
What's the use case?
Basically what the function does: set bits if a condition is true, clear them if false. I think this is a common enough use-case to warrant a helper.
I can tell what the function does, I can't tell why you'd want it and simply stating that it's common isn't helping me here :(
Got it, I'll resend this together with the patches that need it then.
Bartosz