diff options
author | Vic Yang <victoryang@chromium.org> | 2014-08-06 16:38:46 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-08-11 09:05:15 +0000 |
commit | 0d4529c8481a8f4e00ea351a63b0d11d0bb9efe2 (patch) | |
tree | 129bcddb74f3ff1ee49301da21e7fbfd7a71a935 | |
parent | b61bfc8febcf9e897bb5a76f2fbe59b791f9d514 (diff) | |
download | chrome-ec-0d4529c8481a8f4e00ea351a63b0d11d0bb9efe2.tar.gz |
pd: log state transition and stop logging pings
When PD state changes, log the state transition. Also, now that we have
the state logged, logging pings doesn't help us anymore, so stop logging
them to make console clean.
BUG=None
TEST=Run on samus_pd. Plug/unplug zinger. Check state is logged and
pings are not.
BRANCH=None
Change-Id: Ib482b3351d9681fbb4bcc2585da58c732428b7af
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211262
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 40aa9430d0..80aeb7b860 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -214,8 +214,22 @@ static inline void set_state_timeout(int port, static inline void set_state(int port, enum pd_states next_state) { - pd[port].task_state = next_state; + enum pd_states last_state = pd[port].task_state; + set_state_timeout(port, 0, 0); + pd[port].task_state = next_state; + + /* Log state transition, except for toggling between sink and source */ + if (last_state == next_state) + return; +#ifdef CONFIG_USB_PD_DUAL_ROLE + if ((last_state == PD_STATE_SNK_DISCONNECTED && + next_state == PD_STATE_SRC_DISCONNECTED) || + (last_state == PD_STATE_SRC_DISCONNECTED && + next_state == PD_STATE_SNK_DISCONNECTED)) + return; +#endif + CPRINTF("C%d st%d\n", port, next_state); } /* increment message ID counter */ @@ -680,14 +694,16 @@ static void handle_request(int port, uint16_t head, int cnt = PD_HEADER_CNT(head); int p; - if (PD_HEADER_TYPE(head) != 1 || cnt) + if (PD_HEADER_TYPE(head) != PD_CTRL_GOOD_CRC || cnt) send_goodcrc(port, PD_HEADER_ID(head)); - /* dump received packet content */ - CPRINTF("RECV %04x/%d ", head, cnt); - for (p = 0; p < cnt; p++) - CPRINTF("[%d]%08x ", p, payload[p]); - CPRINTF("\n"); + /* dump received packet content (except for ping) */ + if (PD_HEADER_TYPE(head) != PD_CTRL_PING) { + CPRINTF("RECV %04x/%d ", head, cnt); + for (p = 0; p < cnt; p++) + CPRINTF("[%d]%08x ", p, payload[p]); + CPRINTF("\n"); + } /* * If we are in disconnected state, we shouldn't get a request. Do |