Re: [PATCH] bitfield: add constant field preparation macros

From: Johannes Berg
Date: Mon Oct 15 2018 - 10:54:37 EST


On Mon, 2018-10-15 at 09:53 +0100, John Garry wrote:

> > +/**
> > + * __FIELD_PREP() - prepare a constant bitfield element
>
> My impression is that the name prefix - '__' - tells little about the
> function. If you agree, how about even CFIELD_PREP() or
> FIELD_PREP_CONST() or similar? I preper the latter, but becomes rather long.

I was following the __cpu_to_{be,le}{16,32,64} playbook, but don't
really care much. I'd prefer FIELD_PREP_CONST() over CFIELD_PREP()
though, so we can change this.

> > + * @_mask: shifted mask defining the field's length and position
> > + * @_val: value to put in the field
> > + *
> > + * __FIELD_PREP() masks and shifts up the value. The result should
> > + * be combined with other fields of the bitfield using local OR.
>
> should this be 'logical OR', or indeed 'bitwise OR'?

I'm not sure what happened there ... I copy/pasted the comment from
FIELD_PREP() but that says "logical OR" (which is in fact wrong, yes, it
should be say "bitwise OR").

johannes