Commit 05b606b8 authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by Jakub Kicinski

net: pcs: lynx: change lynx_pcs_create() to return error-pointers

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: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 84e476b8
...@@ -313,7 +313,7 @@ static struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio) ...@@ -313,7 +313,7 @@ static struct phylink_pcs *lynx_pcs_create(struct mdio_device *mdio)
lynx = kzalloc(sizeof(*lynx), GFP_KERNEL); lynx = kzalloc(sizeof(*lynx), GFP_KERNEL);
if (!lynx) if (!lynx)
return NULL; return ERR_PTR(-ENOMEM);
mdio_device_get(mdio); mdio_device_get(mdio);
lynx->mdio = mdio; lynx->mdio = mdio;
...@@ -334,12 +334,6 @@ struct phylink_pcs *lynx_pcs_create_mdiodev(struct mii_bus *bus, int addr) ...@@ -334,12 +334,6 @@ struct phylink_pcs *lynx_pcs_create_mdiodev(struct mii_bus *bus, int addr)
pcs = lynx_pcs_create(mdio); 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 /* lynx_create() has taken a refcount on the mdiodev if it was
* successful. If lynx_create() fails, this will free the mdio * successful. If lynx_create() fails, this will free the mdio
* device here. In any case, we don't need to hold our reference * 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) ...@@ -363,12 +357,6 @@ struct phylink_pcs *lynx_pcs_create_fwnode(struct fwnode_handle *node)
pcs = lynx_pcs_create(mdio); 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 /* lynx_create() has taken a refcount on the mdiodev if it was
* successful. If lynx_create() fails, this will free the mdio * successful. If lynx_create() fails, this will free the mdio
* device here. In any case, we don't need to hold our reference * device here. In any case, we don't need to hold our reference
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment