On Thu, Oct 12, 2017 at 12:40 PM, Lukas Wunner <[email protected]> wrote:
> A common idiom is to assign a value to a bit with:
>
> if (value)
> set_bit(nr, addr);
> else
> clear_bit(nr, addr);
>
> Likewise common is the one-line expression variant:
>
> value ? set_bit(nr, addr) : clear_bit(nr, addr);
>
> Commit 9a8ac3ae682e ("dm mpath: cleanup QUEUE_IF_NO_PATH bit
> manipulation by introducing assign_bit()") introduced assign_bit()
> to the md subsystem for brevity.
>
> Make it available to others, specifically gpiolib and the upcoming
> driver for Maxim MAX3191x industrial serializer chips.
>
> As requested by Peter Zijlstra, change the argument order to reflect
> traditional "dst = src" in C, hence "assign_bit(nr, addr, value)".
>
> Cc: Bart Van Assche <[email protected]>
> Cc: Alasdair Kergon <[email protected]>
> Cc: Mike Snitzer <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Neil Brown <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Theodore Ts'o <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> Cc: "H. Peter Anvin" <[email protected]>
> Cc: Denys Vlasenko <[email protected]>
> Signed-off-by: Lukas Wunner <[email protected]>
This v2 applied with Andrew's ACK.
Yours,
Linus Walleij