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

net: mdio: introduce a shutdown method to mdio device drivers

MDIO-attached devices might have interrupts and other things that might
need quiesced when we kexec into a new kernel. Things are even more
creepy when those interrupt lines are shared, and in that case it is
absolutely mandatory to disable all interrupt sources.

Moreover, MDIO devices might be DSA switches, and DSA needs its own
shutdown method to unlink from the DSA master, which is a new
requirement that appeared after commit 2f1e8ea726e9 ("net: dsa: link
interfaces with the DSA master to get rid of lockdep warnings").

So introduce a ->shutdown method in the MDIO device driver structure.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vladimir Oltean and committed by
David S. Miller
cf957997 02319bf1

+14
+11
drivers/net/phy/mdio_device.c
··· 179 179 return 0; 180 180 } 181 181 182 + static void mdio_shutdown(struct device *dev) 183 + { 184 + struct mdio_device *mdiodev = to_mdio_device(dev); 185 + struct device_driver *drv = mdiodev->dev.driver; 186 + struct mdio_driver *mdiodrv = to_mdio_driver(drv); 187 + 188 + if (mdiodrv->shutdown) 189 + mdiodrv->shutdown(mdiodev); 190 + } 191 + 182 192 /** 183 193 * mdio_driver_register - register an mdio_driver with the MDIO layer 184 194 * @drv: new mdio_driver to register ··· 203 193 mdiodrv->driver.bus = &mdio_bus_type; 204 194 mdiodrv->driver.probe = mdio_probe; 205 195 mdiodrv->driver.remove = mdio_remove; 196 + mdiodrv->driver.shutdown = mdio_shutdown; 206 197 207 198 retval = driver_register(&mdiodrv->driver); 208 199 if (retval) {
+3
include/linux/mdio.h
··· 80 80 81 81 /* Clears up any memory if needed */ 82 82 void (*remove)(struct mdio_device *mdiodev); 83 + 84 + /* Quiesces the device on system shutdown, turns off interrupts etc */ 85 + void (*shutdown)(struct mdio_device *mdiodev); 83 86 }; 84 87 85 88 static inline struct mdio_driver *