Skip to content

Commit 8e21a62

Browse files
Prashanth Kgregkh
authored andcommitted
usb: common: usb-conn-gpio: Prevent bailing out if initial role is none
Currently if we bootup a device without cable connected, then usb-conn-gpio won't call set_role() because last_role is same as current role. This happens since last_role gets initialised to zero during the probe. To avoid this, add a new flag initial_detection into struct usb_conn_info, which prevents bailing out during initial detection. Cc: <stable@vger.kernel.org> # 5.4 Fixes: 4602f3b ("usb: common: add USB GPIO based connection detection driver") Signed-off-by: Prashanth K <quic_prashk@quicinc.com> Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/1690880632-12588-1-git-send-email-quic_prashk@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 65dadb2 commit 8e21a62

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/usb/common/usb-conn-gpio.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct usb_conn_info {
4242

4343
struct power_supply_desc desc;
4444
struct power_supply *charger;
45+
bool initial_detection;
4546
};
4647

4748
/*
@@ -86,11 +87,13 @@ static void usb_conn_detect_cable(struct work_struct *work)
8687
dev_dbg(info->dev, "role %s -> %s, gpios: id %d, vbus %d\n",
8788
usb_role_string(info->last_role), usb_role_string(role), id, vbus);
8889

89-
if (info->last_role == role) {
90+
if (!info->initial_detection && info->last_role == role) {
9091
dev_warn(info->dev, "repeated role: %s\n", usb_role_string(role));
9192
return;
9293
}
9394

95+
info->initial_detection = false;
96+
9497
if (info->last_role == USB_ROLE_HOST && info->vbus)
9598
regulator_disable(info->vbus);
9699

@@ -258,6 +261,7 @@ static int usb_conn_probe(struct platform_device *pdev)
258261
device_set_wakeup_capable(&pdev->dev, true);
259262

260263
/* Perform initial detection */
264+
info->initial_detection = true;
261265
usb_conn_queue_dwork(info, 0);
262266

263267
return 0;

0 commit comments

Comments
 (0)