drivers/phy/phy-core.c
Source file repositories/reference/linux-study-clean/drivers/phy/phy-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/phy/phy-core.c- Extension
.c- Size
- 31934 bytes
- Lines
- 1313
- Domain
- Driver Families
- Bucket
- drivers/phy
- 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/kernel.hlinux/export.hlinux/module.hlinux/err.hlinux/debugfs.hlinux/device.hlinux/slab.hlinux/of.hlinux/phy/phy.hlinux/idr.hlinux/pm_runtime.hlinux/regulator/consumer.h
Detected Declarations
function devm_phy_releasefunction devm_phy_provider_releasefunction devm_phy_consumefunction devm_phy_matchfunction phy_create_lookupfunction phy_remove_lookupfunction list_for_each_entryfunction phy_pm_runtime_getfunction phy_pm_runtime_get_syncfunction phy_pm_runtime_putfunction phy_pm_runtime_put_syncfunction phy_power_onfunction phy_power_offfunction phy_initfunction phy_exitfunction phy_set_mode_extfunction phy_set_mediafunction phy_set_speedfunction phy_resetfunction phy_calibratefunction phy_notify_connectfunction phy_notify_disconnectfunction phy_notify_statefunction phy_configurefunction phy_validatefunction _of_phy_getfunction of_phy_putfunction of_phy_putfunction phy_putfunction devm_phy_putfunction of_phy_simple_xlatefunction phy_putfunction devm_phy_getfunction devm_phy_optional_getfunction devm_of_phy_getfunction devm_of_phy_optional_getfunction devm_of_phy_get_by_indexfunction phy_createfunction devm_phy_createfunction phy_destroyfunction devm_phy_destroyfunction __of_phy_provider_registerfunction __devm_of_phy_provider_registerfunction of_phy_provider_unregisterfunction devm_of_phy_provider_unregisterfunction phy_releasefunction phy_core_initfunction phy_core_exit
Annotated Snippet
ret = device_add(&phy->dev);
if (ret)
goto put_dev;
if (pm_runtime_enabled(dev)) {
pm_runtime_enable(&phy->dev);
pm_runtime_no_callbacks(&phy->dev);
}
phy->debugfs = debugfs_create_dir(dev_name(&phy->dev), phy_debugfs_root);
return phy;
put_dev:
put_device(&phy->dev); /* calls phy_release() which frees resources */
return ERR_PTR(ret);
free_phy:
kfree(phy);
return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(phy_create);
/**
* devm_phy_create() - create a new phy
* @dev: device that is creating the new phy
* @node: device node of the phy
* @ops: function pointers for performing phy operations
*
* Creates a new PHY device adding it to the PHY class.
* While at that, it also associates the device with the phy using devres.
* On driver detach, release function is invoked on the devres data,
* then, devres data is freed.
*/
struct phy *devm_phy_create(struct device *dev, struct device_node *node,
const struct phy_ops *ops)
{
struct phy **ptr, *phy;
ptr = devres_alloc(devm_phy_consume, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return ERR_PTR(-ENOMEM);
phy = phy_create(dev, node, ops);
if (!IS_ERR(phy)) {
*ptr = phy;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return phy;
}
EXPORT_SYMBOL_GPL(devm_phy_create);
/**
* phy_destroy() - destroy the phy
* @phy: the phy to be destroyed
*
* Called to destroy the phy.
*/
void phy_destroy(struct phy *phy)
{
pm_runtime_disable(&phy->dev);
device_unregister(&phy->dev);
}
EXPORT_SYMBOL_GPL(phy_destroy);
/**
* devm_phy_destroy() - destroy the PHY
* @dev: device that wants to release this phy
* @phy: the phy returned by devm_phy_get()
*
* destroys the devres associated with this phy and invokes phy_destroy
* to destroy the phy.
*/
void devm_phy_destroy(struct device *dev, struct phy *phy)
{
int r;
r = devres_release(dev, devm_phy_consume, devm_phy_match, phy);
dev_WARN_ONCE(dev, r, "couldn't find PHY resource\n");
}
EXPORT_SYMBOL_GPL(devm_phy_destroy);
/**
* __of_phy_provider_register() - create/register phy provider with the framework
* @dev: struct device of the phy provider
* @children: device node containing children (if different from dev->of_node)
* @owner: the module owner containing of_xlate
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/export.h`, `linux/module.h`, `linux/err.h`, `linux/debugfs.h`, `linux/device.h`, `linux/slab.h`, `linux/of.h`.
- Detected declarations: `function devm_phy_release`, `function devm_phy_provider_release`, `function devm_phy_consume`, `function devm_phy_match`, `function phy_create_lookup`, `function phy_remove_lookup`, `function list_for_each_entry`, `function phy_pm_runtime_get`, `function phy_pm_runtime_get_sync`, `function phy_pm_runtime_put`.
- Atlas domain: Driver Families / drivers/phy.
- 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.