diff options
author | Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | 2023-06-07 13:58:54 +0200 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-06-09 04:19:50 +0200 |
commit | d143898c6d7b7f9b171ddc76cd9a3d8356bfddd5 (patch) | |
tree | 3e674397977497c5c65df1f61fb5afba8462efb7 /drivers/net/pcs | |
parent | net: pcs: lynx: change lynx_pcs_create() to return error-pointers (diff) | |
download | linux-d143898c6d7b7f9b171ddc76cd9a3d8356bfddd5.tar.xz linux-d143898c6d7b7f9b171ddc76cd9a3d8356bfddd5.zip |
net: pcs: lynx: check that the fwnode is available prior to use
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>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/pcs')
-rw-r--r-- | drivers/net/pcs/pcs-lynx.c | 14 |
1 files changed, 14 insertions, 0 deletions
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); |