Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5582284img; Wed, 27 Mar 2019 11:07:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZuP01LK0KsS814roee5Hhr5YT0TXiDA1XH/4C680jGDak1ZL2NnZ3XjNt68lWxQQAza4n X-Received: by 2002:a17:902:248:: with SMTP id 66mr39184638plc.286.1553710024604; Wed, 27 Mar 2019 11:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553710024; cv=none; d=google.com; s=arc-20160816; b=JlUYoRkRVXRQXFMePM0a0eR2cv4f97cDVzIIXO/4OK4GxO4PCmpm2r4d7UNL4m1gkd 9hgE4iyxuY4+UOzO1q2CBcrZd0x5HMO1CYHnZ8cwH2Q4y26WbuWoviK21225Ii18+5X7 786Ck48/reBX7v8zxestXDn7TJUOWm46sOrXb4d710xRJ8Zfls204Zx8nzNCnyCnj2yX pGDytdxZ1AN+38YMSmaB0tiAw5PhiHKLQOGvFmwx4xv5iDSvhIcQ2fCsYslK9ZxHWpwK OAy9yOqVyd21+DLw7teStqWzgFRyrVuwJ7B/9tqymF491sUxjmfKJb52cJ+4EhZHensR OvLw== 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=U8MGLZ5heg3m5vWL4w4ud8gNbBuAj99homKYee0Qdcc=; b=Zc0kzF36lj/KcMcn4eCQWm/GXfqYRUCjmSVH/iGoiDzxXr9SUXoo5A6Z5YcmV3Xryq G2c+Oroxpu/2diJ9FxgU8ciXCIMdklGO1Tiwbdu81fxrNoK6JlGn16s2ssmK01DW6MCO D98lJDm0pbwyQJZ/KZjIq5LTpX1fPJVxK98ntojyqClYAG4/MmpoV+5R115bMfAE5NbM qFSZoNxDBu+cTKROH19mFtftbZ40iS3rS9ZtjgFtEbKFCS0gWVWrNiGky2Pxkk3wUtLg DMDKQ12cKZSdb025YF3S47V56LZBmo9nyk9SZCcHuULIx2r3UJCHNbbXFxOt9G2gIglS QE4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ajj9BjFT; 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 65si20227157plf.288.2019.03.27.11.06.49; Wed, 27 Mar 2019 11:07:04 -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=ajj9BjFT; 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 S1733162AbfC0SEK (ORCPT + 99 others); Wed, 27 Mar 2019 14:04:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:44690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730769AbfC0SEH (ORCPT ); Wed, 27 Mar 2019 14:04:07 -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 147DC2183F; Wed, 27 Mar 2019 18:04:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709846; bh=BpbjgeulZdFAFYAQJn30qI9AGE9S1+pSqf8SdbY3wPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ajj9BjFTuX/TEQk3fFVSEX2aojPxpb1BAEBegKdSZ2C4FgEq3Dh30IEVBHgT296OK 4voasCutAezqjyL3qrYuUpLIMbLq1HOSHBAnEn4PI5yQjvJ+llG79ePLHdpMzCcH01 82oBZ/U2QhMSoee2XsWlBcbtb1lBgPyow48Oxwys= 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 5.0 071/262] usb: chipidea: Grab the (legacy) USB PHY by phandle first Date: Wed, 27 Mar 2019 13:58:46 -0400 Message-Id: <20190327180158.10245-71-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-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 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