From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EFF4C77B7A for ; Thu, 25 May 2023 08:08:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238828AbjEYIIA (ORCPT ); Thu, 25 May 2023 04:08:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234519AbjEYIH6 (ORCPT ); Thu, 25 May 2023 04:07:58 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDBBA122; Thu, 25 May 2023 01:07:56 -0700 (PDT) Received: from [IPV6:2001:b07:2ed:14ed:a962:cd4d:a84:1eab] (unknown [IPv6:2001:b07:2ed:14ed:a962:cd4d:a84:1eab]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 2BD6E6605838; Thu, 25 May 2023 09:07:55 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1685002075; bh=GlR/t9XuJkIbmC5BWGwxNaicq3zxxpUewaYETNdEFYU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=fyJza44H+G6I0peneKyo3UlGsPzEV4ywcpL42Cfb0pdAPwYBUO6nQ6ZTI5Nvlx90d 0LE113MOA7/uP3cY6J3xljiGQS3xSfSBy7A/czX24NESLY4635fHby+fOem+J0Xyf3 DH0IWKv+0GRATbuzsgNlXo1xKheaLOQ246lrixQrFE3YZLe9l29ipvz17cVwcCOeng e7BbrwJBmDi7I6jd/HyyQE5WxuCA2HavpksP66w+1R/wkvGZoLc2EiWLgF4jIRsvPE KKD1mWnDHofTlO2Nw5ZBvbZT8XNtq1OnKZAhtIT/xTuy6XtnQMFs0KOtCBp2SQkVhD R9B1/j1Ec8lbA== Message-ID: <64825178-2310-8c8a-2ed9-4ae14a46915e@collabora.com> Date: Thu, 25 May 2023 10:07:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH v2] usb: common: usb-conn-gpio: Set last role to unknown before initial detection To: Prashanth K , Greg Kroah-Hartman , Matthias Brugger Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <1684936207-23529-1-git-send-email-quic_prashk@quicinc.com> Content-Language: en-US From: AngeloGioacchino Del Regno In-Reply-To: <1684936207-23529-1-git-send-email-quic_prashk@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 24/05/23 15:50, Prashanth K ha scritto: > 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 > initialized 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. > > Fixes: 4602f3bff266 ("usb: common: add USB GPIO based connection detection driver") > Signed-off-by: Prashanth K There's an issue with drivers/usb/cdns3/core.c as pointed out by the test robot; the solution is to handle `default` in the switch, I'd say that it would be safe to handle it as default: break; after solving that: Reviewed-by: AngeloGioacchino Del Regno > --- > v2: Added USB_ROLE_UNKNWON to enum usb_role > > drivers/usb/common/usb-conn-gpio.c | 3 +++ > include/linux/usb/role.h | 1 + > 2 files changed, 4 insertions(+) > > diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c > index e20874c..30bdb81 100644 > --- a/drivers/usb/common/usb-conn-gpio.c > +++ b/drivers/usb/common/usb-conn-gpio.c > @@ -257,6 +257,9 @@ static int usb_conn_probe(struct platform_device *pdev) > platform_set_drvdata(pdev, info); > device_set_wakeup_capable(&pdev->dev, true); > > + /* 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); > > diff --git a/include/linux/usb/role.h b/include/linux/usb/role.h > index b5deafd..221d462 100644 > --- a/include/linux/usb/role.h > +++ b/include/linux/usb/role.h > @@ -8,6 +8,7 @@ > struct usb_role_switch; > > enum usb_role { > + USB_ROLE_UNKNOWN = -1, > USB_ROLE_NONE, > USB_ROLE_HOST, > USB_ROLE_DEVICE,