Skip to content

usb: typec: hd3ss3220: Fix VBUS regulator reference handling - #965

Closed
Chang Wu (kunjinkao-os) wants to merge 2 commits into
qualcomm-linux:mainfrom
kunjinkao-os:dev
Closed

usb: typec: hd3ss3220: Fix VBUS regulator reference handling#965
Chang Wu (kunjinkao-os) wants to merge 2 commits into
qualcomm-linux:mainfrom
kunjinkao-os:dev

Conversation

@kunjinkao-os

Copy link
Copy Markdown

The HD3SS3220 driver uses regulator_is_enabled() to determine whether
VBUS needs to be enabled or disabled. However, this reports the
aggregate regulator state and cannot determine whether this consumer holds an enable reference.

If another consumer enables VBUS first, the driver may skip its own
regulator_enable() call and later issue an unbalanced regulator_disable() call.

Track the VBUS enable state locally for this consumer and update the state only after successful regulator operations. This keeps the regulator enable/disable references balanced across role and ID notifications.

Also fix the VBUS regulator error message to report the operation that was actually attempted.

Fixes: b3f9d6e ("usb: typec: hd3ss3220: Check if regulator needs to be switched")

Testing:

  • Not tested on hardware.

The error message currently reports the inverse operation because the enable/disable names are selected backwards. Report the operation that was actually attempted.

Signed-off-by: Chang Wu <kunjinkao.jp@gmail.com>
regulator_is_enabled() may report enabled when another consumer holds the
enable reference, so it cannot be used to determine whether this consumer
called regulator_enable(). If another consumer enables VBUS first, hd3ss3220
can skip its own enable. A later disable then attempts to drop a reference it
never acquired, causing an unbalanced regulator disable.

Track successful enable and disable calls locally. Do not update the state when a regulator operation fails, so repeated role and ID notifications remain balanced.

Fixes: b3f9d6e ("usb: typec: hd3ss3220: Check if regulator needs to be switched")
Signed-off-by: Chang Wu <kunjinkao.jp@gmail.com>
@sgaud-quic

Copy link
Copy Markdown
Contributor

PR's should not be raised on main branch closing it

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.

2 participants