From patchwork Wed Jun 7 11:58:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13270556 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 297A57488 for ; Wed, 7 Jun 2023 11:58:30 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 297341BFD for ; Wed, 7 Jun 2023 04:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FglZWHLsmjwh6wV19l8Okkc0Fflq2M4hNtBqipFOo7M=; b=JHn8giA39Ig1TCh6oO45+reNhJ LS7VODLC4TKXMLsyNtnJHNH6W3p6TtXdLFseqG00hg56tbTW+nadNYAWrqmPFw5l439xZKWLeiW2a vjd3TuCu/LruVf6RurQJ8SPZV+KCUx790Bymwvat4bHsd8vQqLZVfza/SzVntjm8evsNOHWxSobjC hycoMsyCi7CPffnKUkqmYRMYAeaHjDPVOBV448bw5br3GP6TI2/B35tuQAqei3NZrg9t6a3kJm8Hu cAnYjrDYSPu4aHHvx4kLfEiADXrucQI2gJnI5Go/55KRkx4c30V4UWavY00nm3HySS+01uvIHXaZ8 TPjkd87g==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:57968 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6rnq-0007Kg-G5; Wed, 07 Jun 2023 12:58:14 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q6rnp-00Cfa5-P0; Wed, 07 Jun 2023 12:58:13 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Ioana Ciornei , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org, Paolo Abeni , Sean Anderson Subject: [PATCH net-next v2 01/11] net: dpaa2-mac: allow lynx PCS to manage mdiodev lifetime Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 07 Jun 2023 12:58:13 +0100 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Put the mdiodev after lynx_pcs_create() so that the Lynx PCS driver can manage the lifetime of the mdiodev its using. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index cb70855e2b9a..c0f7dd3b4ac1 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -271,9 +271,9 @@ static int dpaa2_pcs_create(struct dpaa2_mac *mac, } mac->pcs = lynx_pcs_create(mdiodev); + mdio_device_put(mdiodev); if (!mac->pcs) { netdev_err(mac->net_dev, "lynx_pcs_create() failed\n"); - mdio_device_free(mdiodev); return -ENOMEM; } @@ -285,10 +285,7 @@ static void dpaa2_pcs_destroy(struct dpaa2_mac *mac) struct phylink_pcs *phylink_pcs = mac->pcs; if (phylink_pcs) { - struct mdio_device *mdio = lynx_get_mdio_device(phylink_pcs); - lynx_pcs_destroy(phylink_pcs); - mdio_device_free(mdio); mac->pcs = NULL; } } From patchwork Wed Jun 7 11:58:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13270557 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93F1B7488 for ; Wed, 7 Jun 2023 11:58:41 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A7F21FD6 for ; Wed, 7 Jun 2023 04:58:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6XT/c6RL/Um314yTeMdsQ9hJbpiyUNgu45sdtdubkbk=; b=MYNixHbteX5276pHIesgUmpWXl eWT5TO/KZ7pv85WbRkO141GIgKHGGnsuo47uTo4ShyysEGwHZF4CgeexRXhGkDhpph60BLLSeaMgr D5QVh1LLdPOkjGYacx1rcGKKf2Us9LK5rRdwV7c1sF+QmrWf4JGdFxXn1LNNlb+Mbs28cqeSyRbR3 mtM3O6hywaGFA/TCfdchuo+QpTTKpPg3CqR55v6RGoXZi0+yED7nG7OzzZ5yRfAkuGGaTd09fyVCH FbtU9kIOvQINNFGo4IfSBE56M9R+GBsipitg5y/2gftLITl4ziZs4HITFTjOFIZ0kZIe74IDt2s83 QOSLGELg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:48040 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6rnv-0007Kw-Hf; Wed, 07 Jun 2023 12:58:19 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q6rnu-00CfaB-UB; Wed, 07 Jun 2023 12:58:18 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Ioana Ciornei , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org, Paolo Abeni , Sean Anderson Subject: [PATCH net-next v2 02/11] net: fman_memac: allow lynx PCS to handle mdiodev lifetime Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 07 Jun 2023 12:58:18 +0100 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Put the mdiodev after lynx_pcs_create() so that the Lynx PCS driver can manage the lifetime of the mdiodev its using. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/freescale/fman/fman_memac.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c index 625c79d5636f..8f45caf4af12 100644 --- a/drivers/net/ethernet/freescale/fman/fman_memac.c +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c @@ -976,14 +976,10 @@ static int memac_init(struct fman_mac *memac) static void pcs_put(struct phylink_pcs *pcs) { - struct mdio_device *mdiodev; - if (IS_ERR_OR_NULL(pcs)) return; - mdiodev = lynx_get_mdio_device(pcs); lynx_pcs_destroy(pcs); - mdio_device_free(mdiodev); } static int memac_free(struct fman_mac *memac) @@ -1055,8 +1051,7 @@ static struct phylink_pcs *memac_pcs_create(struct device_node *mac_node, return ERR_PTR(-EPROBE_DEFER); pcs = lynx_pcs_create(mdiodev); - if (!pcs) - mdio_device_free(mdiodev); + mdio_device_put(mdiodev); return pcs; } From patchwork Wed Jun 7 11:58:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13270558 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C169D7488 for ; Wed, 7 Jun 2023 11:58:46 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B9161FEA for ; Wed, 7 Jun 2023 04:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oB7biIKgpKIax7oNHTRibqOG2S4goFF6Ody3CttJRV8=; b=nws7d5TAyhytCgkJ0Y4n0o1uBU FtUf/KB+Uwlu/D0ob3LWOCYJZ6I6a4evuVJUHKamdwLw9aOucip0jsrO/BHPD9GP3ZtFJkfoEf26l KoUDTxdyPyslUTY6284xftEZ+ESx+CNSIPU89YTMnQyvNHXpQKpKs9XTNXCGONWe/At3ZwQmiw4AD S6nQLD3URl8UOAktfHVfCGYdmikqW5gD/C0sDhAhj6uXBlz0o31fP5fGJLSUBuK/7U4N3fPE4f9ew RyLp2emOt9edZvpmD/P0mxz6r/EqLVDDUnmRaZc1u1D35oD7kJZVdx3Grf4lH8EOW3kLDG+smgJ8Y 1hYBKpBA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:48050 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6ro0-0007LC-LJ; Wed, 07 Jun 2023 12:58:24 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q6ro0-00CfaI-1T; Wed, 07 Jun 2023 12:58:24 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Ioana Ciornei , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org, Paolo Abeni , Sean Anderson Subject: [PATCH net-next v2 03/11] net: pcs: lynx: remove lynx_get_mdio_device() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 07 Jun 2023 12:58:24 +0100 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org lynx_get_mdio_device() is no longer necessary, let's remove it so the lynx PCS code is always managing the lifetime of the mdiodev. Signed-off-by: Russell King (Oracle) --- drivers/net/pcs/pcs-lynx.c | 8 -------- include/linux/pcs-lynx.h | 2 -- 2 files changed, 10 deletions(-) diff --git a/drivers/net/pcs/pcs-lynx.c b/drivers/net/pcs/pcs-lynx.c index f04dc580ffb8..a90f74172f49 100644 --- a/drivers/net/pcs/pcs-lynx.c +++ b/drivers/net/pcs/pcs-lynx.c @@ -34,14 +34,6 @@ enum sgmii_speed { #define phylink_pcs_to_lynx(pl_pcs) container_of((pl_pcs), struct lynx_pcs, pcs) #define lynx_to_phylink_pcs(lynx) (&(lynx)->pcs) -struct mdio_device *lynx_get_mdio_device(struct phylink_pcs *pcs) -{ - struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); - - return lynx->mdio; -} -EXPORT_SYMBOL(lynx_get_mdio_device); - static void lynx_pcs_get_state_usxgmii(struct mdio_device *pcs, struct phylink_link_state *state) { diff --git a/include/linux/pcs-lynx.h b/include/linux/pcs-lynx.h index 885b59d10581..25f68a096bfe 100644 --- a/include/linux/pcs-lynx.h +++ b/include/linux/pcs-lynx.h @@ -9,8 +9,6 @@ #include #include -struct mdio_device *lynx_get_mdio_device(struct phylink_pcs *pcs); - struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio); struct phylink_pcs *lynx_pcs_create_mdiodev(struct mii_bus *bus, int addr); From patchwork Wed Jun 7 11:58:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13270559 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40E0C7488 for ; Wed, 7 Jun 2023 11:58:52 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4716A1BD4 for ; Wed, 7 Jun 2023 04:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NKzu6tScQTTd6dCbcW/kX4lXt8gMjeHVk3Ows3oQfiU=; b=nSVnQ39ZqantG7/gv4hoWbhuYb elrdkUorDsbO3/ogtkkRXyK88qxUpPlAjthXFUEo8nORsE3zuk8lhmAYvn/33y2fZGWSN++4o2iM4 jLLNac26Bm82y8Vkz/LOuuD6iBJJpKJnT92JbET5l0BdxmwxqgxVwthKAuqRGUIDZToBbG9m+wxaJ Lpd5e4/fKNq54LAuiPRtHsEEPRvdQuhPjCSsLK6sD23ZKp8QYboUsK71j2cQmm38sloyNGw3WJIsB PdDsuWloihCDXD+EYSCUnjdnY8/jgROLZTInv+h49z6R+Vv7SD/GmqdCr44Dv/kwOG3t1lKsosRB6 Cyrdpz9A==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44798 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6ro5-0007LR-Nn; Wed, 07 Jun 2023 12:58:29 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q6ro5-00CfaO-4y; Wed, 07 Jun 2023 12:58:29 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Ioana Ciornei , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org, Paolo Abeni , Sean Anderson Subject: [PATCH net-next v2 04/11] net: pcs: lynx: add lynx_pcs_create_fwnode() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 07 Jun 2023 12:58:29 +0100 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add a helper to create a lynx PCS from a fwnode handle. Signed-off-by: Russell King (Oracle) --- drivers/net/pcs/pcs-lynx.c | 29 +++++++++++++++++++++++++++++ include/linux/pcs-lynx.h | 1 + 2 files changed, 30 insertions(+) diff --git a/drivers/net/pcs/pcs-lynx.c b/drivers/net/pcs/pcs-lynx.c index a90f74172f49..b0907c67d469 100644 --- a/drivers/net/pcs/pcs-lynx.c +++ b/drivers/net/pcs/pcs-lynx.c @@ -353,6 +353,35 @@ struct phylink_pcs *lynx_pcs_create_mdiodev(struct mii_bus *bus, int addr) } EXPORT_SYMBOL(lynx_pcs_create_mdiodev); +struct phylink_pcs *lynx_pcs_create_fwnode(struct fwnode_handle *node) +{ + struct mdio_device *mdio; + struct phylink_pcs *pcs; + + mdio = fwnode_mdio_find_device(node); + if (!mdio) + return ERR_PTR(-EPROBE_DEFER); + + pcs = lynx_pcs_create(mdio); + + /* Convert failure to create the PCS to an error pointer, so this + * function has a consistent return value strategy. + */ + if (!pcs) + pcs = ERR_PTR(-ENOMEM); + + /* lynx_create() has taken a refcount on the mdiodev if it was + * successful. If lynx_create() fails, this will free the mdio + * device here. In any case, we don't need to hold our reference + * anymore, and putting it here will allow mdio_device_put() in + * lynx_destroy() to automatically free the mdio device. + */ + mdio_device_put(mdio); + + return pcs; +} +EXPORT_SYMBOL_GPL(lynx_pcs_create_fwnode); + void lynx_pcs_destroy(struct phylink_pcs *pcs) { struct lynx_pcs *lynx = phylink_pcs_to_lynx(pcs); diff --git a/include/linux/pcs-lynx.h b/include/linux/pcs-lynx.h index 25f68a096bfe..123e813df771 100644 --- a/include/linux/pcs-lynx.h +++ b/include/linux/pcs-lynx.h @@ -11,6 +11,7 @@ struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio); struct phylink_pcs *lynx_pcs_create_mdiodev(struct mii_bus *bus, int addr); +struct phylink_pcs *lynx_pcs_create_fwnode(struct fwnode_handle *node); void lynx_pcs_destroy(struct phylink_pcs *pcs); From patchwork Wed Jun 7 11:58:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13270560 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 734A67488 for ; Wed, 7 Jun 2023 11:58:57 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD9FB1BFB for ; Wed, 7 Jun 2023 04:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=N2nTmqNGwMWGzJNM0Dewi4A1UPfxyq2EXhFIVh+vr8g=; b=MA7n8IV+gPElE2i7+KvKkm2iHj KYWtD/Y+RjGfRNspMeBffTeh+i2OH3KVfdV6n+CBf8gFR7SNb4GMHS/alIY270bg0rC35Us68EFoj c6h5v+OJPa85AEQaYkRP25hkw4f8YS57Req+4xtrfHoS0T2wfyqHmP1ayl/5vCgAVJ8BP9/1FMGiB bKTUGXlSbzlHuuUIM2BMf8BooN2jwXWlzve9S50JHfOBL/1pcrjdaDr1F+P0VND+YFkejGcBDebjC hjLsvZW0kdfxLZWHaiKVAGFaOLWTbRRzCZOpPZgRKe5YZsqhJqjjStCSzVsysqygr3SphUZ/VxZYT Y0+0MhmA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44814 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6roA-0007Lh-TW; Wed, 07 Jun 2023 12:58:34 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q6roA-00CfaU-9F; Wed, 07 Jun 2023 12:58:34 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Ioana Ciornei , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org, Paolo Abeni , Sean Anderson Subject: [PATCH net-next v2 05/11] net: dpaa2-mac: use lynx_pcs_create_fwnode() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 07 Jun 2023 12:58:34 +0100 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Use lynx_pcs_create_fwnode() to create a lynx PCS from a fwnode handle. Signed-off-by: Russell King (Oracle) --- .../net/ethernet/freescale/dpaa2/dpaa2-mac.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index c0f7dd3b4ac1..38e6208f9e1a 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -247,8 +247,8 @@ static int dpaa2_pcs_create(struct dpaa2_mac *mac, struct fwnode_handle *dpmac_node, int id) { - struct mdio_device *mdiodev; struct fwnode_handle *node; + struct phylink_pcs *pcs; node = fwnode_find_reference(dpmac_node, "pcs-handle", 0); if (IS_ERR(node)) { @@ -263,20 +263,22 @@ static int dpaa2_pcs_create(struct dpaa2_mac *mac, return -ENODEV; } - mdiodev = fwnode_mdio_find_device(node); + pcs = lynx_pcs_create_fwnode(node); fwnode_handle_put(node); - if (!mdiodev) { + + if (pcs == ERR_PTR(-EPROBE_DEFER)) { netdev_dbg(mac->net_dev, "missing PCS device\n"); return -EPROBE_DEFER; } - mac->pcs = lynx_pcs_create(mdiodev); - mdio_device_put(mdiodev); - if (!mac->pcs) { - netdev_err(mac->net_dev, "lynx_pcs_create() failed\n"); - return -ENOMEM; + if (IS_ERR(pcs)) { + netdev_err(mac->net_dev, + "lynx_pcs_create_fwnode() failed: %pe\n", pcs); + return PTR_ERR(pcs); } + mac->pcs = pcs; + return 0; } From patchwork Wed Jun 7 11:58:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13270561 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B85F47488 for ; Wed, 7 Jun 2023 11:59:02 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E8971BE2 for ; Wed, 7 Jun 2023 04:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HQhW/Hts9r3Kh+Zsi5qaq9C+CeI+sWFaMco1KSADJRo=; b=qhHf+PzfW/Dl5xDfw52ESVigyO YpiTpw5DSP1aSKSrd2oubrCAybVdHfKx7JeM9HY19TJMWehtmgA/ihresw2P2AEUBF9PktzuMOr+s mvlsgl2Qwbl9dBuo3Z4WEwAlFCuAqTeAGPuoLtn6vIwlerK/SSdBY+9kZsCV0uev8DXY/pyg5YUNt 78qJds1LfvEy8hO28GclXz8MwIYcqiLNx0tDcmGtK8bk7O3yJryPPPpQKqAotGrWgh+ROSP/iV4fg Ra0jY5/wik4b4P9uadkIt8jwGmZVRkbI0CHiI6w0KDab7qBCud/WLWMRDBrpEBNfq15tmct/RVHXA dSrj3E9A==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:55494 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6roG-0007ME-0M; Wed, 07 Jun 2023 12:58:40 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q6roF-00Cfac-D1; Wed, 07 Jun 2023 12:58:39 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Ioana Ciornei , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org, Paolo Abeni , Sean Anderson Subject: [PATCH net-next v2 06/11] net: fman_memac: use lynx_pcs_create_fwnode() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 07 Jun 2023 12:58:39 +0100 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Use lynx_pcs_create_fwnode() to create a lynx PCS from a fwnode handle. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/freescale/fman/fman_memac.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c index 8f45caf4af12..4fbdae996d05 100644 --- a/drivers/net/ethernet/freescale/fman/fman_memac.c +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c @@ -1039,19 +1039,14 @@ static struct phylink_pcs *memac_pcs_create(struct device_node *mac_node, int index) { struct device_node *node; - struct mdio_device *mdiodev = NULL; struct phylink_pcs *pcs; node = of_parse_phandle(mac_node, "pcsphy-handle", index); - if (node && of_device_is_available(node)) - mdiodev = of_mdio_find_device(node); - of_node_put(node); - - if (!mdiodev) - return ERR_PTR(-EPROBE_DEFER); + if (!node || !of_device_is_available(node)) + return ERR_PTR(-ENODEV); - pcs = lynx_pcs_create(mdiodev); - mdio_device_put(mdiodev); + pcs = lynx_pcs_create_fwnode(of_fwnode_handle(node)); + of_node_put(node); return pcs; } From patchwork Wed Jun 7 11:58:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13270562 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D42D7488 for ; Wed, 7 Jun 2023 11:59:08 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED4881FDE for ; Wed, 7 Jun 2023 04:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5Yri5zTLMwqtY189y122EOnnzmFonxPfU7xL3miev/k=; b=CPx/htQGv81tyuwhMmiFi7aorj Si+BSN/OUuM5sLvpFmaVQ774T1x3HqKdJkAEwGW5cjoz+j23Cfy91kFYBxBkzpye8hwx1lKLAdPHu fpqbgCOPeyEaw+DMzvsy1UswlGTRnflrb5WCRvpfIGtoyKcNZFMGvYY7y5R8kItk4uOMYSI7hqBwk 9Dgh4M1CG4q/j4saUJ5zE1QpftvhqwQKNkpDerEEDqFxoeLnJz8PXyLIzzhSVbz9Swu71Sic2cU0+ GAK6xHjEehL/EL6+BdeVRhyQzFskxMSCjUdIvxEbXQKzeTDkSjeFHuhk+oTKW9JB5J0mUGi4rkv7S W/SS+NMg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:55500 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6roL-0007MU-3f; Wed, 07 Jun 2023 12:58:45 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q6roK-00Cfai-Gf; Wed, 07 Jun 2023 12:58:44 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Ioana Ciornei , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org, Paolo Abeni , Sean Anderson Subject: [PATCH net-next v2 07/11] net: pcs: lynx: make lynx_pcs_create() static Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 07 Jun 2023 12:58:44 +0100 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org We no longer need to export lynx_pcs_create() for drivers to use as we now have all the functionality we need in the two new creation helpers. Remove the export and prototype, and make it static. Signed-off-by: Russell King (Oracle) --- drivers/net/pcs/pcs-lynx.c | 3 +-- include/linux/pcs-lynx.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/pcs/pcs-lynx.c b/drivers/net/pcs/pcs-lynx.c index b0907c67d469..b8c66137e28d 100644 --- a/drivers/net/pcs/pcs-lynx.c +++ b/drivers/net/pcs/pcs-lynx.c @@ -307,7 +307,7 @@ static const struct phylink_pcs_ops lynx_pcs_phylink_ops = { .pcs_link_up = lynx_pcs_link_up, }; -struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio) +static struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio) { struct lynx_pcs *lynx; @@ -322,7 +322,6 @@ struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio) return lynx_to_phylink_pcs(lynx); } -EXPORT_SYMBOL(lynx_pcs_create); struct phylink_pcs *lynx_pcs_create_mdiodev(struct mii_bus *bus, int addr) { diff --git a/include/linux/pcs-lynx.h b/include/linux/pcs-lynx.h index 123e813df771..7958cccd16f2 100644 --- a/include/linux/pcs-lynx.h +++ b/include/linux/pcs-lynx.h @@ -9,7 +9,6 @@ #include #include -struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio); struct phylink_pcs *lynx_pcs_create_mdiodev(struct mii_bus *bus, int addr); struct phylink_pcs *lynx_pcs_create_fwnode(struct fwnode_handle *node); From patchwork Wed Jun 7 11:58:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13270563 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F14C3445A for ; Wed, 7 Jun 2023 11:59:09 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26F011BD9 for ; Wed, 7 Jun 2023 04:58:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2yNodawdrBoK9j42w1NAjw0rxU0GUGNTc4kJukpmkmw=; b=IM6BwlxUVtOPGdM5E2I2XrELb5 HXcZ6+VbO6SV1vqK753ZORUqkmcwcX//k6pCnQ3XwFSCiUOMkajWxFIp6gg5SEgCQW95LeRt6TOh4 6lbibufi8Asb/U0U/qfRd2Hz0/mWcPcygDRJ5UNiIm35BuXKmrdyzl3gAKyBNefQS4+X1bTpvxJXb gyIT8b9NrgCcC64vbRcOoF5XeSTM6NowFeO3H7y7lH2AcBTq3KJf4GeC7LJPVIBBJd7FfHkn+ovc/ ORupryCH6TtHq4PnEdnMy2OOaI9IqrXdXB41jnZX/SZh3G1NjCHUT7O5EuqQR+CjUKG9rW12MT+Ns sBcaf04A==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44396 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6roQ-0007Mi-6n; Wed, 07 Jun 2023 12:58:50 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q6roP-00Cfao-KJ; Wed, 07 Jun 2023 12:58:49 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Ioana Ciornei , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org, Paolo Abeni , Sean Anderson Subject: [PATCH net-next v2 08/11] net: pcs: lynx: change lynx_pcs_create() to return error-pointers Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 07 Jun 2023 12:58:49 +0100 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Change lynx_pcs_create() to return an error-pointer on failure to allocate memory, rather than returning NULL. This allows the removal of the conversion in lynx_pcs_create_fwnode() and lynx_pcs_create_mdiodev(). Signed-off-by: Russell King (Oracle) --- drivers/net/pcs/pcs-lynx.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/net/pcs/pcs-lynx.c b/drivers/net/pcs/pcs-lynx.c index b8c66137e28d..c2d01da40430 100644 --- a/drivers/net/pcs/pcs-lynx.c +++ b/drivers/net/pcs/pcs-lynx.c @@ -313,7 +313,7 @@ static struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio) lynx = kzalloc(sizeof(*lynx), GFP_KERNEL); if (!lynx) - return NULL; + return ERR_PTR(-ENOMEM); mdio_device_get(mdio); lynx->mdio = mdio; @@ -334,12 +334,6 @@ struct phylink_pcs *lynx_pcs_create_mdiodev(struct mii_bus *bus, int addr) pcs = lynx_pcs_create(mdio); - /* Convert failure to create the PCS to an error pointer, so this - * function has a consistent return value strategy. - */ - if (!pcs) - pcs = ERR_PTR(-ENOMEM); - /* lynx_create() has taken a refcount on the mdiodev if it was * successful. If lynx_create() fails, this will free the mdio * device here. In any case, we don't need to hold our reference @@ -363,12 +357,6 @@ struct phylink_pcs *lynx_pcs_create_fwnode(struct fwnode_handle *node) pcs = lynx_pcs_create(mdio); - /* Convert failure to create the PCS to an error pointer, so this - * function has a consistent return value strategy. - */ - if (!pcs) - pcs = ERR_PTR(-ENOMEM); - /* lynx_create() has taken a refcount on the mdiodev if it was * successful. If lynx_create() fails, this will free the mdio * device here. In any case, we don't need to hold our reference From patchwork Wed Jun 7 11:58:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13270564 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AE6633CAA for ; Wed, 7 Jun 2023 11:59:10 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F3C01BEC for ; Wed, 7 Jun 2023 04:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CTbswC2wAt+WpcUwJOtfJtor9aQJUnA5Fs3Pr42utho=; b=kEBUe5Cer46bqRDHmjMc6oBrDv /368AWMDxG3d/+G9ztTyNryOgDjOjtI8VqHatXOdyFx6aXrjR97rpbI1o5G4r/ABOrQN0az3xEmPo qgrydJNibQfueL7xNsdAcwz0nPwjn5ye/ZaPCn7d9+4KXrQRjgnkwiCs9dXRtz3kbKsaiRxfhV7Hv eQN6PBuAHeUq+cwzFIA6p/NPN4WtD1ZQzCFRFsKGin93HyhBLJlLBjqj+PQ4i7YB0lZX/H6rouFFZ 9zAlPb64LqTkCOZ4oTDoEIert+BQjlSsJYmGKVa/nO2s5IwvWP0JwqPqIN6GqKBQ54rCiKcmUjM73 0aA2uhpQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44402 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6roV-0007Mx-9x; Wed, 07 Jun 2023 12:58:55 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q6roU-00Cfau-NF; Wed, 07 Jun 2023 12:58:54 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Ioana Ciornei , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org, Paolo Abeni , Sean Anderson Subject: [PATCH net-next v2 09/11] net: pcs: lynx: check that the fwnode is available prior to use Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 07 Jun 2023 12:58:54 +0100 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Check that the fwnode is marked as available prior to trying to lookup the PCS device, and return -ENODEV if unavailable. Document the return codes from lynx_pcs_create_fwnode(). Signed-off-by: Russell King (Oracle) --- drivers/net/pcs/pcs-lynx.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/pcs/pcs-lynx.c b/drivers/net/pcs/pcs-lynx.c index c2d01da40430..fca48ebf0b81 100644 --- a/drivers/net/pcs/pcs-lynx.c +++ b/drivers/net/pcs/pcs-lynx.c @@ -6,6 +6,7 @@ #include #include #include +#include #define SGMII_CLOCK_PERIOD_NS 8 /* PCS is clocked at 125 MHz */ #define LINK_TIMER_VAL(ns) ((u32)((ns) / SGMII_CLOCK_PERIOD_NS)) @@ -346,11 +347,24 @@ struct phylink_pcs *lynx_pcs_create_mdiodev(struct mii_bus *bus, int addr) } EXPORT_SYMBOL(lynx_pcs_create_mdiodev); +/* + * lynx_pcs_create_fwnode() creates a lynx PCS instance from the fwnode + * device indicated by node. + * + * Returns: + * -ENODEV if the fwnode is marked unavailable + * -EPROBE_DEFER if we fail to find the device + * -ENOMEM if we fail to allocate memory + * pointer to a phylink_pcs on success + */ struct phylink_pcs *lynx_pcs_create_fwnode(struct fwnode_handle *node) { struct mdio_device *mdio; struct phylink_pcs *pcs; + if (!fwnode_device_is_available(node)) + return ERR_PTR(-ENODEV); + mdio = fwnode_mdio_find_device(node); if (!mdio) return ERR_PTR(-EPROBE_DEFER); From patchwork Wed Jun 7 11:58:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13270565 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22FCF33CAA for ; Wed, 7 Jun 2023 11:59:14 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D0961BF0 for ; Wed, 7 Jun 2023 04:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cagB9HkYNCjDvU0Ds67MN7diWiRA2eRFcBXfjV/Krrw=; b=p8S/MuGQ7CjkfeV0qcB0yVKlLf uPgokmiSl1lLiU8ENlUHahh03d3bV6I1p3he3Tbst8aL7NdVPm3mO0UyjFww4u6Xyl2xs0lZ8MLyV bQs1TlqIF5pIkWLVB6o5PZDJh1ld6Q47yNHqgI47SjrLPAnuaGyHOgJA3kcez+8qKOuTnTZDQs4hx 3KdWjrbTh1nEXNuKmkUk24wLhToMTJkH+O9HSAIveFBj6JxbJextKtb++TBWF5peiRqtm38DXNLG/ 66cQYXfNBchs0wOxGPlIg9JIPUhAQJX0FUUxG3wXUgZhvwrwJk26VpXK2iTs96UlQ2AI/jhbTVqjR 1eaAbazA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:47176 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6roa-0007ND-Cw; Wed, 07 Jun 2023 12:59:00 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q6roZ-00Cfb0-QA; Wed, 07 Jun 2023 12:58:59 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Ioana Ciornei , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org, Paolo Abeni , Sean Anderson Subject: [PATCH net-next v2 10/11] net: dpaa2: use pcs-lynx's check for fwnode availability Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 07 Jun 2023 12:58:59 +0100 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Use pcs-lynx's check rather than our own when determining if the device is available. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 38e6208f9e1a..d860d9fe73af 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -257,12 +257,6 @@ static int dpaa2_pcs_create(struct dpaa2_mac *mac, return 0; } - if (!fwnode_device_is_available(node)) { - netdev_err(mac->net_dev, "pcs-handle node not available\n"); - fwnode_handle_put(node); - return -ENODEV; - } - pcs = lynx_pcs_create_fwnode(node); fwnode_handle_put(node); @@ -271,6 +265,11 @@ static int dpaa2_pcs_create(struct dpaa2_mac *mac, return -EPROBE_DEFER; } + if (pcs == ERR_PTR(-ENODEV)) { + netdev_err(mac->net_dev, "pcs-handle node not available\n"); + return PTR_ERR(pcs); + } + if (IS_ERR(pcs)) { netdev_err(mac->net_dev, "lynx_pcs_create_fwnode() failed: %pe\n", pcs); From patchwork Wed Jun 7 11:59:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13270566 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5AD633C86 for ; Wed, 7 Jun 2023 11:59:22 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55FCF1BD8 for ; Wed, 7 Jun 2023 04:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NHDIoX7XSuEhtcjBSj36oTpLvD2AfY5ZCtScnFjDg+8=; b=AskZKrc+WPjpu+t4AdbeWyP0tK dSixdJvcKsD0PMGTc+7lzCtIiBbE+U3Q3O+48YtUEXFe7FIZyAHWVTTAAoefgPYrZGdAo+u6ls+Kp YB6/G1EDXuULoXG4Rlw3blWxH+1EYHbIM+YIay178s/rp81Drefu1w1+dZmOylPBByTTjr3TlXzSm NxCc6uOH4uMrfKz3v7KxGNSllXiYsqKvoD67ckdXS4thJWeu1jA2bhWZKIeGRlKC4DZbOmHtFmxqD vKsO4jQvPzd88zXdusy9Njsn1lHDwy9QmB6Az5ZvlrNcKcGMnmXNY2l9H1uLZNe+f4HOBc7wcpmp7 oCysdpvw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:47188 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q6rof-0007NW-Gi; Wed, 07 Jun 2023 12:59:05 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1q6roe-00Cfb6-TS; Wed, 07 Jun 2023 12:59:04 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: "David S. Miller" , Eric Dumazet , Ioana Ciornei , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org, Paolo Abeni , Sean Anderson Subject: [PATCH net-next v2 11/11] net: fman_memac: use pcs-lynx's check for fwnode availability Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 07 Jun 2023 12:59:04 +0100 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Use pcs-lynx's check rather than our own when determining if the device is available. This fixes a bug where the reference gained by of_parse_phandle() is not dropped if the device is not available. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/freescale/fman/fman_memac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c index 4fbdae996d05..3b75cc543be9 100644 --- a/drivers/net/ethernet/freescale/fman/fman_memac.c +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c @@ -1042,7 +1042,7 @@ static struct phylink_pcs *memac_pcs_create(struct device_node *mac_node, struct phylink_pcs *pcs; node = of_parse_phandle(mac_node, "pcsphy-handle", index); - if (!node || !of_device_is_available(node)) + if (!node) return ERR_PTR(-ENODEV); pcs = lynx_pcs_create_fwnode(of_fwnode_handle(node));