drivers/mge-hid.c: refactor, treat ABM unknown as disabled #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I tried to illustrate here my code review/comments on the PR: networkupstools#2660
We've seen non-ABM capable devices with partial ABM paths, these were previously sent into ABM parsing functions. Treating
ABM_UNKNOWN
asABM_DISABLED
resolves this problem, ABM parsing functions should only be executed if ABM is explicitlyABM_ENABLED
. This also allows for graceful transition fromABM_UNKNOWN
/ABM_DISABLED
toABM_ENABLED
.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.Improved the two ABM decision paths (old + new) with clear structure, comments, improved function and variable names.
Improved the checking of ABM enabled-ness by checking for known values, rather than assigning any values directly.
Improved debug messages to be more clear and condensed, as they seemed to be partially overlapping in some areas.
Improved multiple implicitly casted variables to explicit casting in a single place where it felt correct to do so.