Subject: Re: envsys version 2 API
To: Juan RP <juan@xtrarom.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 04/20/2007 17:34:56
On Fri, Apr 20, 2007 at 06:26:23PM +0200, Juan RP wrote:
> 
> Hi, I want to implement envsys version 2 and I need to make the API
> before starting to modify the existing code.
> 
> My current idea is to remove envsys_basic_info_t and just use
> a single struct to set/get values for a specific device sensor:
> 
> /* struct used by a sensor device */
> typedef struct envsys_device {
>         uint8_t         sensor;         /* Sensor number */
>         uint8_t         units;          /* Type of sensor */
>         uint32_t        warnflags;      /* Warning flags */
>         uint32_t        validflags;     /* Valid flags */
>         int32_t         value_cur;      /* Current value */
>         int32_t         value_min;      /* Minimum value */
>         int32_t         value_max;      /* Maximum value */
>         int32_t         value_avg;      /* Average value */
>         char            desc[33];       /* Description of this sensor */
>         uint8_t         rpms;           /* For fans, nominal RPMs */
>         uint8_t         rfact;          /* For volts, (int)(factor x 10^4) */
> 
> } envsys_dev_t;

Is it worth using uint8_t for any of the fields - given the implicit
padding in the above structure.
Similarly I'd use a multiple of 4 for desc[].

	David

-- 
David Laight: david@l8s.co.uk