From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F0ABC43381 for ; Wed, 27 Mar 2019 18:52:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0FF7C205C9 for ; Wed, 27 Mar 2019 18:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553712754; bh=X3DYLM0Eb7a3pvcdqcBx/kgEhQKrPuSjBmCxS9ehUzQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=pg8XrNx5geKl/zLufKoKTK1ipn6GhWaqe8x4E4lvJ+z4aIILKzhfbaIa6hFGO79zu IT55cFbAd0ujukUvopw85RGxnaNvtfBuZFMzVjpd2oxhfFZK536eyJzAi7AWonYJNq +07Bm5rUiLVmnI6m5iY1OrQGr8HLwRpR9OXRKfkQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390347AbfC0SRk (ORCPT ); Wed, 27 Mar 2019 14:17:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:34094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389996AbfC0SRh (ORCPT ); Wed, 27 Mar 2019 14:17:37 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 707A52087C; Wed, 27 Mar 2019 18:17:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710657; bh=X3DYLM0Eb7a3pvcdqcBx/kgEhQKrPuSjBmCxS9ehUzQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wr1GB1VVXDfGwm2wGgZf198gJ0e9Y+jc1xTPiBZXebN/kIy3RfV67p1X0BR0dvTeQ calq1x8ubleXfS549sb6ziAE8T7YGQgXhIKXo0NWYwLQAegn5xGf1OHay+hBDNeyKO LSeO4VBqNQAaloyimzKfgBilyCjMDCVfuFjk7XZM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Paul Kocialkowski , Peter Chen , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 036/123] usb: chipidea: Grab the (legacy) USB PHY by phandle first Date: Wed, 27 Mar 2019 14:15:00 -0400 Message-Id: <20190327181628.15899-36-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327181628.15899-1-sashal@kernel.org> References: <20190327181628.15899-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paul Kocialkowski [ 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