diff options
author | Tomasz Michalec <tm@semihalf.com> | 2022-07-01 16:40:11 +0200 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-13 11:10:58 +0000 |
commit | c0601ea736d191af111132bd9ad75e2ecad3067d (patch) | |
tree | dc5b45fe36e1ee1a8691d05542fb9017c72d975f /driver/retimer | |
parent | 99990795d8452d13fd678da7245e041f0b9e6ba7 (diff) | |
download | chrome-ec-c0601ea736d191af111132bd9ad75e2ecad3067d.tar.gz |
usb_mux: Split struct usb_mux in common files
Split struct usb_mux into struct usb_mux_chain and struct usb_mux. The
first structure is linked list to construct USB muxes chain and has
pointer to struct usb_mux. New struct usb_mux contains only information
about mux itself, not it position in the chain.
This is first CL and it changes common EC files.
LOW_COVERAGE_REASON=no emulator for some of the muxes set up yet
BUG=b:236274003
TEST=zmake build -a
TEST=./twister -T zephyr/test
TEST=make buildall
BRANCH=None
Cq-Depend: chromium:3779618, chromium:3779619, chromium:3779620
Cq-Depend: chromium:3779621, chromium:3779622, chromium:3779623
Cq-Depend: chromium:3779624, chromium:3779625, chromium:3779626
Cq-Depend: chromium:3779627, chromium:3779628, chromium:3779629
Cq-Depend: chromium:3779630, chromium:3779631, chromium:3779632
Cq-Depend: chromium:3779633, chromium:3779634, chromium:3779635
Cq-Depend: chromium:3779636, chromium:3780397, chromium:3780398
Cq-Depend: chromium:3780399, chromium:3780400, chromium:3780401
Cq-Depend: chromium:3780402, chromium:3780403, chromium:3780404
Cq-Depend: chromium:3780405, chromium:3780406, chromium:3780407
Cq-Depend: chromium:3780408, chromium:3780409, chromium:3780410
Cq-Depend: chromium:3780411, chromium:3780412, chromium:3780413
Signed-off-by: Tomasz Michalec <tm@semihalf.com>
Change-Id: Ida64c87b8194dbf4a1273d66aaa773a21b2cff87
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3748785
Commit-Queue: Tomasz Michalec <tmichalec@google.com>
Tested-by: Tomasz Michalec <tmichalec@google.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
Code-Coverage: Tomasz Michalec <tmichalec@google.com>
Diffstat (limited to 'driver/retimer')
-rw-r--r-- | driver/retimer/bb_retimer.c | 13 | ||||
-rw-r--r-- | driver/retimer/kb800x.c | 13 |
2 files changed, 16 insertions, 10 deletions
diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c index c3a55733c3..897541bfc2 100644 --- a/driver/retimer/bb_retimer.c +++ b/driver/retimer/bb_retimer.c @@ -638,6 +638,7 @@ static int console_command_bb_retimer(int argc, const char **argv) int port, reg, data, val = 0; int rv = EC_SUCCESS; const struct usb_mux *mux; + const struct usb_mux_chain *mux_chain; if (argc < 4) return EC_ERROR_PARAM_COUNT; @@ -647,14 +648,15 @@ static int console_command_bb_retimer(int argc, const char **argv) if (*e || !board_is_usb_pd_port_present(port)) return EC_ERROR_PARAM1; - mux = &usb_muxes[port]; - while (mux) { + mux_chain = &usb_muxes[port]; + while (mux_chain) { + mux = mux_chain->mux; if (mux->driver == &bb_usb_retimer) break; - mux = mux->next_mux; + mux_chain = mux_chain->next; } - if (!mux) + if (!mux_chain) return EC_ERROR_PARAM1; /* Validate r/w selection */ @@ -674,7 +676,8 @@ static int console_command_bb_retimer(int argc, const char **argv) return EC_ERROR_PARAM4; } - for (; mux != NULL; mux = mux->next_mux) { + for (; mux_chain != NULL; mux_chain = mux_chain->next) { + mux = mux_chain->mux; if (mux->driver == &bb_usb_retimer) { if (rw == 'r') rv = bb_retimer_read(mux, reg, &data); diff --git a/driver/retimer/kb800x.c b/driver/retimer/kb800x.c index 9470e49289..35ab5b183d 100644 --- a/driver/retimer/kb800x.c +++ b/driver/retimer/kb800x.c @@ -479,6 +479,7 @@ static int console_command_kb800x_xfer(int argc, const char **argv) char rw, *e; int rv, port, reg, val; uint8_t data; + const struct usb_mux_chain *mux_chain; const struct usb_mux *mux; if (argc < 4) @@ -489,16 +490,18 @@ static int console_command_kb800x_xfer(int argc, const char **argv) if (*e || !board_is_usb_pd_port_present(port)) return EC_ERROR_PARAM1; - mux = &usb_muxes[port]; - while (mux) { - if (mux->driver == &kb800x_usb_mux_driver) + mux_chain = &usb_muxes[port]; + while (mux_chain) { + if (mux_chain->mux->driver == &kb800x_usb_mux_driver) break; - mux = mux->next_mux; + mux_chain = mux_chain->next; } - if (!mux) + if (!mux_chain) return EC_ERROR_PARAM1; + mux = mux_chain->mux; + /* Validate r/w selection */ rw = argv[2][0]; if (rw != 'w' && rw != 'r') |