Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1144395iob; Wed, 4 May 2022 15:52:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7hFnrLTZXEq/gEZ2au0CDih6O5LEriaNceIGX6rukzuPNrZ4J57qOiOLTcSf6+DrWuxEi X-Received: by 2002:aa7:d3ca:0:b0:427:b3b2:2d03 with SMTP id o10-20020aa7d3ca000000b00427b3b22d03mr21844666edr.357.1651704773602; Wed, 04 May 2022 15:52:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651704773; cv=none; d=google.com; s=arc-20160816; b=rPaWDqsxvkdjdNBRONQQG5iJ680U2RvibNKNhoKwVzBvFn6itaei6gTm0agLWgGFXI 0sZ6qFYeCQh8SwhVeVSPAxl6cCzgR5GAGMak6QcWOe1IYQ44AoFfphv+s1Rz26pNaoKc z5VZ8x5xoMsaRpv5gsdwYBVCK9LKQ5U/PBWlNAL5s3yFKrZJatAmcck57DPRJq9/vtYq nj/u4p+xIjjXaZchemQUwDs+RFzfoqcr5tyUZxEYOLIlr1v8s2XfPfBROeOfsXiktotU EP6kVAMIwRZgWMnFEAtl1tShL8Fg7BL4CxxcvgNMzOoxXqA0yqzOKeU9Xg2BhEgKqbp6 Hcww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8ZB1NGJL53TXH293bGjnyjl619lN8tizoeip9KZYosg=; b=thizs+hb3jUgEVPNGY5/95JQBa3hsH41gQbb6aLuQYehrXPSDWDtZKEqF9YEL+3CDh WRk6KkwVbAMpGroIXP0VKxhNqjLHAC1kYf2BAJ7P5haOpDR71Sz1GUXJoJLwSO62Klju GVTNpL3et4p3zEH9/IsR++J+ENqEEC0J+0iX1WmmKPDz3+/cWxhjyJx11fSizqfkSizX A3AUHh3uGxUPVEg/mZKbB8vqaVathDGdqbcq6v5jt/cImBsZKYW0tSnQhMA6GB9axlND 8t6/e781JijbhgJ5gdcGMtTlCGD34obc0GxSwaYXuDQrjjDoKLHeXSXPmOrLwmzbb8/P T8Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TizbRl46; 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 i1-20020a05640242c100b00418c2b5befcsi21108061edc.478.2022.05.04.15.52.31; Wed, 04 May 2022 15:52:53 -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=TizbRl46; 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 S1358050AbiEDRZ3 (ORCPT + 99 others); Wed, 4 May 2022 13:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354991AbiEDRDs (ORCPT ); Wed, 4 May 2022 13:03:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A7A04D273; Wed, 4 May 2022 09:52:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1B716617C3; Wed, 4 May 2022 16:52:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F072C385A5; Wed, 4 May 2022 16:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683157; bh=IzHnTEH3xlGhfuyQg4J8ArZeDQO0q0tTgX2u3BJ5BDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TizbRl46qVb/cv1lkbahlPUP3I2GatgVPN1EpkDi5sA8sUkchGkZJ7vdPLvr6/m9H Otx9JdIyPEqmZpcOrJUhPQ41N9od6bgpkiciagbktkGm4cq+H6/T22OyVSQV8SgMou coQA2/qlrhE9RbeaD9EdLBw2b9fOfqxdWTk/nr/c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Sven Peter Subject: [PATCH 5.15 022/177] usb: dwc3: Try usb-role-switch first in dwc3_drd_init Date: Wed, 4 May 2022 18:43:35 +0200 Message-Id: <20220504153055.222697534@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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 From: Sven Peter commit ab7aa2866d295438dc60522f85c5421c6b4f1507 upstream. If the PHY controller node has a "port" dwc3 tries to find an extcon device even when "usb-role-switch" is present. This happens because dwc3_get_extcon() sees that "port" node and then calls extcon_find_edev_by_node() which will always return EPROBE_DEFER in that case. On the other hand, even if an extcon was present and dwc3_get_extcon() was successful it would still be ignored in favor of "usb-role-switch". Let's just first check if "usb-role-switch" is configured in the device tree and directly use it instead and only try to look for an extcon device otherwise. Fixes: 8a0a13799744 ("usb: dwc3: Registering a role switch in the DRD code.") Cc: stable Signed-off-by: Sven Peter Link: https://lore.kernel.org/r/20220411155300.9766-1-sven@svenpeter.dev Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc3/drd.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -571,16 +571,15 @@ int dwc3_drd_init(struct dwc3 *dwc) { int ret, irq; + if (ROLE_SWITCH && + device_property_read_bool(dwc->dev, "usb-role-switch")) + return dwc3_setup_role_switch(dwc); + dwc->edev = dwc3_get_extcon(dwc); if (IS_ERR(dwc->edev)) return PTR_ERR(dwc->edev); - if (ROLE_SWITCH && - device_property_read_bool(dwc->dev, "usb-role-switch")) { - ret = dwc3_setup_role_switch(dwc); - if (ret < 0) - return ret; - } else if (dwc->edev) { + if (dwc->edev) { dwc->edev_nb.notifier_call = dwc3_drd_notifier; ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST, &dwc->edev_nb);