From patchwork Wed Feb 5 12:42:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13960927 X-Patchwork-Delegate: kuba@kernel.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34AB0151987; Wed, 5 Feb 2025 12:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759373; cv=none; b=IGG8av1J2M9xX3F55UYTuPgVn8lV5SFxQAEiguuLw/M2blW/eWqga9aGx0YI5EN0d16wYmK7g0TnC7uGpbQk5NXuQz++PgxsrglRoEiVjHOylXomZciQm00fnjq2w/RtEmtaSYco1COJX1mDlnvkm8mjRQWXyHPx3nV+67qD52s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759373; c=relaxed/simple; bh=YEYdw+RFyZttEyYMNGQiwpZ9nMRJRavaUV89oFfVInc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hJTT6M8a3edwlJ8yiSG1JdvP1Z5wP134LodXIU47wyC8h7js37oDVSqBDyh/tsADvOCrz9W41bjpABBCLrxzwViyALtllIG8MMTo+Eczq05dzsMmyFP7uEGZzopFyRZUmUwWqO7gTd8+tVc9q7agA5yfldguBMd0Ys9l+SAlY4U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-CSE-ConnectionGUID: qJDgGzujQ7SrbqbP/MsImQ== X-CSE-MsgGUID: Pn+2gzssSaqklt7ImdEg4g== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 05 Feb 2025 21:42:48 +0900 Received: from localhost.localdomain (unknown [10.226.92.225]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 9599F41F86AF; Wed, 5 Feb 2025 21:42:43 +0900 (JST) From: Biju Das To: Rob Herring , Saravana Kannan , Matthias Brugger , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , AngeloGioacchino Del Regno Cc: Biju Das , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH net-next v2 1/7] of: base: Add of_get_available_child_by_name() Date: Wed, 5 Feb 2025 12:42:21 +0000 Message-ID: <20250205124235.53285-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> References: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org There are lot of drivers using of_get_child_by_name() followed by of_device_is_available() to find the available child node by name for a given parent. Provide a helper for these users to simplify the code. Suggested-by: Geert Uytterhoeven Reviewed-by: Rob Herring Signed-off-by: Biju Das --- previous v2->v2 * Added Rb tag from Rob. v1->previous v2: * Updated commit description. * Updated kerneldoc comment block * Avoided code duplication by using of_get_child_by_name(). --- drivers/of/base.c | 27 +++++++++++++++++++++++++++ include/linux/of.h | 9 +++++++++ 2 files changed, 36 insertions(+) diff --git a/drivers/of/base.c b/drivers/of/base.c index af6c68bbb427..e37b088f1fad 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -824,6 +824,33 @@ struct device_node *of_get_child_by_name(const struct device_node *node, } EXPORT_SYMBOL(of_get_child_by_name); +/** + * of_get_available_child_by_name - Find the available child node by name for a given parent + * @node: parent node + * @name: child name to look for. + * + * This function looks for child node for given matching name and checks the + * device's availability for use. + * + * Return: A node pointer if found, with refcount incremented, use + * of_node_put() on it when done. + * Returns NULL if node is not found. + */ +struct device_node *of_get_available_child_by_name(const struct device_node *node, + const char *name) +{ + struct device_node *child; + + child = of_get_child_by_name(node, name); + if (child && !of_device_is_available(child)) { + of_node_put(child); + return NULL; + } + + return child; +} +EXPORT_SYMBOL(of_get_available_child_by_name); + struct device_node *__of_find_node_by_path(const struct device_node *parent, const char *path) { diff --git a/include/linux/of.h b/include/linux/of.h index eaf0e2a2b75c..9d6b8a61607f 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -301,6 +301,8 @@ extern struct device_node *of_get_compatible_child(const struct device_node *par const char *compatible); extern struct device_node *of_get_child_by_name(const struct device_node *node, const char *name); +extern struct device_node *of_get_available_child_by_name(const struct device_node *node, + const char *name); /* cache lookup */ extern struct device_node *of_find_next_cache_node(const struct device_node *); @@ -578,6 +580,13 @@ static inline struct device_node *of_get_child_by_name( return NULL; } +static inline struct device_node *of_get_available_child_by_name( + const struct device_node *node, + const char *name) +{ + return NULL; +} + static inline int of_device_is_compatible(const struct device_node *device, const char *name) { From patchwork Wed Feb 5 12:42:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13960928 X-Patchwork-Delegate: kuba@kernel.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2D6422CBF0; Wed, 5 Feb 2025 12:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759375; cv=none; b=XrVARagHYr/1n3rzdpR+eQP9xnGcf3/PbV0dIYkMTmqs+9/DyFsulTtECQIJeLt3rXvwN6RCzu4/NocHvkyDMLQU632d4LR/7oG3t09epXWyqNouA8pX7J3I0RvrAz9ufpv9VsR2MrbDGvWQvckTR52zD3mvnZFdM+ctE3cGGAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759375; c=relaxed/simple; bh=M59bAyhFbBpgimep1aNSv2IjiEbV0AW5sYtPvby1jk4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j9yyysl5DI4ibldkYfsSEUN3gsEAeeDPDQXfeBTfd24S/45RdjlDv3frhyk7aTFK56Knnx04g67/N0DMmGjPoprUgCgzd5scPWzCvnm+5XwP8DsyDB4J/3XvtmsqWsaGueAmsw5zq9ggjJlzZD0ASQ86ivN9LA5DQAIr5fzdwXE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-CSE-ConnectionGUID: T6ydRXaWRROGraya7wGKig== X-CSE-MsgGUID: KqT/9pnmRKGRVER+RoQePg== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 05 Feb 2025 21:42:52 +0900 Received: from localhost.localdomain (unknown [10.226.92.225]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 18CD341F86A7; Wed, 5 Feb 2025 21:42:48 +0900 (JST) From: Biju Das To: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Biju Das , linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das Subject: [PATCH net-next v2 2/7] net: dsa: rzn1_a5psw: Use of_get_available_child_by_name() Date: Wed, 5 Feb 2025 12:42:22 +0000 Message-ID: <20250205124235.53285-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> References: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Simplify a5psw_probe() by using of_get_available_child_by_name(). While at it, move of_node_put(mdio) inside the if block to avoid code duplication. Signed-off-by: Biju Das --- v1->v2: * Rebased and added patch suffix net-next. --- drivers/net/dsa/rzn1_a5psw.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c index 66974379334a..31ea8130a495 100644 --- a/drivers/net/dsa/rzn1_a5psw.c +++ b/drivers/net/dsa/rzn1_a5psw.c @@ -1248,18 +1248,16 @@ static int a5psw_probe(struct platform_device *pdev) if (ret) goto clk_disable; - mdio = of_get_child_by_name(dev->of_node, "mdio"); - if (of_device_is_available(mdio)) { + mdio = of_get_available_child_by_name(dev->of_node, "mdio"); + if (mdio) { ret = a5psw_probe_mdio(a5psw, mdio); + of_node_put(mdio); if (ret) { - of_node_put(mdio); dev_err(dev, "Failed to register MDIO: %d\n", ret); goto hclk_disable; } } - of_node_put(mdio); - ds = &a5psw->ds; ds->dev = dev; ds->num_ports = A5PSW_PORTS_NUM; From patchwork Wed Feb 5 12:42:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13960930 X-Patchwork-Delegate: kuba@kernel.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35C5922ACC6 for ; Wed, 5 Feb 2025 12:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759386; cv=none; b=RsZyaeVjsKl4C+XQAVJJga1CjQL9+68BnFSjhqnR/TafqZsrxcv1IPfviBeTQUHrnWNjbpBBxFq7zMtdbBK5RdBGM9c9j82B0qs0ttciRJT0vRReobHIg48GVa6IiJRk70jloxSQOT+9/BWYANylkp5HwM08VQsFLVKQdzSEHcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759386; c=relaxed/simple; bh=/By+oCRZjiaYCiEru6w0iWiKL671JCi+VB1DA1Za1QU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NLVjYRjEnLIBeOescm0nCsyl5xxTBC3EEA0T8IlYN48Y9czVJmCq4YiZsztHywDM49uSE7NJmK8P65pFRYb8Kw+A4rNGiVrU4i8pimyed3vkDVaRWKEeMcb+7h1bHdVHXPMmtPr3ADKJhAaYkTgv3FA9TfSfM24OaAKpE1bM0Jg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-CSE-ConnectionGUID: oORIsVN5T+OqCrjya76M2g== X-CSE-MsgGUID: 0ZKUtHwqQc6diYjxjsLPcg== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 05 Feb 2025 21:43:03 +0900 Received: from localhost.localdomain (unknown [10.226.92.225]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 7282741F8497; Wed, 5 Feb 2025 21:42:53 +0900 (JST) From: Biju Das To: Vladimir Oltean , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Biju Das , netdev@vger.kernel.org, Geert Uytterhoeven , Biju Das Subject: [PATCH net-next v2 3/7] net: dsa: sja1105: Use of_get_available_child_by_name() Date: Wed, 5 Feb 2025 12:42:23 +0000 Message-ID: <20250205124235.53285-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> References: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use the helper of_get_available_child_by_name() to simplify sja1105_mdiobus_register(). Signed-off-by: Biju Das --- v1->v2: * Dropped using _free(). --- drivers/net/dsa/sja1105/sja1105_mdio.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c index 84b7169f2974..8d535c033cef 100644 --- a/drivers/net/dsa/sja1105/sja1105_mdio.c +++ b/drivers/net/dsa/sja1105/sja1105_mdio.c @@ -468,13 +468,10 @@ int sja1105_mdiobus_register(struct dsa_switch *ds) if (rc) return rc; - mdio_node = of_get_child_by_name(switch_node, "mdios"); + mdio_node = of_get_available_child_by_name(switch_node, "mdios"); if (!mdio_node) return 0; - if (!of_device_is_available(mdio_node)) - goto out_put_mdio_node; - if (regs->mdio_100base_tx != SJA1105_RSV_ADDR) { rc = sja1105_mdiobus_base_tx_register(priv, mdio_node); if (rc) @@ -487,7 +484,6 @@ int sja1105_mdiobus_register(struct dsa_switch *ds) goto err_free_base_tx_mdiobus; } -out_put_mdio_node: of_node_put(mdio_node); return 0; From patchwork Wed Feb 5 12:42:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13960931 X-Patchwork-Delegate: kuba@kernel.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FA62151987 for ; Wed, 5 Feb 2025 12:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759389; cv=none; b=nPJJpjmB5o/zJBtSOhJOGtYy/lVxKq+m7Gv3hUurNwI/tREH1grGIISUOnK9ffjzflBaB+trvjn81IHwNXiwapoj4SD70ED5jfqP1HAIkossMmQdlDwZIJNQrVal3MIhFIn851m4ecMmdN4TEcr05sevnwbbZAuD8GKO4CPVtGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759389; c=relaxed/simple; bh=H33hURR7xzjz1AVHWTdUM2TEYSjtNcmtPyyliQYYmVA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L8Ogn8fO/WJk/8c8t8psLFCV4RvaJEefN/MevEid+I9zGm3YTqpeQJFDheVD7yp2EjMWS66xwqoCLvJj4gzxvTdaSCFwogpC2e+E0w4vPS7NX26MwJXbi+v/FZb3/2CpNWBUMAbQTUoqWIG4+6mbHyhnVfDETzkCQ9CBjA1+h2o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-CSE-ConnectionGUID: KTNcS2wNQMaUlothZ7KZaQ== X-CSE-MsgGUID: zctjB0xES0S1VXpVZgYMxQ== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 05 Feb 2025 21:43:02 +0900 Received: from localhost.localdomain (unknown [10.226.92.225]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 45B7241F86AB; Wed, 5 Feb 2025 21:42:56 +0900 (JST) From: Biju Das To: Felix Fietkau , Sean Wang , Lorenzo Bianconi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno Cc: Biju Das , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Geert Uytterhoeven , Biju Das Subject: [PATCH net-next v2 4/7] net: ethernet: mtk-star-emac: Use of_get_available_child_by_name() Date: Wed, 5 Feb 2025 12:42:24 +0000 Message-ID: <20250205124235.53285-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> References: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use the helper of_get_available_child_by_name() to simplify mtk_star_mdio_init(). Signed-off-by: Biju Das --- v1->v2: * Dropped using _free() --- drivers/net/ethernet/mediatek/mtk_star_emac.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c index 25989c79c92e..76f202d7f055 100644 --- a/drivers/net/ethernet/mediatek/mtk_star_emac.c +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c @@ -1427,15 +1427,10 @@ static int mtk_star_mdio_init(struct net_device *ndev) of_node = dev->of_node; - mdio_node = of_get_child_by_name(of_node, "mdio"); + mdio_node = of_get_available_child_by_name(of_node, "mdio"); if (!mdio_node) return -ENODEV; - if (!of_device_is_available(mdio_node)) { - ret = -ENODEV; - goto out_put_node; - } - priv->mii = devm_mdiobus_alloc(dev); if (!priv->mii) { ret = -ENOMEM; From patchwork Wed Feb 5 12:42:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13960933 X-Patchwork-Delegate: kuba@kernel.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 038DF22CBFC for ; Wed, 5 Feb 2025 12:43:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759396; cv=none; b=VPtfGQTJDG1e3ctjJusmEKM0b72yH0vVg5IO6EiVaUF62he96fChmbmzp8xeB51fjQ0l5uDKeSwO19aWIIxR3L7C2D1jQhJtoyWafzSky25ZB9aY2p162h/nSuj0hpwXFwRynnBc1rNLdTmwoVF8Xo1mCBzyAFu91s9GDaURM/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759396; c=relaxed/simple; bh=0a76rMX4A5KkCWxXKAhyeftlYEa53MDXoI+fCqhufo0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RcsY6GbXZHSqP5okh8MOO9y9VrE+nWiv2upwmJFU1Flh92AZ/+Opp/XDKFO2Yd3T2us7K1Y+W20kaLD4Yxu0VGHZd5Kj+Uv0bnUASUVu+M5W9xmCT45Feb6S4B62uO7mNUyFtjw6msrow0hgIexagydMZXOV17PaLjYXWtHF9w4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-CSE-ConnectionGUID: kZEjbmkXQmKuWVWpCE4ldQ== X-CSE-MsgGUID: heLXhqTjSwWnRtR0B4PM8w== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 05 Feb 2025 21:43:13 +0900 Received: from localhost.localdomain (unknown [10.226.92.225]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id AC44F41F86B5; Wed, 5 Feb 2025 21:43:02 +0900 (JST) From: Biju Das To: Felix Fietkau , Sean Wang , Lorenzo Bianconi , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno Cc: Biju Das , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Geert Uytterhoeven , Biju Das Subject: [PATCH net-next v2 5/7] net: ethernet: mtk_eth_soc: Use of_get_available_child_by_name() Date: Wed, 5 Feb 2025 12:42:25 +0000 Message-ID: <20250205124235.53285-6-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> References: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use the helper of_get_available_child_by_name() to simplify mtk_mdio_init(). Signed-off-by: Biju Das --- v1->v2: * Dropped using _free(). --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 53485142938c..0ad965ced5ef 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -830,17 +830,12 @@ static int mtk_mdio_init(struct mtk_eth *eth) int ret; u32 val; - mii_np = of_get_child_by_name(eth->dev->of_node, "mdio-bus"); + mii_np = of_get_available_child_by_name(eth->dev->of_node, "mdio-bus"); if (!mii_np) { dev_err(eth->dev, "no %s child node found", "mdio-bus"); return -ENODEV; } - if (!of_device_is_available(mii_np)) { - ret = -ENODEV; - goto err_put_node; - } - eth->mii_bus = devm_mdiobus_alloc(eth->dev); if (!eth->mii_bus) { ret = -ENOMEM; From patchwork Wed Feb 5 12:42:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13960932 X-Patchwork-Delegate: kuba@kernel.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1C93151987 for ; Wed, 5 Feb 2025 12:43:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759394; cv=none; b=gUhBHAjKliJo8JQRBoX3INnPOQzgiUT2IWHq+RazvUr5l+yGiBjoUVD0M7z1JQLJjrQBNeMgu0jw0wLRkKrZQYMTZk3DSc9pmg6Ug+zTtcszIuj+fexHqtAbibks29fTC/hKXcUf5hP/lTVERYuQ8aLopU6W3MCVE/6Y6ZHAapw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759394; c=relaxed/simple; bh=UMKsj3kOJyvqQuwohwlW+wXDdaliWn1oR5I20QwRHfs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K1dZxMbOmXiGiBUjDQ3FIgMp81oCuLG5Is+G3SP+2qYoTKKb4csHizJwhNqIkzepYwgmE5P7G+eCF+uJrBZHapUyPtdA/a6H8WNNOQN1AuTiNzZT3eRWGCyuQ6p6NIqHIn1GUqwouOESxlGF/oo56qpM6g5ZcRMmKeXLFd5szJg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-CSE-ConnectionGUID: ceBcTh8kQCW+CZ/WKhC9Yg== X-CSE-MsgGUID: TpZdVZhQTc2TjjwYpYPbgw== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 05 Feb 2025 21:43:11 +0900 Received: from localhost.localdomain (unknown [10.226.92.225]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id DF36D41F86AF; Wed, 5 Feb 2025 21:43:07 +0900 (JST) From: Biju Das To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Andreas_F=C3=A4rber?= , Manivannan Sadhasivam Cc: Biju Das , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-actions@lists.infradead.org, Geert Uytterhoeven , Biju Das Subject: [PATCH net-next v2 6/7] net: ethernet: actions: Use of_get_available_child_by_name() Date: Wed, 5 Feb 2025 12:42:26 +0000 Message-ID: <20250205124235.53285-7-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> References: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use the helper of_get_available_child_by_name() to simplify owl_emac_mdio_init(). Signed-off-by: Biju Das --- previous v2->v2: * Dropped using _free(). v1-> previous v2: * Dropped duplicate mdio_node declaration. --- drivers/net/ethernet/actions/owl-emac.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/ethernet/actions/owl-emac.c b/drivers/net/ethernet/actions/owl-emac.c index 115f48b3342c..0a08da799255 100644 --- a/drivers/net/ethernet/actions/owl-emac.c +++ b/drivers/net/ethernet/actions/owl-emac.c @@ -1325,15 +1325,10 @@ static int owl_emac_mdio_init(struct net_device *netdev) struct device_node *mdio_node; int ret; - mdio_node = of_get_child_by_name(dev->of_node, "mdio"); + mdio_node = of_get_available_child_by_name(dev->of_node, "mdio"); if (!mdio_node) return -ENODEV; - if (!of_device_is_available(mdio_node)) { - ret = -ENODEV; - goto err_put_node; - } - priv->mii = devm_mdiobus_alloc(dev); if (!priv->mii) { ret = -ENOMEM; From patchwork Wed Feb 5 12:42:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13960934 X-Patchwork-Delegate: kuba@kernel.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD75322DF81 for ; Wed, 5 Feb 2025 12:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759409; cv=none; b=KMVWx1SplRHT6ujGeS50XAPZH5IWp3Ng2PbK3hHW3A5kYwvoKZ11Th2r4NnrSSCLCTCBarhIJZkFljWuDm8v2I11fEaQnmMuXxUfmVcHypohAPUoiBf4RGo/reNwFAc/qPQtRERqJTYQcms/JzARu3tjX+K9U/qQwrynMoXDbnA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738759409; c=relaxed/simple; bh=TJrOO80xGmN2b0CDRuYtCrX2qz0g5fveMRkZM0ot4fo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J0NqDg6dDevYYYGudKf9RL3UOrEMMvUOLHucTpTmr/or3DE11g1HZj8GehQc4x6dBtU6INpfYJUwqb7SRTSUUiDxvyNM8iROI9KU7e1GjuDUWYGmdz5P4sQUZsoY7m/uJouBQ06TgHwsF5yFn6DEd+bW6mnxjMULD3AnNlBNYQw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-CSE-ConnectionGUID: Fii3sQLtT9qTh/UL0YK85w== X-CSE-MsgGUID: myESdrXdT/+YWeio5jb/TA== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 05 Feb 2025 21:43:26 +0900 Received: from localhost.localdomain (unknown [10.226.92.225]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 4B07541F8497; Wed, 5 Feb 2025 21:43:12 +0900 (JST) From: Biju Das To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Biju Das , Rosen Penev , Shannon Nelson , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Simon Horman , netdev@vger.kernel.org, Geert Uytterhoeven , Biju Das Subject: [PATCH net-next v2 7/7] net: ibm: emac: Use of_get_available_child_by_name() Date: Wed, 5 Feb 2025 12:42:27 +0000 Message-ID: <20250205124235.53285-8-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> References: <20250205124235.53285-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use the helper of_get_available_child_by_name() to simplify emac_dt_mdio_probe(). Signed-off-by: Biju Das --- v1->v2: * Dropped using _free() --- drivers/net/ethernet/ibm/emac/core.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index 25b8a3556004..417dfa18daae 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -2554,17 +2554,12 @@ static int emac_dt_mdio_probe(struct emac_instance *dev) struct mii_bus *bus; int res; - mii_np = of_get_child_by_name(dev->ofdev->dev.of_node, "mdio"); + mii_np = of_get_available_child_by_name(dev->ofdev->dev.of_node, "mdio"); if (!mii_np) { dev_err(&dev->ofdev->dev, "no mdio definition found."); return -ENODEV; } - if (!of_device_is_available(mii_np)) { - res = -ENODEV; - goto put_node; - } - bus = devm_mdiobus_alloc(&dev->ofdev->dev); if (!bus) { res = -ENOMEM;