Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp884885yba; Wed, 24 Apr 2019 11:10:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHgIJkKn1Vp3/x33pkceDAt654ACj/n+epivAuCgETv5StKQAV/IqkkClB51eNtdgVGOnj X-Received: by 2002:a63:4b21:: with SMTP id y33mr32905109pga.37.1556129437008; Wed, 24 Apr 2019 11:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556129437; cv=none; d=google.com; s=arc-20160816; b=zWyzBCXesf0r8JzB++0BguS0Is3wmzFLmq6Q2MM6XNPJBWli8PWlEYAPe3yXGY76mg 1pR6FFAvuEX3CAV8LAB7zKUj/PgAwp7AdOqou8I/5s/mQ4VFXA9qZeTs5XXH8+Cno0dI PaQO29q4e29AcYAHWIsILVb1ASq+NDoqZVEDzssHHm81yHPDlvnPUEjh2OGrUort+G6K E9lprRJBIm/WrUyd39dUFXGsyh9MpzpXR405M+PLzvPwc0X+aJs8cBuRsr/Z0unRm86e KfF5vkNSlaF/e4kPpTNOODA9IRR368J+CS97Q+0MX5cSyyVTRUqkl60+PI08Tz0rDR5T /ZkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Vm3G//rLecHmfI6+tY+m3VhSxeEG6KbKeJfshGYfFHM=; b=RKebHmOt8j2VvJ+VpnZYLn4yNJ/fGKhmihiuHIewtQC2qyRTWiicbSetoN5MGk+yD7 vjWuR3dm9hEbQnx0yy3vOlr9zwVw0XEbvCNFiK1ttX/MDDnVEmOdYWJCYNvk9tuKg4u6 ksuc+0TTefNd2YRKaY1mX/ZzYTzsWZf9MI2NyDSWQmKVPbC1r9++4jHZ04+LpwxvgfbJ ONAwTLHbOBpTM9LJTIu+3r8pDUnwhhEaht9B+ktobKU1ACRKvkJvivaAdve/nKhEN1VS sUQjFJw/x99cas2cJEeJeRxOXR91hQeoPxdF1JdSwJzgD0B1ALRFT4drevF/xKN2y52l PhvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oopIAx7t; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l77si20160037pfb.34.2019.04.24.11.10.22; Wed, 24 Apr 2019 11:10:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oopIAx7t; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388863AbfDXSHf (ORCPT + 99 others); Wed, 24 Apr 2019 14:07:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:41468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388486AbfDXRQq (ORCPT ); Wed, 24 Apr 2019 13:16:46 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2870821905; Wed, 24 Apr 2019 17:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126205; bh=AKuK2cYjYxTef23fmeAF2bYhIT51tvNCAqcl5PyOUgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oopIAx7tS/c+M+FLjDdcPrB+g3FTefINrTpfLQErhoHupG/CY+qkzKKi+y94zxnrr EhLWgehmJRhK5Jiy35BSDe9dXNOXgHBiY/K9kF5hEfimFxwU4uevZFBU0rMjktqr1J 3y+IH0ltW4bvzbf6FaDmU5vLCMq5Ov/wPs+Z1kuM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Kocialkowski , Peter Chen , Sasha Levin Subject: [PATCH 4.4 028/168] usb: chipidea: Grab the (legacy) USB PHY by phandle first Date: Wed, 24 Apr 2019 19:07:52 +0200 Message-Id: <20190424170925.355705904@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170923.452349382@linuxfoundation.org> References: <20190424170923.452349382@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 68ef236274793066b9ba3154b16c0acc1c891e5c ] According to the chipidea driver bindings, the USB PHY is specified via the "phys" phandle node. However, this only takes effect for USB PHYs that use the common PHY framework. For legacy USB PHYs, a simple lookup based on the USB PHY type is done instead. This does not play out well when more than one USB PHY is registered, since the first registered PHY matching the type will always be returned regardless of what the driver was bound to. Fix this by looking up the PHY based on the "phys" phandle node. Although generic PHYs are rather matched by their "phys-name" and not the "phys" phandle directly, there is no helper for similar lookup on legacy PHYs and it's probably not worth the effort to add it. When no legacy USB PHY is found by phandle, fallback to grabbing any registered USB2 PHY. This ensures backward compatibility if some users were actually relying on this mechanism. Signed-off-by: Paul Kocialkowski Signed-off-by: Peter Chen Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/chipidea/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 57ee43512992..dee22d8effda 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -913,8 +913,15 @@ static int ci_hdrc_probe(struct platform_device *pdev) } else if (ci->platdata->usb_phy) { ci->usb_phy = ci->platdata->usb_phy; } else { + ci->usb_phy = devm_usb_get_phy_by_phandle(dev->parent, "phys", + 0); ci->phy = devm_phy_get(dev->parent, "usb-phy"); - ci->usb_phy = devm_usb_get_phy(dev->parent, USB_PHY_TYPE_USB2); + + /* Fallback to grabbing any registered USB2 PHY */ + if (IS_ERR(ci->usb_phy) && + PTR_ERR(ci->usb_phy) != -EPROBE_DEFER) + ci->usb_phy = devm_usb_get_phy(dev->parent, + USB_PHY_TYPE_USB2); /* if both generic PHY and USB PHY layers aren't enabled */ if (PTR_ERR(ci->phy) == -ENOSYS && -- 2.19.1