While my device does not seem to provide AtRateTimeToFull or AtRateTimeToEmpty, it does have RunTimeToEmpty. Then I found that SENSOR_TIMEDELTA values are in nanoseconds and that scaling for them was never implemented correctly.
I am confused by the spec [1], though; see 4.2.5 - Battery Measures. The reported values are supposedly in minutes but hid_info.unit is 0x1001 (seconds) and observation of RunTimeToEmpty appears to agree. I don’t see any other drivers in the tree that pay attention to unit or unit_exponent fields, and don’t want to go down a rabbit hole if there’s no interest. As usual, feedback is welcome. [1] http://www.usb.org/developers/hidpage/pdcv10.pdf --david Index: upd.c =================================================================== RCS file: /cvs/src/sys/dev/usb/upd.c,v retrieving revision 1.12 diff -u -p -r1.12 upd.c --- upd.c 11 Dec 2014 18:50:32 -0000 1.12 +++ upd.c 18 Dec 2014 05:02:30 -0000 @@ -66,7 +66,11 @@ static struct upd_usage_entry upd_usage_ { HUP_BATTERY, HUB_AC_PRESENT, SENSOR_INDICATOR, "ACPresent" }, { HUP_BATTERY, HUB_ATRATE_TIMETOFULL, - SENSOR_TIMEDELTA, "AtRateTimeToFull" } + SENSOR_TIMEDELTA, "AtRateTimeToFull" }, + { HUP_BATTERY, HUB_ATRATE_TIMETOEMPTY, + SENSOR_TIMEDELTA, "AtRateTimeToEmpty" }, + { HUP_BATTERY, HUB_RUNTIMETO_EMPTY, + SENSOR_TIMEDELTA, "RunTimeToEmpty" }, }; struct upd_report { @@ -322,9 +326,9 @@ upd_update_sensors(struct upd_softc *sc, int repid) { struct upd_sensor *sensor; - ulong hdata, batpres; - ulong adjust; - int i; + int64_t adjust; + ulong batpres; + int hdata, i; sensor = upd_lookup_sensor(sc, HUP_BATTERY, HUB_BATTERY_PRESENT); batpres = sensor ? sensor->ksensor.value : -1; @@ -353,6 +357,11 @@ upd_update_sensors(struct upd_softc *sc, case HUB_FULLCHARGE_CAPACITY: adjust = 1000; /* scale adjust */ break; + case HUB_ATRATE_TIMETOFULL: + case HUB_ATRATE_TIMETOEMPTY: + case HUB_RUNTIMETO_EMPTY: + adjust = 1000000000LL; /* XXX not minutes? */ + break; default: adjust = 1; /* no scale adjust */ break; @@ -363,7 +372,7 @@ upd_update_sensors(struct upd_softc *sc, sensor->ksensor.value = hdata * adjust; sensor->ksensor.status = SENSOR_S_OK; sensor->ksensor.flags &= ~SENSOR_FINVALID; - DPRINTF(("%s: hidget data: %lu\n", + DPRINTF(("%s: hidget data: %d\n", sc->sc_sensordev.xname, hdata)); } }