Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5614939img; Wed, 27 Mar 2019 11:45:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZIKO83fgB/wBg5F3nZr/201VVLmXTiDsIrJXS8wuuVx5QRP8bmWrp4y8vxT0yEYq/ftTZ X-Received: by 2002:aa7:820c:: with SMTP id k12mr12848835pfi.177.1553712332384; Wed, 27 Mar 2019 11:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553712332; cv=none; d=google.com; s=arc-20160816; b=c8DqSowXCJ3yCQjVBrPfavT5C/hgxc/h07IU6+xYh9yc000nOOwXu288fuQNzmSYp7 RkzfOeAstfhIiFq14LZov0pOSN5s6DpoXPxtCfkSx1L/Vwm5ht4QHb0RTGWs3FFi86oG jF1UnfYZTAYjR2+NWX96uUxYBvLWPq+3ZwCaARRVzDA96OR/HIq3iOHRXdCn/gA8aso4 BH5TiNehK7eD31HJU/y9EAEwFPSoFuuT6PzKVS6PyFSXq/G1g9ONBWGAZ5YEUYjfIyFW tpa0OxFZTsYFa6pF/mhmilsKn+RrxmZpTsCrg579U8emot/iflvvOnJeG7ITn4lHv5E4 KWpw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9alB2PKzzPdWwNGF9/X5yPrYmEU1sOpSMjWUYXeVUeg=; b=Bwiy6UPYepDZ987/2rKFVKSnw9rN3ZV1DnwXjnN2kMbbTXWBXp0KhcMz+CU7YI5JGV ljFPYoKDiZliHSEuu4KHA67sn313eSCOTCizF41/HQFZc++UnwBj/XtzARHwL/gJMEeB hgL0frB96obNXujxuvqBTb1Uus68XXZlfVA/ivqUaLkmoBM4I+vq8qPUOSjfHJwLeYq/ rZGOJhFetilwmA2SDElnO0lUXPhIeX8Y4QGdkR/iFN/qh8dRACA6n9eEsVqqNJ05NzNu O/9RfOTvG9CThcNRHYiQleVhv70fz8tXoFMFJx37io4ShZWTZ/uo7lC9KkvvurHnuD8Y wtpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ns5WuiHS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m22si18695485pgv.562.2019.03.27.11.45.17; Wed, 27 Mar 2019 11:45:32 -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=Ns5WuiHS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390584AbfC0SV3 (ORCPT + 99 others); Wed, 27 Mar 2019 14:21:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:39290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391145AbfC0SV0 (ORCPT ); Wed, 27 Mar 2019 14:21:26 -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 5376E2082F; Wed, 27 Mar 2019 18:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710885; bh=zRyu5tVHzZ4oXZu1Pnm9Bga9xA3dembngA7lxWvIrDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ns5WuiHSBPjxBYP4oYrKXFcUyuYGavEs5QyZj7bnfm7tA5Tprnu3AQf3vMr9cnCby cfwkQ3Xl5KgtfW2wd4W8xLqEXz6a3BEYOjAUs+Jfxflb2uArEzCgiOV2v5bZAHbqWc 66evLuerVQmbKM7IJBjm00KwNixMEDAUiRZ267ZE= 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.9 26/87] usb: chipidea: Grab the (legacy) USB PHY by phandle first Date: Wed, 27 Mar 2019 14:19:39 -0400 Message-Id: <20190327182040.17444-26-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327182040.17444-1-sashal@kernel.org> References: <20190327182040.17444-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 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