[alsa-devel] [PATCH] ASoC: sirf-audio-codec: Simplify the new bitmask value in regmap_update_bits

Axel Lin axel.lin at ingics.com
Thu May 8 10:31:40 CEST 2014

On 四, 2014-05-08 at 16:29 +0800, Axel Lin wrote:
> Having the binary ones complement operator in the new bitmak value makes the
> code hard to read.
> Signed-off-by: Axel Lin <axel.lin at ingics.com>
> ---
> I think the binary ones complement operator in such use case is error prone:
> For example:
> To set BIT(1) and clear both BIT(2) and BIT(3):
> The following code has wrong result:
> regmap_update_bits(regmap, the_register, BIT(1), BIT(2), BIT(3),
>                    BIT(1) | ~BIT(2) | ~BIT(3));
Oops, I mean:
regmap_update_bits(regmap, the_register, BIT(1) | BIT(2)| BIT(3),
                   BIT(1) | ~BIT(2) | ~BIT(3));

More information about the Alsa-devel mailing list