Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1226941rwd; Thu, 15 Jun 2023 07:55:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xhwHlaCDd24zWv2OL/2DjJ/oXdixBC8GMdTsSStWkQAk4yuOPiXdVarXtWWyQjpHF6A7x X-Received: by 2002:aa7:d756:0:b0:516:416b:f736 with SMTP id a22-20020aa7d756000000b00516416bf736mr12101500eds.35.1686840938471; Thu, 15 Jun 2023 07:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686840938; cv=none; d=google.com; s=arc-20160816; b=VWPRm4hjI4yjdreIokvBLPdu8P8m/OU9ZkvQ0ydAt6qdnC6UadqtKyFlULn+Rg0oc2 lwwMNhdo2kDalV4H53MrznZWbQj3dr85G2yZdV6N8104PKMq+BFaDp4AyAkrHsSDFYnF 1IV1dwHiY0TkmWIjit8NMM2sBo79S5G5/NDLdCx3KY2imwM/CFHxtMGUqhDHcu6UGH+B OF+A4grUA6H0abxgdqkqDC4Wv/NVdvoLEYx/MoHta/KqKzTlnhm8Vf7c/hp2gkOk9GDP YqzsuOyVcEBrlD1BbqEkyOeO1cBHVTtDhNA5lCL5zUACGofdDrv9K2lSsVwCjuSf6qkH 4yig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K7M214Cep3afix0SPy+XZqPQ8AP8Y1pTMtfrf7gHPKY=; b=icEB6tfGyPwlW+lfPfNo6/IBRvLYNEzthJWfIplPE2Q68WMZpbvSBrvRnzkyJAmvBR sJagp6QchbZ6CONFERSMjy6meh66C8jdsBE5PRGwHylfL3xZ15ivJaEChYg46jRClj6+ tDRn/DUpPMOtMazRJ743b56nxYdMvsz39xR2VoHC4MpOqYDxSwFZ8srX+03gwQJUJSEO Q577k3xog8S1ji6xMmbihiRF3g1noMH2R55o1kb259os6KWKLiu1u9LdaIBSNejKXtKi 1l4c74tbNEcRvb+T6sZY9J1hnTCTXFrpZZPdMPKpxE/dhGCNovslp7JyzxmV+3s5ELk2 tBLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wJUePUXS; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h24-20020aa7c618000000b0051a315d6e23si47125edq.603.2023.06.15.07.55.11; Thu, 15 Jun 2023 07:55:38 -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=@linuxfoundation.org header.s=korg header.b=wJUePUXS; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344451AbjFOOgZ (ORCPT + 99 others); Thu, 15 Jun 2023 10:36:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241156AbjFOOgY (ORCPT ); Thu, 15 Jun 2023 10:36:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC10A194; Thu, 15 Jun 2023 07:36:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 68E2961298; Thu, 15 Jun 2023 14:36:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B10CC433C8; Thu, 15 Jun 2023 14:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1686839781; bh=j7fswNF00+3EsBKE9l3ZGPQpN/5xxxUoZx34TL5CkLw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wJUePUXSGwFyZeIXTc/MCaXOpmi+1fQwp9quAdxPgCGFMgaGIGyuHot/RM4V9eUSg bRRuajr0ywJxzZyTWi2eh94EmsUitXvQ9RpBJaxUWdHeJWwkm0GryLE5dqXgxMFtnn kkFShesR42R6MG9PPdyUMHbNJJR5HLfYk9Kmbeeo= Date: Thu, 15 Jun 2023 16:36:19 +0200 From: Greg Kroah-Hartman To: Prashanth K Cc: Heikki Krogerus , AngeloGioacchino Del Regno , Matthias Brugger , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7] usb: common: usb-conn-gpio: Set last role to unknown before initial detection Message-ID: <2023061512-vowed-panther-38ed@gregkh> References: <1685544074-17337-1-git-send-email-quic_prashk@quicinc.com> <2023061547-staleness-camper-ae8a@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 15, 2023 at 07:52:32PM +0530, Prashanth K wrote: > > > On 15-06-23 03:00 pm, Greg Kroah-Hartman wrote: > > On Wed, Jun 14, 2023 at 12:14:08PM +0300, Heikki Krogerus wrote: > > > 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. > > > > > > > > While at it, also handle default case for the usb_role switch > > > > in cdns3, intel-xhci-usb-role-switch & musb/jz4740 to avoid > > > > build warnings. > > > > > > > > Fixes: 4602f3bff266 ("usb: common: add USB GPIO based connection detection driver") > > > > Signed-off-by: Prashanth K > > > > Reviewed-by: AngeloGioacchino Del Regno > > > > --- > > > > v7: Added default case in musb/jz4740.c & intel-xhci-usb-role-switch.c to > > > > avoid build warnings. > > > > v6: Moved USB_ROLE_UNKNOWN towards the end of enum usb_role. > > > > v5: Update commit text to mention the changes made in cdns3 driver. > > > > v4: Added Reviewed-by tag. > > > > v3: Added a default case in drivers/usb/cdns3/core.c as pointed out by > > > > the test robot. > > > > v2: Added USB_ROLE_UNKNWON to enum usb_role. > > > > > > > > drivers/usb/cdns3/core.c | 2 ++ > > > > drivers/usb/common/usb-conn-gpio.c | 3 +++ > > > > drivers/usb/musb/jz4740.c | 2 ++ > > > > drivers/usb/roles/intel-xhci-usb-role-switch.c | 2 ++ > > > > include/linux/usb/role.h | 1 + > > > > 5 files changed, 10 insertions(+) > > > > > > Just to be clear to everybody, that USB_ROLE_UNKNOWN is not handled in > > > drivers/usb/roles/class.c, so this patch is broken. > > > > > > But the whole approach is wrong. That USB_ROLE_UNKNOWN is clearly a > > > flag where the other values in enum usb_role are actual switch states. > > > So it does not belong there. > > > > > > In general, adding globals states like that just in order to work > > > around issues in single drivers is never a good idea IMO. > > > > Ok, let me go revert this from my tree, thanks for the review. > > > > greg k-h > > In that case, can I resubmit v1 of this patch again, where I have used a > macro in usb-conn-gpio driver ? something like this. > > @@ -27,6 +27,8 @@ > #define USB_CONN_IRQF \ > (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT) > > +#define USB_ROLE_UNKNOWN (USB_ROLE_NONE -1) Are you referencing an existing enum here and assuming it is a specific value? For obvious reasons, that can never work :) thanks, greg k-h