git: 24c581ffa917 - stable/13 - powerpc pmu: Don't use garbage battery info.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 13 May 2022 22:54:52 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=24c581ffa9177cdc3770126d886a1def5d68fc06

commit 24c581ffa9177cdc3770126d886a1def5d68fc06
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-04-12 21:58:58 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-13 20:13:43 +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
    
    (cherry picked from commit 5f2995aa950f99ca124a450e4e57c9966fba802a)
---
 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);
 	}
 }