type-c-service/wrapper: Break-out existing wrapper code into per-port structs#818
Merged
RobertZ2011 merged 11 commits intoMay 6, 2026
Conversation
dde13a4 to
d41aaf7
Compare
e32cadc to
31afce1
Compare
8d95207 to
5b5dc20
Compare
Cargo Vet Audit Passed
|
915c055 to
8b523bc
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Type‑C controller “wrapper” (which previously managed multiple PD ports in one struct) into per‑port Port structs under a new type-c-service::controller module. It also removes the power‑policy proxy/messaging layer in favor of direct Psu trait calls, updates the Type‑C service event shapes accordingly, and adjusts examples/tests and supply‑chain metadata to match.
Changes:
- Replace
type-c-service/src/wrapper/*withtype-c-service/src/controller/*(per‑portPort, per‑port event receiver, shared state). - Remove power‑policy proxy command/response plumbing; rely on
Psutrait methods and device‑maintained PSU state. - Update Type‑C interface/service event payloads (status changed data + DP status value) and update examples, tests, lockfiles, and cargo‑vet config.
Reviewed changes
Copilot reviewed 35 out of 39 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| type-c-service/src/wrapper/vdm.rs | Removed; VDM handling moved into per‑port controller code. |
| type-c-service/src/wrapper/proxy.rs | Removed power proxy channel/device abstraction. |
| type-c-service/src/wrapper/power.rs | Removed wrapper power‑policy command handling. |
| type-c-service/src/wrapper/pd.rs | Removed wrapper PD helper logic (sink‑ready timeout moved). |
| type-c-service/src/wrapper/mod.rs | Removed the multi‑port ControllerWrapper implementation. |
| type-c-service/src/wrapper/message.rs | Removed wrapper event/output message types. |
| type-c-service/src/wrapper/event_receiver.rs | Removed wrapper event receivers (replaced by controller event receiver/splitter). |
| type-c-service/src/wrapper/dp.rs | Removed; DP status handling moved into controller PD module. |
| type-c-service/src/wrapper/backing.rs | Removed wrapper backing storage/registration/proxy state. |
| type-c-service/src/task.rs | Simplified Type‑C task signature; no longer registers wrappers/controllers. |
| type-c-service/src/service/mod.rs | Updated to consume new StatusChangedData payload shape. |
| type-c-service/src/lib.rs | Exposes new controller module; removes wrapper module export. |
| type-c-service/src/driver/tps6699x.rs | Retargets interrupt receiver trait impl to the new controller event receiver module. |
| type-c-service/src/controller/state.rs | New shared per‑port state (sink‑ready timeout) between port + receiver. |
| type-c-service/src/controller/power.rs | New per‑port power policy logic and Psu impl on Port. |
| type-c-service/src/controller/pd.rs | New per‑port PD helpers (VDM/DP status/alert) and event emission. |
| type-c-service/src/controller/mod.rs | New per‑port Port struct: state cache, sync, event processing, and event emission. |
| type-c-service/src/controller/event.rs | New per‑port event/loopback event types. |
| type-c-service/src/controller/event_receiver.rs | New per‑port event receiver + interrupt splitter and sink‑ready timeout selection. |
| type-c-service/src/controller/config.rs | New controller config (unconstrained sink behavior). |
| type-c-interface/src/service/event.rs | Changes service port event payloads (StatusChangedData, DpStatusUpdate(DpStatus)). |
| supply-chain/imports.lock | Updates imported audit metadata/audits set. |
| supply-chain/config.toml | Removes broad exemptions (tightens cargo‑vet policy configuration). |
| supply-chain/audits.toml | Adds audits for device-driver v1.0.9 (safe‑to‑deploy + safe‑to‑run). |
| power-policy-service/tests/common/mock.rs | Updates mock PSU to mutate internal state on simulated events and direct calls. |
| power-policy-service/src/service/provider.rs | Removes redundant PSU state mutation after connect_provider. |
| power-policy-service/src/service/mod.rs | Stops mutating PSU internal state on notifications (assumes device updates its own state). |
| power-policy-service/src/service/consumer.rs | Removes redundant PSU state mutation after connect/disconnect operations. |
| power-policy-interface/src/psu/mod.rs | Loosens State::disconnect to allow Idle; removes proxy command/response types. |
| power-policy-interface/src/psu/event.rs | Removes power policy response types from event module. |
| examples/std/src/lib/type_c/mock_controller.rs | Updates mock controller types/aliases to use new per‑port controller wiring. |
| examples/std/src/bin/type_c/unconstrained.rs | Reworks example wiring: per‑port tasks + interrupt splitter + loopback channels. |
| examples/std/src/bin/type_c/ucsi.rs | Reworks example wiring for new per‑port controller model. |
| examples/std/src/bin/type_c/service.rs | Reworks service example wiring; adjusts alert handling return type. |
| examples/std/src/bin/power_policy.rs | Updates example PSU to maintain its own State transitions. |
| examples/rt685s-evk/src/bin/type_c.rs | Reworks embedded example wiring: per‑port tasks + interrupt splitter + new registration. |
| examples/rt685s-evk/src/bin/type_c_cfu.rs | Reworks CFU example wiring similarly to per‑port controller model. |
| examples/rt685s-evk/Cargo.lock | Updates dependency lockfile (e.g., device-driver / git deps). |
| Cargo.lock | Updates workspace lockfile (e.g., device-driver / git deps). |
8b523bc to
2c28428
Compare
jerrysxie
reviewed
May 5, 2026
jerrysxie
previously approved these changes
May 5, 2026
This implementation currently takes responsibility for updating the state of each PSU. This is not as flexible when it comes to the PSU recovering if something goes wrong during a state transition. This also sets a standard that is less applicable to other uses, e.g. charger.
Remove power policy messaging in favor of direct async function calls.
Move existing proxy code into this directory.
Convert the current controller-level event receiver into a per-port event receiver.
Also remove finalize functions since they were mostly for message passing. Change `trace` -> `debug` in a couple of places.
Flatten `wrapper/proxy` into `controller` as the previous `wrapper` module no longer contains any code of its own and `controller` is a better name than `wrapper`.
The imprevious implementation wouldn't work correctly if `sync_state` were called from the port object if the event receiver's `wait_next` function had already been called. Introduce a loopback channel to support this functionality.
* Fix comment * Shorten lock liftime in VDM code
73079b0 to
de0b870
Compare
Contributor
Author
|
Rebased and resolved conflicts in cargo vet files. |
jerrysxie
approved these changes
May 6, 2026
tullom
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR moves the existing logic from the
wrappermodule, which manages multiple ports on a PD controller, into individual structs for each port. This is done in several steps:EventReceiverstruct is broken up into per-port event receiverswrapperis moved into the existing port proxy structs.Port.