Re: [PATCH] net: dsa: Fix conditional handling of Wake-on-Lan configuration in dsa_user_set_wol

From: Mohammed Anees
Date: Sat Oct 05 2024 - 14:43:08 EST


In the original code, we initialize ret = -EOPNOTSUPP and then call
phylink_ethtool_set_wol(). If DSA supports WOL, we call set_wol().
However, we aren’t checking if phylink_ethtool_set_wol() succeeds,
so I assumed both functions should be called, and if either fails,
we return -EOPNOTSUPP.


static int dsa_user_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
{
struct dsa_port *dp = dsa_user_to_port(dev);
struct dsa_switch *ds = dp->ds;
int ret = -EOPNOTSUPP;

phylink_ethtool_set_wol(dp->pl, w);

if (ds->ops->set_wol)
ret = ds->ops->set_wol(ds, dp->index, w);

return ret;
}

>From your response, it seems either of the two function can handle setting
WOL, if so shouldn't we check the return value of phylink_ethtool_set_wol()
to ensure it succeeds?

Thanks!