battery: correct time_to_empty calculation

The kernel docs state that time_to_empty contains the estimation of
remaining time in seconds. Hence, calculate estimate minutes and hours
from that in a more correct way.

Signed-off-by: David Bimmler <git@d4ve.email>
This commit is contained in:
David Bimmler 2023-07-07 11:20:36 +02:00
parent d236b9c1b9
commit 08f5f444eb
2 changed files with 4 additions and 2 deletions

View file

@ -86,8 +86,9 @@ content(struct module *mod)
unsigned long minutes;
if (m->time_to_empty >= 0) {
hours = m->time_to_empty / 60;
minutes = m->time_to_empty % 60;
minutes = m->time_to_empty / 60;
hours = minutes / 60;
minutes = minutes % 60;
} else if (m->energy_full >= 0 && m->charge && m->power >= 0) {
unsigned long energy = m->state == STATE_CHARGING
? m->energy_full - m->energy : m->energy;