Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp924754imj; Fri, 15 Feb 2019 09:03:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IZENoq+1iidd5TX2GTfbNh9GpBSDpu/fYMruYkxwb34tGdsT9pV+0sTvbwWl/VGxzgPDwtV X-Received: by 2002:a63:cf4b:: with SMTP id b11mr6419082pgj.405.1550250236643; Fri, 15 Feb 2019 09:03:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550250236; cv=none; d=google.com; s=arc-20160816; b=Sz9Ggc4ydHVRb6BMJ6zr0tDDl+wf9NX7WHafJFRR9G7RAB1hR6813/ZYCUwty7Qd93 MmBNdzDAQ19hD0BD9u/w2KuYXSNhZ6BfxiDGD/UoA2sHftiYEhYU50ZyGLtTxwWYbrF7 WVi6E1yR9paKA3Z+1XnkUbp2CvGU24EUkvOqcT19+P8ZiI0GFWTd0wbvvD9bdMd2L5VQ sXkpBIiphYa9tbKUR5ETXnE2pXhHdDP2b1jaq0YpVhmqkWmRvNf2yeHIJ4fjJopET1Vm 2t0dgtqIktrPTYiscZR188Wp+YU492WjrFrmn+Cjgh+eajnQfGrs3+Bf7eUBAXgf5R8X GjbQ== 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 :message-id:date:subject:cc:to:from; bh=di6Sfcv07GmX1pAyLQZp9AogOv7mzBn4lLKcsG6RPiE=; b=a4oUe0BljAHt2e9c+b+JzXH1Vmuy87I5QR0rF5n9J7e3S1nHyxoNCSO0gaIkYLcU25 /8uNVnUIuGw//rwxkn9wmb/ZCBfrjozUzjBdlE2PUV3NOdLbeVwp7QqFBapWhgUHVkhr pkbKN+hOAEussp3SGeqUXDxx4JkXPkNPDJOX62mmeI/MYLcdGDerN/JxP0EmIAIYE+60 bDAkvNi8eScoNfAh0506n3qJs2hl8F4zyp7Hl47lqqNleCKe1h1znG1ZFp/ISq704Uis ImPCxmAhuF64y5nsBJf6dMc2XJV56qzkKnWRvqvlej4i9oescKnG8jKSqtf5z5A5TU1a Pepg== ARC-Authentication-Results: i=1; mx.google.com; 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 d4si5972716pfa.150.2019.02.15.09.03.29; Fri, 15 Feb 2019 09:03:56 -0800 (PST) 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; 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 S1728812AbfBOQgJ (ORCPT + 99 others); Fri, 15 Feb 2019 11:36:09 -0500 Received: from mslow2.mail.gandi.net ([217.70.178.242]:53836 "EHLO mslow2.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726137AbfBOQgJ (ORCPT ); Fri, 15 Feb 2019 11:36:09 -0500 Received: from relay9-d.mail.gandi.net (unknown [217.70.183.199]) by mslow2.mail.gandi.net (Postfix) with ESMTP id 786F73A7FD6; Fri, 15 Feb 2019 17:22:45 +0100 (CET) X-Originating-IP: 90.88.30.68 Received: from localhost.localdomain (aaubervilliers-681-1-89-68.w90-88.abo.wanadoo.fr [90.88.30.68]) (Authenticated sender: paul.kocialkowski@bootlin.com) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 0A2CFFF805; Fri, 15 Feb 2019 16:22:42 +0000 (UTC) From: Paul Kocialkowski To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Peter Chen , Greg Kroah-Hartman , Thomas Petazzoni , Paul Kocialkowski Subject: [PATCH v3] usb: chipidea: Grab the (legacy) USB PHY by phandle first Date: Fri, 15 Feb 2019 17:22:25 +0100 Message-Id: <20190215162225.19284-1-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes since v2: * Fixed typos in commit message. Changes since v1: * Only consider legacy USB PHY error for fallback as suggested; * Checked against EPROBE_DEFER before entering fallback. 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.20.1