On Sat, May 17, 2014 at 06:32:10PM +0200, Fabian Raetz wrote: > Hi, > > i want to expose "capacity" (full capacity design) > as a sensor like the rest. > > This sensor will be used in an upcoming diff to upower to > expose "energy-full-design" and "capacity" properties if > this patch gets merged. > > Both patches together will fix wrong notifications about > broken batteries in KDE4. > > Cheers, > Fabian >
I don't have any problems with this diff. It might make sense to get this in snaps and have a few folks verify it shows proper information on various machines though. otherwise ok mlarkin@ > > Index: acpidev.h > =================================================================== > RCS file: /cvs/src/sys/dev/acpi/acpidev.h,v > retrieving revision 1.33 > diff -u -p -r1.33 acpidev.h > --- acpidev.h 13 Jul 2012 10:37:40 -0000 1.33 > +++ acpidev.h 17 May 2014 15:51:29 -0000 > @@ -278,7 +278,7 @@ struct acpibat_softc { > struct acpibat_bst sc_bst; > volatile int sc_bat_present; > > - struct ksensor sc_sens[8]; > + struct ksensor sc_sens[9]; > struct ksensordev sc_sensdev; > }; > > Index: acpibat.c > =================================================================== > RCS file: /cvs/src/sys/dev/acpi/acpibat.c,v > retrieving revision 1.59 > diff -u -p -r1.59 acpibat.c > --- acpibat.c 16 Oct 2011 11:59:21 -0000 1.59 > +++ acpibat.c 17 May 2014 15:51:29 -0000 > @@ -163,6 +163,12 @@ acpibat_monitor(struct acpibat_softc *sc > sensor_attach(&sc->sc_sensdev, &sc->sc_sens[7]); > sc->sc_sens[7].value = sc->sc_bst.bst_voltage * 1000; > > + strlcpy(sc->sc_sens[8].desc, "capacity", > + sizeof(sc->sc_sens[8].desc)); > + sc->sc_sens[8].type = type; > + sensor_attach(&sc->sc_sensdev, &sc->sc_sens[8]); > + sc->sc_sens[8].value = sc->sc_bif.bif_capacity * 1000; > + > sensordev_install(&sc->sc_sensdev); > } > > @@ -176,7 +182,7 @@ acpibat_refresh(void *arg) > sc->sc_devnode->name); > > if (!sc->sc_bat_present) { > - for (i = 0; i < 8; i++) { > + for (i = 0; i < 9; i++) { > sc->sc_sens[i].value = 0; > sc->sc_sens[i].status = SENSOR_S_UNSPEC; > sc->sc_sens[i].flags = SENSOR_FINVALID; > @@ -273,6 +279,16 @@ acpibat_refresh(void *arg) > sc->sc_sens[7].value = sc->sc_bst.bst_voltage * 1000; > sc->sc_sens[7].status = SENSOR_S_UNSPEC; > sc->sc_sens[7].flags = 0; > + } > + > + if (sc->sc_bif.bif_capacity == BIF_UNKNOWN) { > + sc->sc_sens[8].value = 0; > + sc->sc_sens[8].status = SENSOR_S_UNKNOWN; > + sc->sc_sens[8].flags = SENSOR_FUNKNOWN; > + } else { > + sc->sc_sens[8].value = sc->sc_bif.bif_capacity * 1000; > + sc->sc_sens[8].status = SENSOR_S_UNSPEC; > + sc->sc_sens[8].flags = 0; > } > acpi_record_event(sc->sc_acpi, APM_POWER_CHANGE); > } >