Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3747C433EF for ; Thu, 3 Feb 2022 18:08:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B5CF783090; Thu, 3 Feb 2022 19:08:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=akkea.ca Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=akkea.ca header.i=@akkea.ca header.b="dozX61N6"; dkim=pass (1024-bit key) header.d=akkea.ca header.i=@akkea.ca header.b="dozX61N6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DFB7383388; Thu, 3 Feb 2022 19:08:53 +0100 (CET) Received: from node.akkea.ca (li1434-30.members.linode.com [45.33.107.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 670BB81DCA for ; Thu, 3 Feb 2022 19:08:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=akkea.ca Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=angus@akkea.ca Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id 5EB334E200E; Thu, 3 Feb 2022 18:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1643911728; bh=bUNIEWpVG8HPxxszuwpU0LIz29+Qk7UKI5hreQmFJg8=; h=From:To:Cc:Subject:Date; b=dozX61N6bA0oTS6l72s8xcrOSjyvrmshQLhdoKwbuqmt554WmFH8+L3ObBhW83Jm/ 7/2Zep7xDTlnvzHOUfICxr9FbxQhRdPFXRMnfiCiS/vFcCzptJAdmayYvQZtN/9SC5 VeIAhfxLvcduX7IRxchqQHRP3R749HxrINirOAGY= Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Or_FHIKmM5lf; Thu, 3 Feb 2022 18:08:48 +0000 (UTC) Received: from midas.localdomain (S0106788a2041785e.gv.shawcable.net [24.108.106.191]) by node.akkea.ca (Postfix) with ESMTPSA id 96FB74E2006; Thu, 3 Feb 2022 18:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1643911728; bh=bUNIEWpVG8HPxxszuwpU0LIz29+Qk7UKI5hreQmFJg8=; h=From:To:Cc:Subject:Date; b=dozX61N6bA0oTS6l72s8xcrOSjyvrmshQLhdoKwbuqmt554WmFH8+L3ObBhW83Jm/ 7/2Zep7xDTlnvzHOUfICxr9FbxQhRdPFXRMnfiCiS/vFcCzptJAdmayYvQZtN/9SC5 VeIAhfxLvcduX7IRxchqQHRP3R749HxrINirOAGY= From: Angus Ainslie To: u-boot@lists.denx.de Cc: Simon Glass , Neil Armstrong , Angus Ainslie , Alper Nebi Yasak , Alexander Dahl , Sean Anderson , Patrick Delaunay , kernel@puri.sm Subject: [PATCH] phy: phy-uclass: check the parents for phys Date: Thu, 3 Feb 2022 10:08:38 -0800 Message-Id: <20220203180838.2313500-1-angus@akkea.ca> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The port/hub leaf nodes don't contain the phy definitions in some dts files so check the parents. Signed-off-by: Angus Ainslie --- drivers/phy/phy-uclass.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c index 49e2ec25c2..8b84da3ce0 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -354,23 +354,31 @@ int generic_phy_configure(struct phy *phy, void *params) int generic_phy_get_bulk(struct udevice *dev, struct phy_bulk *bulk) { int i, ret, count; + struct udevice *phydev = dev; bulk->count = 0; /* Return if no phy declared */ - if (!dev_read_prop(dev, "phys", NULL)) - return 0; + if (!dev_read_prop(dev, "phys", NULL)) { + phydev = dev->parent; + if (!dev_read_prop(phydev, "phys", NULL)) { + pr_err("%s : no phys property\n", __func__); + return 0; + } + } - count = dev_count_phandle_with_args(dev, "phys", "#phy-cells", 0); - if (count < 1) + count = dev_count_phandle_with_args(phydev, "phys", "#phy-cells", 0); + if (count < 1) { + pr_err("%s : no phys found %d\n", __func__, count); return count; + } - bulk->phys = devm_kcalloc(dev, count, sizeof(struct phy), GFP_KERNEL); + bulk->phys = devm_kcalloc(phydev, count, sizeof(struct phy), GFP_KERNEL); if (!bulk->phys) return -ENOMEM; for (i = 0; i < count; i++) { - ret = generic_phy_get_by_index(dev, i, &bulk->phys[i]); + ret = generic_phy_get_by_index(phydev, i, &bulk->phys[i]); if (ret) { pr_err("Failed to get PHY%d for %s\n", i, dev->name); return ret; -- 2.25.1