Skip to content

Commit aeb4e91

Browse files
oleremNipaLocal
authored andcommitted
net: usb: lan78xx: Improve error handling in WoL operations
Enhance error handling in Wake-on-LAN (WoL) operations: - Log a warning in `lan78xx_get_wol` if `lan78xx_read_reg` fails. - Check and handle errors from `device_set_wakeup_enable` and `phy_ethtool_set_wol` in `lan78xx_set_wol`. - Ensure proper cleanup with a unified error handling path. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: NipaLocal <nipa@local>
1 parent dc46d65 commit aeb4e91

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,7 @@ static void lan78xx_get_wol(struct net_device *netdev,
18571857

18581858
ret = lan78xx_read_reg(dev, USB_CFG0, &buf);
18591859
if (unlikely(ret < 0)) {
1860+
netdev_warn(dev->net, "failed to get WoL %pe", ERR_PTR(ret));
18601861
wol->supported = 0;
18611862
wol->wolopts = 0;
18621863
} else {
@@ -1888,10 +1889,13 @@ static int lan78xx_set_wol(struct net_device *netdev,
18881889

18891890
pdata->wol = wol->wolopts;
18901891

1891-
device_set_wakeup_enable(&dev->udev->dev, (bool)wol->wolopts);
1892+
ret = device_set_wakeup_enable(&dev->udev->dev, (bool)wol->wolopts);
1893+
if (ret < 0)
1894+
goto exit_pm_put;
18921895

1893-
phy_ethtool_set_wol(netdev->phydev, wol);
1896+
ret = phy_ethtool_set_wol(netdev->phydev, wol);
18941897

1898+
exit_pm_put:
18951899
usb_autopm_put_interface(dev->intf);
18961900

18971901
return ret;

0 commit comments

Comments
 (0)