drivers/net/phy/mdio_device.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/mdio_device.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/mdio_device.c- Extension
.c- Size
- 7511 bytes
- Lines
- 317
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/errno.hlinux/gpio.hlinux/gpio/consumer.hlinux/init.hlinux/interrupt.hlinux/kernel.hlinux/mdio.hlinux/mii.hlinux/module.hlinux/phy.hlinux/reset.hlinux/slab.hlinux/string.hlinux/unistd.hlinux/property.hphylib-internal.h
Detected Declarations
function Copyrightfunction mdio_device_unregister_resetfunction mdio_device_resetfunction mdio_device_freefunction mdio_device_releasefunction mdio_device_registerfunction mdio_device_registerfunction mdiobus_register_devicefunction mdiobus_unregister_devicefunction mdio_probefunction mdio_removefunction mdio_shutdownfunction mdio_driver_registerfunction mdio_driver_unregisterexport mdio_device_resetexport mdio_device_freeexport mdio_device_createexport mdio_device_registerexport mdio_device_removeexport mdio_driver_registerexport mdio_driver_unregister
Annotated Snippet
struct device_driver *drv = mdiodev->dev.driver;
struct mdio_driver *mdiodrv = to_mdio_driver(drv);
int err = 0;
/* Deassert the reset signal */
mdio_device_reset(mdiodev, 0);
if (mdiodrv->probe) {
err = mdiodrv->probe(mdiodev);
if (err) {
/* Assert the reset signal */
mdio_device_reset(mdiodev, 1);
}
}
return err;
}
static int mdio_remove(struct device *dev)
{
struct mdio_device *mdiodev = to_mdio_device(dev);
struct device_driver *drv = mdiodev->dev.driver;
struct mdio_driver *mdiodrv = to_mdio_driver(drv);
if (mdiodrv->remove)
mdiodrv->remove(mdiodev);
/* Assert the reset signal */
mdio_device_reset(mdiodev, 1);
return 0;
}
static void mdio_shutdown(struct device *dev)
{
struct mdio_device *mdiodev = to_mdio_device(dev);
struct device_driver *drv = mdiodev->dev.driver;
struct mdio_driver *mdiodrv = to_mdio_driver(drv);
if (mdiodrv->shutdown)
mdiodrv->shutdown(mdiodev);
}
/**
* mdio_driver_register - register an mdio_driver with the MDIO layer
* @drv: new mdio_driver to register
*
* Return: Zero if successful, negative error code on failure
*/
int mdio_driver_register(struct mdio_driver *drv)
{
struct mdio_driver_common *mdiodrv = &drv->mdiodrv;
int retval;
pr_debug("%s: %s\n", __func__, mdiodrv->driver.name);
mdiodrv->driver.bus = &mdio_bus_type;
mdiodrv->driver.probe = mdio_probe;
mdiodrv->driver.remove = mdio_remove;
mdiodrv->driver.shutdown = mdio_shutdown;
retval = driver_register(&mdiodrv->driver);
if (retval) {
pr_err("%s: Error %d in registering driver\n",
mdiodrv->driver.name, retval);
return retval;
}
return 0;
}
EXPORT_SYMBOL(mdio_driver_register);
void mdio_driver_unregister(struct mdio_driver *drv)
{
struct mdio_driver_common *mdiodrv = &drv->mdiodrv;
driver_unregister(&mdiodrv->driver);
}
EXPORT_SYMBOL(mdio_driver_unregister);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/errno.h`, `linux/gpio.h`, `linux/gpio/consumer.h`, `linux/init.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mdio.h`.
- Detected declarations: `function Copyright`, `function mdio_device_unregister_reset`, `function mdio_device_reset`, `function mdio_device_free`, `function mdio_device_release`, `function mdio_device_register`, `function mdio_device_register`, `function mdiobus_register_device`, `function mdiobus_unregister_device`, `function mdio_probe`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.