Message ID | 20240222175843.26919-5-fancer.lancer@gmail.com |
---|---|
State | New |
Headers | show |
Series | net: pcs: xpcs: Cleanups before adding MMIO dev support | expand |
Hello Serge, On Thu, 22 Feb 2024 20:58:23 +0300 Serge Semin <fancer.lancer@gmail.com> wrote: > If an unsupported interface is passed to the PCS validation callback there > is no need in further link-modes calculations since the resultant array > will be initialized with zeros which will be perceived by the phylink > subsystem as error anyway (see phylink_validate_mac_and_pcs()). Instead > let's explicitly return the -EINVAL error to inform the caller about the > unsupported interface as it's done in the rest of the pcs_validate > callbacks. > > Signed-off-by: Serge Semin <fancer.lancer@gmail.com> This looks good to me, Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 92c47da61db4..46afeb5510c0 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -613,14 +613,15 @@ static int xpcs_validate(struct phylink_pcs *pcs, unsigned long *supported, xpcs = phylink_pcs_to_xpcs(pcs); compat = xpcs_find_compat(xpcs->id, state->interface); + if (!compat) + return -EINVAL; /* Populate the supported link modes for this PHY interface type. * FIXME: what about the port modes and autoneg bit? This masks * all those away. */ - if (compat) - for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) - set_bit(compat->supported[i], xpcs_supported); + for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) + set_bit(compat->supported[i], xpcs_supported); linkmode_and(supported, supported, xpcs_supported);
If an unsupported interface is passed to the PCS validation callback there is no need in further link-modes calculations since the resultant array will be initialized with zeros which will be perceived by the phylink subsystem as error anyway (see phylink_validate_mac_and_pcs()). Instead let's explicitly return the -EINVAL error to inform the caller about the unsupported interface as it's done in the rest of the pcs_validate callbacks. Signed-off-by: Serge Semin <fancer.lancer@gmail.com> --- drivers/net/pcs/pcs-xpcs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)