git: 5f2995aa950f - main - powerpc pmu: Don't use garbage battery info.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Tue, 12 Apr 2022 21:59:23 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=5f2995aa950f99ca124a450e4e57c9966fba802a

commit 5f2995aa950f99ca124a450e4e57c9966fba802a
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-04-12 21:58:58 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-04-12 21:58:58 +0000

    powerpc pmu: Don't use garbage battery info.
    
    If pmu_query_battery fails, don't notify a change in battery status.
    
    Reviewed by:    jhibbits
    Differential Revision:  https://reviews.freebsd.org/D34889
---
 sys/powerpc/powermac/pmu.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/powerpc/powermac/pmu.c b/sys/powerpc/powermac/pmu.c
index 97865174cc2f..ae01b9251b11 100644
--- a/sys/powerpc/powermac/pmu.c
+++ b/sys/powerpc/powermac/pmu.c
@@ -964,7 +964,7 @@ pmu_battery_notify(struct pmu_battstate *batt, struct pmu_battstate *old)
 }
 
 static void
-pmu_battquery_proc()
+pmu_battquery_proc(void)
 {
 	struct pmu_softc *sc;
 	struct pmu_battstate batt;
@@ -977,8 +977,10 @@ pmu_battquery_proc()
 	while (1) {
 		kproc_suspend_check(curproc);
 		error = pmu_query_battery(sc, 0, &batt);
-		pmu_battery_notify(&batt, &cur_batt);
-		cur_batt = batt;
+		if (error == 0) {
+			pmu_battery_notify(&batt, &cur_batt);
+			cur_batt = batt;
+		}
 		pause("pmu_batt", hz);
 	}
 }