Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/mge-hid.c: refactor, treat ABM unknown as disabled #4

Open
wants to merge 6 commits into
base: work/246-add-battery.charger.status+mode
Choose a base branch
from

Conversation

desertwitch
Copy link

@desertwitch desertwitch commented Oct 27, 2024

I tried to illustrate here my code review/comments on the PR: networkupstools#2660

  1. We've seen non-ABM capable devices with partial ABM paths, these were previously sent into ABM parsing functions. Treating ABM_UNKNOWN as ABM_DISABLED resolves this problem, ABM parsing functions should only be executed if ABM is explicitly ABM_ENABLED. This also allows for graceful transition from ABM_UNKNOWN/ABM_DISABLED to ABM_ENABLED.

  2. Removed ABM_ENABLED_TYPE as an additional way of enabling ABM, this is just a textual value for the battery charger type and ABM disabled/enabled is already handled through the correct HID path (x.ABMEnable) in another function. An ABM battery charger type can still be ABM disabled, so it makes no sense to assume enable ABM based on the charger type.

  3. Improved the two ABM decision paths (old + new) with clear structure, comments, improved function and variable names.

  4. Improved the checking of ABM enabled-ness by checking for known values, rather than assigning any values directly.

  5. Improved debug messages to be more clear and condensed, as they seemed to be partially overlapping in some areas.

  6. Improved multiple implicitly casted variables to explicit casting in a single place where it felt correct to do so.

@desertwitch desertwitch force-pushed the work/246-add-battery.charger.status+mode branch from 8db8a2d to 14e0cf2 Compare October 28, 2024 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant