drivers/extcon/devres.c
Source file repositories/reference/linux-study-clean/drivers/extcon/devres.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/extcon/devres.c- Extension
.c- Size
- 7453 bytes
- Lines
- 268
- Domain
- Driver Families
- Bucket
- drivers/extcon
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
extcon.h
Detected Declarations
struct extcon_dev_notifier_devresfunction Copyrightfunction devm_extcon_dev_releasefunction devm_extcon_dev_unregfunction devm_extcon_dev_notifier_unregfunction devm_extcon_dev_notifier_all_unregfunction ERR_PTRfunction devm_extcon_dev_freefunction devm_extcon_dev_registerfunction devm_extcon_dev_unregisterfunction devm_extcon_register_notifierfunction devm_extcon_unregister_notifierfunction devm_extcon_register_notifier_allfunction devm_extcon_unregister_notifier_allexport devm_extcon_dev_allocateexport devm_extcon_dev_freeexport devm_extcon_dev_registerexport devm_extcon_dev_unregisterexport devm_extcon_register_notifierexport devm_extcon_unregister_notifierexport devm_extcon_register_notifier_allexport devm_extcon_unregister_notifier_all
Annotated Snippet
struct extcon_dev_notifier_devres {
struct extcon_dev *edev;
unsigned int id;
struct notifier_block *nb;
};
static void devm_extcon_dev_notifier_unreg(struct device *dev, void *res)
{
struct extcon_dev_notifier_devres *this = res;
extcon_unregister_notifier(this->edev, this->id, this->nb);
}
static void devm_extcon_dev_notifier_all_unreg(struct device *dev, void *res)
{
struct extcon_dev_notifier_devres *this = res;
extcon_unregister_notifier_all(this->edev, this->nb);
}
/**
* devm_extcon_dev_allocate - Allocate managed extcon device
* @dev: the device owning the extcon device being created
* @supported_cable: the array of the supported external connectors
* ending with EXTCON_NONE.
*
* This function manages automatically the memory of extcon device using device
* resource management and simplify the control of freeing the memory of extcon
* device.
*
* Returns the pointer memory of allocated extcon_dev if success
* or ERR_PTR(err) if fail
*/
struct extcon_dev *devm_extcon_dev_allocate(struct device *dev,
const unsigned int *supported_cable)
{
struct extcon_dev **ptr, *edev;
ptr = devres_alloc(devm_extcon_dev_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return ERR_PTR(-ENOMEM);
edev = extcon_dev_allocate(supported_cable);
if (IS_ERR(edev)) {
devres_free(ptr);
return edev;
}
edev->dev.parent = dev;
*ptr = edev;
devres_add(dev, ptr);
return edev;
}
EXPORT_SYMBOL_GPL(devm_extcon_dev_allocate);
/**
* devm_extcon_dev_free() - Resource-managed extcon_dev_unregister()
* @dev: the device owning the extcon device being created
* @edev: the extcon device to be freed
*
* Free the memory that is allocated with devm_extcon_dev_allocate()
* function.
*/
void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev)
{
WARN_ON(devres_release(dev, devm_extcon_dev_release,
devm_extcon_dev_match, edev));
}
EXPORT_SYMBOL_GPL(devm_extcon_dev_free);
/**
* devm_extcon_dev_register() - Resource-managed extcon_dev_register()
* @dev: the device owning the extcon device being created
* @edev: the extcon device to be registered
*
* this function, that extcon device is automatically unregistered on driver
* detach. Internally this function calls extcon_dev_register() function.
* To get more information, refer that function.
*
* If extcon device is registered with this function and the device needs to be
* unregistered separately, devm_extcon_dev_unregister() should be used.
*
* Returns 0 if success or negaive error number if failure.
*/
int devm_extcon_dev_register(struct device *dev, struct extcon_dev *edev)
{
struct extcon_dev **ptr;
int ret;
Annotation
- Immediate include surface: `extcon.h`.
- Detected declarations: `struct extcon_dev_notifier_devres`, `function Copyright`, `function devm_extcon_dev_release`, `function devm_extcon_dev_unreg`, `function devm_extcon_dev_notifier_unreg`, `function devm_extcon_dev_notifier_all_unreg`, `function ERR_PTR`, `function devm_extcon_dev_free`, `function devm_extcon_dev_register`, `function devm_extcon_dev_unregister`.
- Atlas domain: Driver Families / drivers/extcon.
- Implementation status: integration 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.