New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 846412 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Last visit > 30 days ago
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Task



Sign in to add a comment

Rename battery_check_present_status, battery_is_present, and battery_hw_present functions for clarity

Project Member Reported by jettrink@chromium.org, May 24 2018

Issue description

We have 3 functions that are subtly different: battery_check_present_status, battery_is_present, and battery_hw_present functions. We should refactor them to make it more clear what each one represents.
 
Cc: aaboagye@chromium.org scollyer@chromium.org
It would definitely be very helpful to make the intent and naming clear.
Cc: rspangler@chromium.org
Labels: -Type-Bug Type-Task
It seems like it would be beneficial to have a single enum that accounted for all connection states of a battery. It is confusing going to different functions for different pieces of state. Also having multiple functions forces callers to know which function to call in all situations (making it easy to miss a condition).

If we had a get_battery_connection_state() method that accounted for all connection states, I can see it having the following states:

PHYSICALLY_ABSENT
PHYSICALLY_PRESENT_ERROR (can't communicate with battery)
PHYSICALLY_PRESENT_UNIT (haven't tried communication yet)
PHYSICALLY_PRESENT_CUTOFF (disconnected - needs trickle current to wake up)
PHYSICALLY_PRESENT_CUTOFF_PENDING (disconnect is scheduled after next reboot)
PHYSICALLY_PRESENT_CONNECTED (providing power - still may need to check for minimum charge % for SoC)

(We will tweak names in final enum)

Cutoff is the same thing as disconnected, right?
Are there any other connection states we need to account for?

I was thinking about adding PHYSICALLY_PRESENT_CONNECTED_NOT_ENOUGH_POWER (used when CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON is defined), but I don't think it belongs in this concept. I think it makes more sense to check for PHYSICAL_PRESENT_CONNECTED then for percentage separately.

Comment 3 by ecgh@chromium.org, Jun 1 2018

I'd also like to nominate battery_is_cut_off() for renaming, since it tells you whether the battery is scheduled to be cut off at next shutdown, not whether the battery is currently cut off.

See: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1072637/5/common/battery_fuel_gauge.c#214
Status: Assigned (was: Untriaged)
This bug has an owner, thus, it's been triaged. Changing status to "assigned".

Sign in to add a comment