From: Ian Jackson Date: Tue, 15 Jul 2025 13:22:50 +0000 (+0100) Subject: xbatmon-simple: Parse (but do not process) TYPE=USB X-Git-Tag: archive/debian/8.0.1~4 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=238635e1f3daf06e74647d5f883bada8dac6fbe2;p=chiark-utils.git xbatmon-simple: Parse (but do not process) TYPE=USB We prefer the general ACAD entry, which subsumes the more specific USB entries. Signed-off-by: Ian Jackson --- diff --git a/cprogs/xbatmon-simple.c b/cprogs/xbatmon-simple.c index 8fe9b06..3ce1d57 100644 --- a/cprogs/xbatmon-simple.c +++ b/cprogs/xbatmon-simple.c @@ -123,7 +123,7 @@ typedef struct batinfo_field { #define UEVENT_ENUM_FIELDS(_) \ _(state, BATTERY, STATUS, "Discharging","Charging","Full","Unknown" ) \ - _(type, BOTH, TYPE, "Mains", "Battery" ) + _(type, BOTH, TYPE, "Mains", "Battery", "USB" ) #define CHGST_DISCHARGING 0 /* Reflects order in _(state,...) above */ #define CHGST_CHARGING 1 /* Also, much code assumes exactly */ @@ -132,8 +132,9 @@ typedef struct batinfo_field { #define CHGST_ERROR 8 /* Except that this one is an extra bit. */ #define TYPE_MAINS 0 /* Reflects order in _(type,...) above */ -#define TYPE_BATTERY 1 /* Also, much code assumes exactly these two */ -#define TYPE_BOTH 100 /* Except this is a magic invalid value. */ +#define TYPE_BATTERY 1 /* We want exactly one of MAINS & BATTERY */ +#define TYPE_USB 2 /* These get ignored. */ +#define TYPE_BOTH 100 /* This is a magic invalid value. */ #define SEPARATE_QUANTITY_FIELDS(_) \ /* See commit ec6f5f0be800bc5f2a27046833dba04e0c67ffac for @@ -396,6 +397,9 @@ ALL_ACCUMULATE_FIELDS(Q_ZERO) r= readbattery(); tidybattery(); + if (this_type >= TYPE_USB) + continue; + if (r) { bad: charging_mask |= (1u << CHGST_ERROR);