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

From: Andrew Lunn
Date: Sun Oct 06 2024 - 15:57:48 EST


On Sun, Oct 06, 2024 at 09:40:32PM +0530, Mohammed Anees wrote:
> Considering the insight you've provided, I've written the code below
>
> 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;
>
> ret = phylink_ethtool_set_wol(dp->pl, w);
>
> if (ret != -EOPNOTSUPP)
> return ret;
>
> if (ds->ops->set_wol)
> ret = ds->ops->set_wol(ds, dp->index, w);
> if (ret != -EOPNOTSUPP)
> return ret;

This can be simplified to just:

> if (ds->ops->set_wol)
> return ds->ops->set_wol(ds, dp->index, w);
>
> return -EOPNOTSUPP;
> }

Andrew