diff mbox series

[BlueZ,1/1] profiles/battery: Fix batt random lose percentage

Message ID 20240723082843.184915-2-YanceyChiew@gmail.com (mailing list archive)
State New, archived
Headers show
Series Fix com.bluez.battery1 randomly missing percentage value | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch fail ERROR:TRAILING_WHITESPACE: trailing whitespace #118: FILE: profiles/battery/battery.c:97: +^I$ ERROR:TRAILING_WHITESPACE: trailing whitespace #123: FILE: profiles/battery/battery.c:102: +^I$ /github/workspace/src/src/13739703.patch total: 2 errors, 0 warnings, 19 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. NOTE: Whitespace errors detected. You may wish to use scripts/cleanpatch or scripts/cleanfile /github/workspace/src/src/13739703.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Yancey Chiew July 23, 2024, 8:28 a.m. UTC
Fix an error related to "Trying to update an unregistered battery",
which causes the battery1 dbus service to fail to provide the
initial value until the battery level changes.

battery.c:batt_io_value_cb() maybe run earlier than
battery.c:batt_io_ccc_written_cb(), which causes the percentage
to be updated in the batt structure when the dbus interface
has not been registered.

After the dbus interface is registered, the function to update
the battery percentage is skipped again because the battery level
has not changed yet.
---
 profiles/battery/battery.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

bluez.test.bot@gmail.com July 23, 2024, 10:09 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=873169

---Test result---

Test Summary:
CheckPatch                    FAIL      0.61 seconds
GitLint                       PASS      0.28 seconds
BuildEll                      PASS      25.05 seconds
BluezMake                     PASS      1740.67 seconds
MakeCheck                     PASS      13.20 seconds
MakeDistcheck                 PASS      183.61 seconds
CheckValgrind                 PASS      257.26 seconds
CheckSmatch                   PASS      359.91 seconds
bluezmakeextell               PASS      123.45 seconds
IncrementalBuild              PASS      1527.84 seconds
ScanBuild                     PASS      1070.18 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,1/1] profiles/battery: Fix batt random lose percentage
ERROR:TRAILING_WHITESPACE: trailing whitespace
#118: FILE: profiles/battery/battery.c:97:
+^I$

ERROR:TRAILING_WHITESPACE: trailing whitespace
#123: FILE: profiles/battery/battery.c:102:
+^I$

/github/workspace/src/src/13739703.patch total: 2 errors, 0 warnings, 19 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

/github/workspace/src/src/13739703.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.




---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/profiles/battery/battery.c b/profiles/battery/battery.c
index 02d024d92..b2699c0d7 100644
--- a/profiles/battery/battery.c
+++ b/profiles/battery/battery.c
@@ -94,13 +94,15 @@  static void parse_battery_level(struct batt *batt,
 	uint8_t percentage;
 
 	percentage = value[0];
+	
+	if (!batt->battery) {
+		warn("Trying to update an unregistered battery");
+		return;
+	}
+	
 	if (batt->percentage != percentage) {
 		batt->percentage = percentage;
 		DBG("Battery Level updated: %d%%", percentage);
-		if (!batt->battery) {
-			warn("Trying to update an unregistered battery");
-			return;
-		}
 		btd_battery_update(batt->battery, batt->percentage);
 	}
 }