From: "Russell King (Oracle)" <rmk+kernel@armlinux•org.uk>
To: Andrew Lunn <andrew@lunn•ch>, Heiner Kallweit <hkallweit1@gmail•com>
Cc: "David S. Miller" <davem@davemloft•net>,
Eric Dumazet <edumazet@google•com>,
Ioana Ciornei <ioana.ciornei@nxp•com>,
Jakub Kicinski <kuba@kernel•org>,
Madalin Bucur <madalin.bucur@nxp•com>,
netdev@vger•kernel.org, Paolo Abeni <pabeni@redhat•com>,
Sean Anderson <sean.anderson@seco•com>
Subject: [PATCH net-next v2 09/11] net: pcs: lynx: check that the fwnode is available prior to use
Date: Wed, 07 Jun 2023 12:58:54 +0100 [thread overview]
Message-ID: <E1q6roU-00Cfau-NF@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <ZIBwuw+IuGQo5yV8@shell.armlinux.org.uk>
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) <rmk+kernel@armlinux•org.uk>
---
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 <linux/mdio.h>
#include <linux/phylink.h>
#include <linux/pcs-lynx.h>
+#include <linux/property.h>
#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);
--
2.30.2
next prev parent reply other threads:[~2023-06-07 11:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 11:57 [PATCH net-next v2 00/11] complete Lynx mdio device handling Russell King (Oracle)
2023-06-07 11:58 ` [PATCH net-next v2 01/11] net: dpaa2-mac: allow lynx PCS to manage mdiodev lifetime Russell King (Oracle)
2023-06-07 11:58 ` [PATCH net-next v2 02/11] net: fman_memac: allow lynx PCS to handle " Russell King (Oracle)
2023-06-07 11:58 ` [PATCH net-next v2 03/11] net: pcs: lynx: remove lynx_get_mdio_device() Russell King (Oracle)
2023-06-07 11:58 ` [PATCH net-next v2 04/11] net: pcs: lynx: add lynx_pcs_create_fwnode() Russell King (Oracle)
2023-06-07 11:58 ` [PATCH net-next v2 05/11] net: dpaa2-mac: use lynx_pcs_create_fwnode() Russell King (Oracle)
2023-06-07 11:58 ` [PATCH net-next v2 06/11] net: fman_memac: " Russell King (Oracle)
2023-06-07 11:58 ` [PATCH net-next v2 07/11] net: pcs: lynx: make lynx_pcs_create() static Russell King (Oracle)
2023-06-07 11:58 ` [PATCH net-next v2 08/11] net: pcs: lynx: change lynx_pcs_create() to return error-pointers Russell King (Oracle)
2023-06-07 11:58 ` Russell King (Oracle) [this message]
2023-06-07 11:58 ` [PATCH net-next v2 10/11] net: dpaa2: use pcs-lynx's check for fwnode availability Russell King (Oracle)
2023-06-07 11:59 ` [PATCH net-next v2 11/11] net: fman_memac: " Russell King (Oracle)
2023-06-09 2:30 ` [PATCH net-next v2 00/11] complete Lynx mdio device handling patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1q6roU-00Cfau-NF@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux$(echo .)org.uk \
--cc=andrew@lunn$(echo .)ch \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=hkallweit1@gmail$(echo .)com \
--cc=ioana.ciornei@nxp$(echo .)com \
--cc=kuba@kernel$(echo .)org \
--cc=madalin.bucur@nxp$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
--cc=sean.anderson@seco$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox