Clean up 'dc_tankvolume_t' type and make it 'dc_tankinfo_t'

The dc_tankvolume_t type had information about metric vs imperial
volume, but we actually want other things too, like the actual usage of
the cylinder.

So rename it to 'dc_tankinfo_t' and extend the semantics from an
enumeration of volume units, to be a bitmap of information flags.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2020-05-07 12:06:08 -07:00
parent 06ca08ed2b
commit 086b0a799e
2 changed files with 13 additions and 8 deletions

View File

@ -148,11 +148,16 @@ typedef struct dc_gasmix_t {
#define DC_GASMIX_UNKNOWN 0xFFFFFFFF
typedef enum dc_tankvolume_t {
DC_TANKVOLUME_NONE,
DC_TANKVOLUME_METRIC,
DC_TANKVOLUME_IMPERIAL,
} dc_tankvolume_t;
typedef unsigned int dc_tankinfo_t;
#define DC_TANKINFO_METRIC 1
#define DC_TANKINFO_IMPERIAL 2
#define DC_TANKINFO_CC_DILUENT 4
#define DC_TANKINFO_CC_O2 8
// For backwards compatibility
#define DC_TANKVOLUME_NONE 0
#define DC_TANKVOLUME_METRIC DC_TANKINFO_METRIC
#define DC_TANKVOLUME_IMPERIAL DC_TANKINFO_IMPERIAL
/*
* Tank volume
@ -179,7 +184,7 @@ typedef enum dc_tankvolume_t {
typedef struct dc_tank_t {
unsigned int gasmix; /* Gas mix index, or DC_GASMIX_UNKNOWN */
dc_tankvolume_t type; /* Tank type */
dc_tankinfo_t type; /* Tank type - metric/imperial and oc/cc */
double volume; /* Volume (liter) */
double workpressure; /* Work pressure (bar) */
double beginpressure; /* Begin pressure (bar) */

View File

@ -89,7 +89,7 @@ typedef struct suunto_eonsteel_parser_t {
double lowsetpoint;
double highsetpoint;
double customsetpoint;
dc_tankvolume_t tankinfo[MAXGASES];
dc_tankinfo_t tankinfo[MAXGASES];
double tanksize[MAXGASES];
double tankworkingpressure[MAXGASES];
} cache;
@ -1157,7 +1157,7 @@ static void set_depth_field(suunto_eonsteel_parser_t *eon, unsigned short d)
static int add_gas_type(suunto_eonsteel_parser_t *eon, const struct type_desc *desc, unsigned char type)
{
int idx = eon->cache.ngases;
dc_tankvolume_t tankinfo = DC_TANKVOLUME_METRIC;
dc_tankinfo_t tankinfo = DC_TANKINFO_METRIC;
char *name;
if (idx >= MAXGASES)