From 0adc4aa5b1749f3af716591749472937ee2c9885 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Tue, 23 Nov 2021 17:58:05 +0100
Subject: [PATCH 355/463] usb: typec: tcpm: Improve logs

This adds clarity to debugging.

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 drivers/usb/typec/tcpm/tcpm.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 7ee27a6676546..081ab8d099634 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -958,10 +958,13 @@ static int tcpm_pd_transmit(struct tcpm_port *port,
 		break;
 	}
 
-	if (msg)
+	if (msg) {
 		tcpm_log(port, "PD TX, header: %#x", le16_to_cpu(msg->header));
-	else
+		for (ret = 0; ret < pd_header_cnt_le(msg->header); ret++)
+			tcpm_log(port, "  tx payload[%d]: %#x", ret, le32_to_cpu(msg->payload[ret]));
+	} else {
 		tcpm_log(port, "PD TX, type: %#x", tx_sop_type);
+	}
 
 	reinit_completion(&port->tx_complete);
 	ret = port->tcpc->pd_transmit(port->tcpc, tx_sop_type, msg, negotiated_rev);
@@ -3681,6 +3684,10 @@ void tcpm_pd_receive(struct tcpm_port *port, const struct pd_message *msg,
 		     enum tcpm_transmit_type rx_sop_type)
 {
 	struct pd_rx_event *event;
+	int ret;
+
+	for (ret = 0; ret < pd_header_cnt_le(msg->header); ret++)
+		tcpm_log(port, "  rx payload[%d]: %#x", ret, le32_to_cpu(msg->payload[ret]));
 
 	event = kzalloc(sizeof(*event), GFP_ATOMIC);
 	if (!event)
@@ -5962,7 +5969,7 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1,
 
 static void _tcpm_pd_vbus_on(struct tcpm_port *port)
 {
-	tcpm_log_force(port, "VBUS on");
+	tcpm_log_force(port, "VBUS event received: on");
 	port->vbus_present = true;
 	/*
 	 * When vbus_present is true i.e. Voltage at VBUS is greater than VSAFE5V implicitly
@@ -6052,7 +6059,7 @@ static void _tcpm_pd_vbus_on(struct tcpm_port *port)
 
 static void _tcpm_pd_vbus_off(struct tcpm_port *port)
 {
-	tcpm_log_force(port, "VBUS off");
+	tcpm_log_force(port, "VBUS event received: off");
 	port->vbus_present = false;
 	port->vbus_never_low = false;
 	switch (port->state) {
-- 
2.46.0

