Skip to content

Comments

Remove unnecessary parameters unconstrained_power from Func cmp_consumer_capability#636

Merged
asasine merged 2 commits intoOpenDevicePartnership:mainfrom
WangYuanyuan1996:personal/yuanwa/rust/remove_unconstrained_power
Dec 15, 2025
Merged

Remove unnecessary parameters unconstrained_power from Func cmp_consumer_capability#636
asasine merged 2 commits intoOpenDevicePartnership:mainfrom
WangYuanyuan1996:personal/yuanwa/rust/remove_unconstrained_power

Conversation

@WangYuanyuan1996
Copy link
Contributor

@WangYuanyuan1996 WangYuanyuan1996 commented Dec 15, 2025

In current ODP code cmp_consumer_capability(), when two power sources have the same power capability, it will compare their unconstrained_power next.
Currently, the unconstrained power of USBC power is always false, so if the unconstrained power of another lower-power source is always true, it will always select this lower-power source regardless of whether it's inserted first or last. It is enough to use power capability and current power flag to choose best consumer.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the unconstrained_power flag from the consumer capability comparison logic in the power policy service. According to the description, the unconstrained_power flag was causing the low power source to always be selected over USB-C, regardless of connection order, because this barrel jack charger source always reports unconstrained_power=1 while USB-C reports 0. The team determined that comparing power capability and current connection status is sufficient for selecting the best consumer.

Key Changes

  • Removed unconstrained_power() from the tuple comparison in cmp_consumer_capability(), simplifying the logic to compare only power capability and current connection status
  • The unconstrained_power flag is still tracked and used elsewhere in the codebase for state monitoring and notifications

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@WangYuanyuan1996 WangYuanyuan1996 changed the title Remove unnecessary parameters unconstrained_power from Func cmp_consumer_capability() Remove unnecessary parameters unconstrained_power from Func cmp_consumer_capability Dec 15, 2025
@asasine asasine merged commit 7f3db26 into OpenDevicePartnership:main Dec 15, 2025
14 checks passed
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.

3 participants