drivers/net/phy/mii_timestamper.c
Source file repositories/reference/linux-study-clean/drivers/net/phy/mii_timestamper.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/phy/mii_timestamper.c- Extension
.c- Size
- 3622 bytes
- Lines
- 136
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/mii_timestamper.h
Detected Declarations
struct mii_timestamping_descfunction register_mii_tstamp_controllerfunction unregister_mii_tstamp_controllerfunction unregister_mii_timestamperexport register_mii_tstamp_controllerexport unregister_mii_tstamp_controllerexport register_mii_timestamperexport unregister_mii_timestamper
Annotated Snippet
struct mii_timestamping_desc {
struct list_head list;
struct mii_timestamping_ctrl *ctrl;
struct device *device;
};
/**
* register_mii_tstamp_controller() - registers an MII time stamping device.
*
* @device: The device to be registered.
* @ctrl: Pointer to device's control interface.
*
* Returns zero on success or non-zero on failure.
*/
int register_mii_tstamp_controller(struct device *device,
struct mii_timestamping_ctrl *ctrl)
{
struct mii_timestamping_desc *desc;
desc = kzalloc_obj(*desc);
if (!desc)
return -ENOMEM;
INIT_LIST_HEAD(&desc->list);
desc->ctrl = ctrl;
desc->device = device;
mutex_lock(&tstamping_devices_lock);
list_add_tail(&mii_timestamping_devices, &desc->list);
mutex_unlock(&tstamping_devices_lock);
return 0;
}
EXPORT_SYMBOL(register_mii_tstamp_controller);
/**
* unregister_mii_tstamp_controller() - unregisters an MII time stamping device.
*
* @device: A device previously passed to register_mii_tstamp_controller().
*/
void unregister_mii_tstamp_controller(struct device *device)
{
struct mii_timestamping_desc *desc;
struct list_head *this, *next;
mutex_lock(&tstamping_devices_lock);
list_for_each_safe(this, next, &mii_timestamping_devices) {
desc = list_entry(this, struct mii_timestamping_desc, list);
if (desc->device == device) {
list_del_init(&desc->list);
kfree(desc);
break;
}
}
mutex_unlock(&tstamping_devices_lock);
}
EXPORT_SYMBOL(unregister_mii_tstamp_controller);
/**
* register_mii_timestamper - Enables a given port of an MII time stamper.
*
* @node: The device tree node of the MII time stamp controller.
* @port: The index of the port to be enabled.
*
* Returns a valid interface on success or ERR_PTR otherwise.
*/
struct mii_timestamper *register_mii_timestamper(struct device_node *node,
unsigned int port)
{
struct mii_timestamper *mii_ts = NULL;
struct mii_timestamping_desc *desc;
struct list_head *this;
mutex_lock(&tstamping_devices_lock);
list_for_each(this, &mii_timestamping_devices) {
desc = list_entry(this, struct mii_timestamping_desc, list);
if (desc->device->of_node == node) {
mii_ts = desc->ctrl->probe_channel(desc->device, port);
if (!IS_ERR(mii_ts)) {
mii_ts->device = desc->device;
get_device(desc->device);
}
break;
}
}
mutex_unlock(&tstamping_devices_lock);
return mii_ts ? mii_ts : ERR_PTR(-EPROBE_DEFER);
}
EXPORT_SYMBOL(register_mii_timestamper);
Annotation
- Immediate include surface: `linux/mii_timestamper.h`.
- Detected declarations: `struct mii_timestamping_desc`, `function register_mii_tstamp_controller`, `function unregister_mii_tstamp_controller`, `function unregister_mii_timestamper`, `export register_mii_tstamp_controller`, `export unregister_mii_tstamp_controller`, `export register_mii_timestamper`, `export unregister_mii_timestamper`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.