Message ID | 1684918441-14794-1-git-send-email-quic_prashk@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2704466vqo; Wed, 24 May 2023 02:13:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5grcZ0/9D/T1rAm/SrtGB+E2Nix3SEqg973z6vusAcAsek4UYk3LdOY7QVfMk+Rt7ptNE7 X-Received: by 2002:a05:6a00:1a8f:b0:62d:cfd4:e440 with SMTP id e15-20020a056a001a8f00b0062dcfd4e440mr2552219pfv.8.1684919629365; Wed, 24 May 2023 02:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684919629; cv=none; d=google.com; s=arc-20160816; b=zza1LqDYniNFdzKsfzsvYe0yNGSgu4+P048hGtLJvKBZujT6743Tfq3rSgCCPDfm+E bPWvHFRb3hyj/Hj0711a7X1dJyr7psSl533v2di1Oig34gsXt+IiZvwjnpPdif6Sju38 VIMqLCU0FP2NtXUcAuKlLWOmcU/zzBITCh/JxyJ+14MnEE4ezfJdjA0RwjG3O2jeH3vW nSyjuc2JkoHUXhdLgwg80NqVA5EStIx6VczVovsg03Tysod6pjem7zWrtvsE9Vii4TyB ZnkIjP0Sfya234kNZ8j951Dd6c31RHVAdzmtWtOwpeF6t1ythUlLMlVarUJhJOQqp5Ne fu5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=YnHB7FpBtR8Tse8rs4GaIWlXq+QS5MQbGYPk6a0WV9s=; b=wb7eEF6FDpyM7jbjQaVYYbTOgmumW+fUguZiNdePqLfeqevzXgE2F6ROkqelJSUwnH 2q+010e384d5yJ4EVMf9dbSnOT7D8GHiV5izGG/ow5n2MmAM8K01308cWInpfqNW8I3O CS3CPTwrO3urBzLf+AQBWuPoU6gEWiPpyVj/tuICNfJqGlWKCxR8iddEwqWI/UbFAy14 0BBj1LLnFem6THQRfs26aIq95i7Cz94fADEm2fgWMCs3pJPZk3Dvw31wK7Jd6zpR5v74 InuQsrELHnZ4LZ774uj0vtDX2erbDB+Q0LGdLpxS4VUpA+UycBKeDNjsqot9ziX0ippc jOcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=TdYIAymk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x28-20020aa7957c000000b0063b8ab7f91csi948991pfq.365.2023.05.24.02.13.36; Wed, 24 May 2023 02:13:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=TdYIAymk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240405AbjEXIyW (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Wed, 24 May 2023 04:54:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240169AbjEXIyU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 24 May 2023 04:54:20 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F8A0FC; Wed, 24 May 2023 01:54:18 -0700 (PDT) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34O7ZRhU003297; Wed, 24 May 2023 08:54:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=YnHB7FpBtR8Tse8rs4GaIWlXq+QS5MQbGYPk6a0WV9s=; b=TdYIAymkxInBAXWDz6DVR6tFm7ZvmRUKPPOtDGfFeVG5U32TYrK+DLL/Mfo804VbQknv NLkuNHfBjcHfAXux1krvjAyeMHVBkdkjWytJ3D2NUubbKAB1ANnMOcDoF9Km4CZ06+Hf bQ/85XR54g/a9+n2tcGVgvrVAEWIos9zbVcLwVuwZMdwVGPh4cZhzqNKUTlNXwVu7d0P Vjmgr/n8dBafvgpDwgX6vY0lE9+nSsMQhpQdssjwOLS8jStMhKXeeECUsmQgGN9qFCeG VGWznxRiArAYHMw10ByPV8PvN933+/Z/ONMcW1ZO0Wd86PVlH6tVJxESvvRYRWdT3QHY 5Q== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qs05sa128-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 May 2023 08:54:15 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 34O8sEYN032504 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 24 May 2023 08:54:14 GMT Received: from hu-prashk-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 24 May 2023 01:54:12 -0700 From: Prashanth K <quic_prashk@quicinc.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Matthias Brugger <matthias.bgg@gmail.com> CC: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Prashanth K <quic_prashk@quicinc.com> Subject: [PATCH] usb: common: usb-conn-gpio: Set last role to unknown before initial detection Date: Wed, 24 May 2023 14:24:01 +0530 Message-ID: <1684918441-14794-1-git-send-email-quic_prashk@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: ACchDRO1baxKxziO4wrZEyL8aP8O0g8W X-Proofpoint-ORIG-GUID: ACchDRO1baxKxziO4wrZEyL8aP8O0g8W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-24_05,2023-05-23_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 clxscore=1015 bulkscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305240075 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766766285470192139?= X-GMAIL-MSGID: =?utf-8?q?1766766285470192139?= |
Series |
usb: common: usb-conn-gpio: Set last role to unknown before initial detection
|
|
Commit Message
Prashanth K
May 24, 2023, 8:54 a.m. UTC
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, last_role is set to USB_ROLE_UNKNOWN before
performing the initial detection.
Fixes: 4602f3bff266 ("usb: common: add USB GPIO based connection detection driver")
Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
---
drivers/usb/common/usb-conn-gpio.c | 5 +++++
1 file changed, 5 insertions(+)
Comments
Il 24/05/23 10:54, 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 > initialised to zero. > > To avoid this, last_role is set to USB_ROLE_UNKNOWN before > performing the initial detection. > > Fixes: 4602f3bff266 ("usb: common: add USB GPIO based connection detection driver") > Signed-off-by: Prashanth K <quic_prashk@quicinc.com> > --- > drivers/usb/common/usb-conn-gpio.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c > index e20874c..00af735 100644 > --- a/drivers/usb/common/usb-conn-gpio.c > +++ b/drivers/usb/common/usb-conn-gpio.c > @@ -27,6 +27,8 @@ > #define USB_CONN_IRQF \ > (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT) > > +#define USB_ROLE_UNKNOWN -1 I would add USB_ROLE_UNKNOWN to `enum usb_role` instead. enum usb_role { USB_ROLE_UNKNOWN = -1, USB_ROLE_NONE, .... }; Regards, Angelo > + > struct usb_conn_info { > struct device *dev; > struct usb_role_switch *role_sw; > @@ -257,6 +259,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); >
On 24-05-23 03:10 pm, AngeloGioacchino Del Regno wrote: > Il 24/05/23 10:54, 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 >> initialised to zero. >> >> To avoid this, last_role is set to USB_ROLE_UNKNOWN before >> performing the initial detection. >> >> Fixes: 4602f3bff266 ("usb: common: add USB GPIO based connection >> detection driver") >> Signed-off-by: Prashanth K <quic_prashk@quicinc.com> >> --- >> drivers/usb/common/usb-conn-gpio.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/drivers/usb/common/usb-conn-gpio.c >> b/drivers/usb/common/usb-conn-gpio.c >> index e20874c..00af735 100644 >> --- a/drivers/usb/common/usb-conn-gpio.c >> +++ b/drivers/usb/common/usb-conn-gpio.c >> @@ -27,6 +27,8 @@ >> #define USB_CONN_IRQF \ >> (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT) >> +#define USB_ROLE_UNKNOWN -1 > > I would add USB_ROLE_UNKNOWN to `enum usb_role` instead. > > enum usb_role { > USB_ROLE_UNKNOWN = -1, > USB_ROLE_NONE, > .... > }; > > Regards, > Angelo Thanks for the suggestion Agnelo. Will change it in next patch. Regards, Prashanth K
diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c index e20874c..00af735 100644 --- a/drivers/usb/common/usb-conn-gpio.c +++ b/drivers/usb/common/usb-conn-gpio.c @@ -27,6 +27,8 @@ #define USB_CONN_IRQF \ (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT) +#define USB_ROLE_UNKNOWN -1 + struct usb_conn_info { struct device *dev; struct usb_role_switch *role_sw; @@ -257,6 +259,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);