]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: pcs: xpcs: Return EINVAL in the internal methods
authorSerge Semin <fancer.lancer@gmail.com>
Thu, 22 Feb 2024 17:58:22 +0000 (20:58 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 26 Feb 2024 13:09:08 +0000 (13:09 +0000)
In particular the xpcs_soft_reset() and xpcs_do_config() functions
currently return -1 if invalid auto-negotiation mode is specified. That
value might be then passed to the generic kernel subsystems which require
a standard kernel errno value. Even though the erroneous conditions are
very specific (memory corruption or buggy driver implementation) using a
hard-coded -1 literal doesn't seem correct anyway especially when it comes
to passing it higher to the network subsystem or printing to the system
log.  Convert the hard-coded error values to -EINVAL then.

Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
Tested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/pcs/pcs-xpcs.c

index 6060f1cc669916ff052bfa2eaf01a11a05399a67..02262af336c4c78e64918a9f08f791d388494228 100644 (file)
@@ -292,7 +292,7 @@ static int xpcs_soft_reset(struct dw_xpcs *xpcs,
                dev = MDIO_MMD_VEND2;
                break;
        default:
-               return -1;
+               return -EINVAL;
        }
 
        ret = xpcs_write(xpcs, dev, MDIO_CTRL1, MDIO_CTRL1_RESET);
@@ -889,7 +889,7 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface,
                        return ret;
                break;
        default:
-               return -1;
+               return -EINVAL;
        }
 
        if (compat->pma_config) {