Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phylib: add link_change_notify callback to phy device

Add a notify callback to inform phy drivers when the core is about to
do its link adjustment. No change for drivers that do not implement
this callback.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Daniel Mack and committed by
David S. Miller
2b8f2a28 916c1689

+12
+3
drivers/net/phy/phy.c
··· 720 720 721 721 mutex_lock(&phydev->lock); 722 722 723 + if (phydev->drv->link_change_notify) 724 + phydev->drv->link_change_notify(phydev); 725 + 723 726 switch (phydev->state) { 724 727 case PHY_DOWN: 725 728 case PHY_STARTING:
+9
include/linux/phy.h
··· 536 536 /* See set_wol, but for checking whether Wake on LAN is enabled. */ 537 537 void (*get_wol)(struct phy_device *dev, struct ethtool_wolinfo *wol); 538 538 539 + /* 540 + * Called to inform a PHY device driver when the core is about to 541 + * change the link state. This callback is supposed to be used as 542 + * fixup hook for drivers that need to take action when the link 543 + * state changes. Drivers are by no means allowed to mess with the 544 + * PHY device structure in their implementations. 545 + */ 546 + void (*link_change_notify)(struct phy_device *dev); 547 + 539 548 struct device_driver driver; 540 549 }; 541 550 #define to_phy_driver(d) container_of(d, struct phy_driver, driver)