Re: [PATCHv6 1/2] add basic register-field manipulation macros

From: Linus Torvalds
Date: Wed Aug 17 2016 - 13:16:14 EST


On Wed, Aug 17, 2016 at 10:11 AM, Jakub Kicinski
<jakub.kicinski@xxxxxxxxxxxxx> wrote:
> On Wed, 17 Aug 2016 09:33:26 -0700, Linus Torvalds wrote:
>>
>> I'm not a huge fan, since the interface fundamentally seems to be
>> oddly designed (why pass in the mask rather than "start bit +
>> length"?).
>
> Would that not require start and length to have separate defines?

Yeah.

> I assume doing:
>
> #define REG_BLA_FIELD_FOO 3, 4
> val = FIELD_GET(REG_BLA_FIELD_FOO, reg);
>
> is not acceptable. Attempts to define a single value brought us to the
> shifted mask.

Agreed. Maybe the mask with the complexity to then undo it (at compile
time) is the better approach.

Linus