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

From: Mohammed Anees
Date: Fri Oct 04 2024 - 18:03:34 EST


The WOL configuration now checks if the DSA switch supports setting WOL
before attempting to apply settings via phylink. This prevents
unnecessary calls to phylink_ethtool_set_wol when WOL is not supported.

Signed-off-by: Mohammed Anees <pvmohammedanees2003@xxxxxxxxx>
---
net/dsa/user.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/dsa/user.c b/net/dsa/user.c
index 74eda9b30608..c685ccea9ddf 100644
--- a/net/dsa/user.c
+++ b/net/dsa/user.c
@@ -1217,10 +1217,12 @@ static int dsa_user_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
struct dsa_switch *ds = dp->ds;
int ret = -EOPNOTSUPP;

- phylink_ethtool_set_wol(dp->pl, w);
-
- if (ds->ops->set_wol)
+ if (ds->ops->set_wol) {
ret = ds->ops->set_wol(ds, dp->index, w);
+ if (ret)
+ return ret;
+ phylink_ethtool_set_wol(dp->pl, w);
+ }

return ret;
}
--
2.46.0