Re: [PATCH v7] usb: common: usb-conn-gpio: Set last role to unknown before initial detection

From: Prashanth K
Date: Wed Jun 14 2023 - 00:25:32 EST




On 13-06-23 04:40 pm, Heikki Krogerus wrote:
Hi,

On Wed, May 31, 2023 at 08:11:14PM +0530, Prashanth K wrote:
Currently if we bootup a device without cable connected, then
usb-conn-gpio won't call set_role() since last_role is same as
current role. This happens because during probe last_role gets
initialised to zero.

To avoid this, added a new constant in enum usb_role, last_role
is set to USB_ROLE_UNKNOWN before performing initial detection.

So why can't you fix this by just always setting the role
unconditionally to USB_ROLE_NONE in your probe function before the
initial detection?

Hi Heikki, thats exactly what we are doing here.

+ /* Set last role to unknown before performing the initial detection */
+ info->last_role = USB_ROLE_UNKNOWN;
+
/* Perform initial detection */
usb_conn_queue_dwork(info, 0);

Thanks,
Prashanth K