Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp989679yba; Thu, 4 Apr 2019 01:53:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1Hru/yAbtk+pyojmvLUua4MiJoyFGmCgkksD2s2wD3n78wTYp3ivyvt1OP7DTT9tvNj45 X-Received: by 2002:a63:6786:: with SMTP id b128mr4672491pgc.318.1554367991212; Thu, 04 Apr 2019 01:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554367991; cv=none; d=google.com; s=arc-20160816; b=KVmYnzzAjTpHI+9ZL6qOAaL13u0WFKmTvwIQthNwliHUl2PnhXywKL5ZfW9WkNzd14 y0Qla5zR60TmGGXJ2sDcbbInhbCBHHtMDpIIHqqnZZgUsY96WpVmhKe2GOCyResC3tZy 7wsvyzPXCNZPfqwV9hj5/BWR1pFpBjHRjIg7WhQ3lA5acwNJDJjMz8gwyaaBoJdnBJ6m aluFgL4B6VJ93pYLmpqDpVhih8OhjqZV8UinMp0sGmNjhhDx65yhPTUbwyZUVFqV/FB3 isQMeO5a0dXjq217ReM59cKjNc1O/2ZvMvZkSPP+gfrj8KMFFDtZvpdXK8WwYWeYxdBG Wq8Q== 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=a6eXXyH/U3ZG3X/Ox/T33i27I3Zbkyy5R69seN1Z1RM=; b=IOrEuEQZL6G/3zB0QB9Lf90LAd2aDB7sQosX3PwpoAQ8Kcdc/W1ZBz4CDXcZ5qZbkx th18rvNDlmYy0DuzGOlUZm65wFS3MwVOmKcT6VGU/qKGRHQZ35EFL4XZJpuiC6KO0xgj UhLx5aDl7nWbzKLDX9/tXEU4Wu28jG6OYbs3qSL0cfOpHT0FXPSmyqyHQgLew8TaqPRH rdSOpgBVtKXS2Y8zWz1ejdXdD0DXd7+QgwLLRg3EbT4L7qrRjRxSO6saQN/6dok5Hc07 pRvu7PccrwtSKvy5Ue1U3+kcRR+WT8SgfE6Kvg4QeMuLuwan7PqjBSL39ozjJR2tu5x1 W0Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XoGTCrWN; 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 t3si9173839plq.181.2019.04.04.01.52.56; Thu, 04 Apr 2019 01:53:11 -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=XoGTCrWN; 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 S1728912AbfDDIv3 (ORCPT + 99 others); Thu, 4 Apr 2019 04:51:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:53212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729363AbfDDIvZ (ORCPT ); Thu, 4 Apr 2019 04:51:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 56A2D217D7; Thu, 4 Apr 2019 08:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554367884; bh=OYd5Iltv+ble0Zc4yPMCmipK+YNiJYdaRjtdsR8eS9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XoGTCrWNZVgJt9FzPprm1JZskP/MtFBcSMyz3UxhGVmL4rnSTq4ipdJCgir5qt1t7 VCazX7o7s9TEk/nb1yPRekqZplXpRDgC/nr8HAM2wGg5kpHURoLvsrh8aOFa7MIiiN z0aPhcFQAq/w4OUERILVH2KjGHsL3WlFMZwjMshQ= 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.9 33/91] usb: chipidea: Grab the (legacy) USB PHY by phandle first Date: Thu, 4 Apr 2019 10:47:17 +0200 Message-Id: <20190404084537.381417961@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084535.450029272@linuxfoundation.org> References: <20190404084535.450029272@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 64c6af2c8559..e96e3a5808b3 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -901,8 +901,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