Subject: Re: PROPOSAL: API for environmental sensors
To: None <tech-kern@netbsd.org>
From: Greg A. Woods <woods@most.weird.com>
List: tech-kern
Date: 11/21/1999 13:06:32
[ On Tuesday, November 16, 1999 at 10:40:47 (+0100), eric.delcamp@legrand.fr wrote: ]
> Subject: Re: PROPOSAL: API for environmental sensors
>
> > ENVSYS_FCURVALID  0x00000002
> > ENVSYS_FMINVALID  0x00000004
> > ENVSYS_FMAXVALID  0x00000008
> > ENVSYS_FAVGVALID  0x00000016
>
> If theses values are hexadecimal flags, it should be something like : 0x02,
> 0x04, 0x08, 0x10.

I'm beginning to really detest the use of manually generated binary
flags for purposes like this.  They are inelegant and prone to error and
harder to use (well, harder only in the sense that one has to learn all
of the bit-masking, bit-setting, and bit-testing idioms as I'm sure we
have all done long ago).  I'm beginning to find that one-bit bit-fields
are much more elegant and make my code very easy to understand.

Bit-fields of course are not usually appropriate when trying to map
hardware register values into data structures, but that's not what this
API is doing anyway.

If I were to re-write my LM78 driver with a more generic API then I
would most certainly avoid bit-flags using #define.

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>