From a8d9ca7ede5f98a03b170933d2cef7eea15ad638 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Tue, 23 Nov 2021 17:57:06 +0100
Subject: [PATCH 334/480] usb: typec: fusb302: Update VBUS state even if VBUS
 interrupt is not triggered

This seems to improve robustness.

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

diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
index c30f93ec78fa..16c3f8d94a9d 100644
--- a/drivers/usb/typec/tcpm/fusb302.c
+++ b/drivers/usb/typec/tcpm/fusb302.c
@@ -1716,14 +1716,16 @@ static void fusb302_irq_work(struct work_struct *work)
 
 	fusb302_print_state(chip);
 
-	if (interrupt & FUSB_REG_INTERRUPT_VBUSOK) {
-		vbus_present = !!(status0 & FUSB_REG_STATUS0_VBUSOK);
+	vbus_present = !!(status0 & FUSB_REG_STATUS0_VBUSOK);
+	if (interrupt & FUSB_REG_INTERRUPT_VBUSOK)
 		fusb302_log(chip, "IRQ: VBUS_OK, vbus=%s",
 			    str_on_off(vbus_present));
-		if (vbus_present != chip->vbus_present) {
-			chip->vbus_present = vbus_present;
-			tcpm_vbus_change(chip->tcpm_port);
-		}
+	if (vbus_present != chip->vbus_present) {
+		chip->vbus_present = vbus_present;
+		if (!(interrupt & FUSB_REG_INTERRUPT_VBUSOK))
+		fusb302_log(chip, "IRQ: VBUS changed without interrupt, vbus=%s",
+			    str_on_off(vbus_present));
+		tcpm_vbus_change(chip->tcpm_port);
 	}
 
 	if (interrupta & FUSB_REG_INTERRUPTA_TOGDONE) {
-- 
2.49.0

