Skip to content

Commit

Permalink
regmap: provide regmap_assign_bits()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Bartosz Golaszewski <[email protected]>
Signed-off-by: Tomi Valkeinen <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
brgl authored and broonie committed Nov 8, 2024
1 parent 953e549 commit d1f4390
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions include/linux/regmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit d1f4390

Please sign in to comment.