Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp992710yba; Thu, 4 Apr 2019 01:57:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaA3liUnAxx8qFuE3+LNf2B4a/extZidRghbsgfhJIJoKO6yCeXANF34S67RNNhqE+hbm3 X-Received: by 2002:a62:1c13:: with SMTP id c19mr4578583pfc.11.1554368276741; Thu, 04 Apr 2019 01:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368276; cv=none; d=google.com; s=arc-20160816; b=YucyQKzXkJwsG3fgKodV91l5f3+xNeKhApJz5jBHbjY45cMIAGfE+8h8cqxWIVeMgW uRQf8YFjqbjez1oLhXi7gMVYpGgt1rJvNjkUkamkNIp5qUfJeaEITRyD7PQ7xcnHneeU gmB6Bti2gdWR9F+8TGPkHM/e0E269q1C0JWsFFJP+1LryFcNdxQpxQ/QET0kczaVmpwz 2LQH7D3sy2MZYPTuLwmTIejC2p2ocTaoCa5Bdj5ny9lqQTDLbS8H8KrtI6vD9wikXt1n CotgL7DhP96L/9rK5p2YoQS21H3cFrN/DvGaWNjULWE0PX/f//fKz4ljoiHwRlDj/AVv qZxw== 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=XJlSMPxBIX3QE6tz3q7vZdRXzROjQXN8Ool+gPUk7Jg=; b=0BboBLO/Kr5Pz+dRujCAdIPXnJ8u3hR2z3teOOD7TUm5ESPJXolhXo+uaRKIZ/VQYG NxGtUAk9CsyQo/6O9Tko8wOCfgcHBcdhHyD5XhaTpnFy/FF0k7kjqutHl3Sf+bEWdL9K Ut6SAduGdgEw8N1N8fitpKeiQhAUAK51ucQvw8SnhhnIZws7QJYv+dch71XcquY7z65U B9V5lGmRI89ZXvxphNkRIIaWZX383JbYC5FJJU14vrj2IoZRgezXCdrIkH86NE79dTPS 3UuLXEiAK5TU13DE3uebYEeEYpAJfs3nZ1DxIngFfp8RZJ5c1i8s74cnpbFYeuaVbT8+ zMZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mAjgurd9; 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 v7si15796303plp.191.2019.04.04.01.57.41; Thu, 04 Apr 2019 01:57:56 -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=mAjgurd9; 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 S1730245AbfDDIzN (ORCPT + 99 others); Thu, 4 Apr 2019 04:55:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:58012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729275AbfDDIzJ (ORCPT ); Thu, 4 Apr 2019 04:55:09 -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 1CB47217D4; Thu, 4 Apr 2019 08:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368108; bh=/Yo1mGTtFv67WJrWjV208qxiKij7FZQemelRpoEFmgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mAjgurd9B4cMFOrkpc73N+2gPept021agn4W5+cG1Dsp+eW2Rm0KSMezeNFDSgLhh r71UH8gSqtzXX4PhxsTjNJ9VIoZcE+mK4MAUGH4SAZUTCWwtY4atZoeyFGf/IzI4of CkOPcwhEh+PrQB4Tn8atu9qAG2fUyc3RC6RWGMXQ= 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.14 040/121] usb: chipidea: Grab the (legacy) USB PHY by phandle first Date: Thu, 4 Apr 2019 10:47:08 +0200 Message-Id: <20190404084547.470168311@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084545.245659903@linuxfoundation.org> References: <20190404084545.245659903@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.14-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 43ea5fb87b9a..70306ae039c0 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -938,8 +938,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