Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1003837yba; Thu, 4 Apr 2019 02:11:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqztvtCpQ4vuhmfIBWY5rD2eBI8w5kHCL7a6JXqbrIZgMX9MOd/GLiF97HMHmKkC9CJ/n6Po X-Received: by 2002:a17:902:ea0d:: with SMTP id cu13mr5169467plb.92.1554369105150; Thu, 04 Apr 2019 02:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554369105; cv=none; d=google.com; s=arc-20160816; b=xRcYAmGFsGxrsYIb6nAX3/5cDMYf3FnrfQy/J5TWBxGqTZnP/HAQxpEd+MYjo+EWsj 1xcI8o+QU+CZ1u7d075NQwN9ZGhOfSNtHVzpWUpb5bOpdPSH3yK4p7T9cXV20mgfG4Bv MayjcH3fhqtQURxGL5NOWWRb3yBOuTN1TgenQ+6X9dLJ03W7Q+i2GtvlFLknXRE/A7bR RqvIbAynji4BODKo7PYqezVXHXD37nPiSjhNMSIoyZ2Et8ZF+mFylBfw33PdPo2rivtl QptZLEkGTpDSBBsMoInbpuLXQ99OpG023vEL4sHnnW6oUChEJ8m0KY1jzFQh4LZPPIG3 JZww== 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=j/l9UJDckEpEYmuGOBBHMjSMwmMoasb1vhYxwaoHeuk=; b=KjBumkv8ErHadkBKDt4vaH+0l2axPLb2cnHPTxkEjO3iqH7KWQAyOCIvc+/YArjPR7 j8OFPkv8jgAT4xpD+YXPP5gPTufzaf4UzcgY2UHrtGwcmDdY4G/pCyDqEguy9xDWkRyN cBQyPTImH+89L7KN8RA5lkaw8u8d9YoWexZpFbH7nQgxl7p9qUNdC+E/DB8JProlfOHt BadLeXDgf773QW4BuipNl4LHrcH/qZZzj3G0pK/J719ydL4isGaohqv82AbYoDoGwHpC K0e6TLEihOO+P+WLdgcmiOCS8poNDtKtaJyHjQOLuyUoA0dHXqmjhK8d8EcKZa1j7cT1 DX4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lw2SVr3S; 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 u3si16182037pfn.281.2019.04.04.02.11.29; Thu, 04 Apr 2019 02:11:45 -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=Lw2SVr3S; 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 S1733093AbfDDJK6 (ORCPT + 99 others); Thu, 4 Apr 2019 05:10:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:50732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733086AbfDDJK4 (ORCPT ); Thu, 4 Apr 2019 05:10:56 -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 0332520693; Thu, 4 Apr 2019 09:10:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554369055; bh=BOUCe4qItu6MoKe6kgJI66qQLOyN/TTOqvTwEyFQjQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lw2SVr3SGAcWtW4KakmaS3dUiokT/0OqflumjRmJH2tqy4qQGkDBjc4R/va1/OssX Q0/hJUEDFhpElHS250vAfFZU9raVK9tXxulNgRG6wGdBOYOgUoqQDiPvtsYlzhJA6U AgEdN1JNPmumd5n0W4Wvt/xIGG2s9GjvzzDObJX0= 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 5.0 066/246] usb: chipidea: Grab the (legacy) USB PHY by phandle first Date: Thu, 4 Apr 2019 10:46:06 +0200 Message-Id: <20190404084621.462950971@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084619.236418459@linuxfoundation.org> References: <20190404084619.236418459@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 5.0-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 7bfcbb23c2a4..016e4004fe9d 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -954,8 +954,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