On Mon, Aug 21, 2017 at 3:12 PM, Lukas Wunner <lukas@xxxxxxxxx> 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, in particular gpiolib and the upcoming > driver for Maxim MAX3191x industrial serializer chips. > > Cc: Bart Van Assche <bart.vanassche@xxxxxxx> > Cc: Alasdair Kergon <agk@xxxxxxxxxx> > Cc: Mike Snitzer <snitzer@xxxxxxxxxx> > Signed-off-by: Lukas Wunner <lukas@xxxxxxxxx> Looks reasonable. > +static __always_inline void assign_bit(bool value, long nr, > + volatile unsigned long *addr) > +{ > + if (value) > + set_bit(nr, addr); > + else > + clear_bit(nr, addr); > +} > + > +static __always_inline void __assign_bit(bool value, long nr, > + volatile unsigned long *addr) > +{ > + if (value) > + __set_bit(nr, addr); > + else > + __clear_bit(nr, addr); > +} What I have never understood is the semantic difference between bitop_foo() and __bitop_foo(). And I even use them quite a lot. Can someone explain when I use the bitop_foo() and when I use the __bitop_foo(). I am asking so I can understand patch 2/4 in this series. I guess this is why I generally detest the __annotation, since it is so unspecific and unclear, but that is not something I expect you to solve in this patch. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html