Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1026135yba; Thu, 4 Apr 2019 02:43:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4qzFCnFdGAUDkszO4krJch8EqALaJRApnW0vI0NAs1/nidv2ZlwVW9XJ/AMG2hl5JV7Jv X-Received: by 2002:a63:360c:: with SMTP id d12mr4602153pga.404.1554371008586; Thu, 04 Apr 2019 02:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554371008; cv=none; d=google.com; s=arc-20160816; b=Vfh2wjqpSxuZPIYX7FOQdppaKnBJSR8nvmd6QfQffeyOqDJaeJp5ThbpDQZQLXldki TRpxwqEaWbp3ZUi4URTjnqbVjeIJw0WreGRXqr8Lq6bZBzOYAfJMaJiunKVDgdnNXdrT yAr2Td1xxnH7+xjDvlvyqTXpEZnJwKVt9VztxrhUtnv4r/I+vw/S51RFyYl1B0sVrkz8 nzpd5p4zE+Hz6XYlnZeHpzPvrTN9fFnueYRKOxb6FaCP3bTekKJyi/HDCCknNSuloUyJ xGHsq4klewJD6waocB/h8dIHHpN6iC/r2mLEre2O/rqh/JFzBhBPoZn68Qo4JWUMveOy 4yxw== 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=RKWhR5RtH61aZC00zl3H5WrjBY6nHSvpZEAx+p7Jr+U=; b=sztVWA4YxLLsZy6kIEaGFk0d8XVs912hu9N4AQf8AKJeV8kldv7dc/YDXeee9yBVmB 9PVSg7W1xm+4Qjq8gk8aBDAmAts9QGW5pEd0zQb9WNHwLql+SS0UBWNLfMN+1zXMGm5k zRDV32wG5+LIx+ApN2C9hBxH827HOIGRytVDYNDJx6CZ5ZOhE4fiT+89TYJCSlD+Lc5G vDGO8Iic8Ge822IIEMIwDdj7SXr2KUMna3OOOOvSz8TOVlg43QLigCOudLD3BChSnxMP 38RoE+xVPccHBWzFj/UTh9FNGdWu6g/LcOxGcL+j2lkbep0IAp7kaqTabeGfHI4+w2On y17g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gDmgzV5W; 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 h69si6999756pge.487.2019.04.04.02.43.13; Thu, 04 Apr 2019 02:43:28 -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=gDmgzV5W; 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 S1731396AbfDDJBR (ORCPT + 99 others); Thu, 4 Apr 2019 05:01:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:38258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730855AbfDDJBM (ORCPT ); Thu, 4 Apr 2019 05:01:12 -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 D73B82183E; Thu, 4 Apr 2019 09:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368472; bh=mprgzQnvcTtOPyzj4++wiiltcdSvblcNX1KhfiPOhyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDmgzV5WpfwrQ/MhIqx8392v8rCSsNZ3DYYeJ2Y4lo7knTP1bHiQAghhmNkFoBWh7 ZiT+ILXrl/WP7JLVPQEklTuI5Emn2XOU9QgA/w1nGtGOEn7kvskYEyvwqdFh9Lc+hj Y7R7lqXB8+UsneH0vK9JhacNFQXGikCHMr75hKXs= 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.19 052/187] usb: chipidea: Grab the (legacy) USB PHY by phandle first Date: Thu, 4 Apr 2019 10:46:29 +0200 Message-Id: <20190404084605.542013759@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@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.19-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 85fc6db48e44..159b897c5e80 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -935,8 +935,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