drivers/regulator/devres.c
Source file repositories/reference/linux-study-clean/drivers/regulator/devres.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/devres.c- Extension
.c- Size
- 23463 bytes
- Lines
- 807
- Domain
- Driver Families
- Bucket
- drivers/regulator
- 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.
- 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/err.hlinux/regmap.hlinux/regulator/consumer.hlinux/regulator/driver.hlinux/module.hinternal.h
Detected Declarations
struct regulator_bulk_devresstruct regulator_supply_alias_matchstruct regulator_notifier_matchfunction devm_regulator_releasefunction regulator_getfunction regulator_get_exclusivefunction regulator_action_disablefunction _devm_regulator_get_enablefunction regulator_disablefunction regulator_disablefunction regulator_get_optionalfunction regulator_disablefunction devm_regulator_matchfunction devm_regulator_getfunction devm_regulator_bulk_releasefunction _devm_regulator_bulk_getfunction devm_regulator_bulk_getfunction devm_regulator_bulk_get_exclusivefunction devm_regulator_bulk_getfunction devm_regulator_bulk_matchfunction devm_regulator_bulk_getfunction devm_regulator_bulk_disablefunction devm_regulator_bulk_get_enablefunction devm_rdev_releasefunction ERR_PTRfunction devm_regulator_match_supply_aliasfunction devm_regulator_destroy_supply_aliasfunction regulator_register_supply_aliasfunction devm_regulator_unregister_supply_aliasfunction devm_regulator_bulk_register_supply_aliasfunction devm_regulator_match_notifierfunction devm_regulator_destroy_notifierfunction devm_regulator_register_notifierfunction regulator_unregister_notifierfunction regulator_irq_helper_dropfunction thefunction of_regulator_getfunction regulator_get_optionalexport devm_regulator_getexport devm_regulator_get_exclusiveexport devm_regulator_get_enable_optionalexport devm_regulator_get_enableexport devm_regulator_get_optionalexport devm_regulator_get_enable_read_voltageexport devm_regulator_putexport devm_regulator_bulk_getexport devm_regulator_bulk_get_exclusiveexport devm_regulator_bulk_get_const
Annotated Snippet
struct regulator_bulk_devres {
struct regulator_bulk_data *consumers;
int num_consumers;
};
static void devm_regulator_bulk_release(struct device *dev, void *res)
{
struct regulator_bulk_devres *devres = res;
regulator_bulk_free(devres->num_consumers, devres->consumers);
}
static int _devm_regulator_bulk_get(struct device *dev, int num_consumers,
struct regulator_bulk_data *consumers,
enum regulator_get_type get_type)
{
struct regulator_bulk_devres *devres;
int ret;
devres = devres_alloc(devm_regulator_bulk_release,
sizeof(*devres), GFP_KERNEL);
if (!devres)
return -ENOMEM;
ret = _regulator_bulk_get(dev, num_consumers, consumers, get_type);
if (!ret) {
devres->consumers = consumers;
devres->num_consumers = num_consumers;
devres_add(dev, devres);
} else {
devres_free(devres);
}
return ret;
}
/**
* devm_regulator_bulk_get - managed get multiple regulator consumers
*
* @dev: device to supply
* @num_consumers: number of consumers to register
* @consumers: configuration of consumers; clients are stored here.
*
* @return 0 on success, a negative error number on failure.
*
* This helper function allows drivers to get several regulator
* consumers in one operation with management, the regulators will
* automatically be freed when the device is unbound. If any of the
* regulators cannot be acquired then any regulators that were
* allocated will be freed before returning to the caller.
*/
int devm_regulator_bulk_get(struct device *dev, int num_consumers,
struct regulator_bulk_data *consumers)
{
return _devm_regulator_bulk_get(dev, num_consumers, consumers, NORMAL_GET);
}
EXPORT_SYMBOL_GPL(devm_regulator_bulk_get);
/**
* devm_regulator_bulk_get_exclusive - managed exclusive get of multiple
* regulator consumers
*
* @dev: device to supply
* @num_consumers: number of consumers to register
* @consumers: configuration of consumers; clients are stored here.
*
* @return 0 on success, a negative error number on failure.
*
* This helper function allows drivers to exclusively get several
* regulator consumers in one operation with management, the regulators
* will automatically be freed when the device is unbound. If any of
* the regulators cannot be acquired then any regulators that were
* allocated will be freed before returning to the caller.
*/
int devm_regulator_bulk_get_exclusive(struct device *dev, int num_consumers,
struct regulator_bulk_data *consumers)
{
return _devm_regulator_bulk_get(dev, num_consumers, consumers, EXCLUSIVE_GET);
}
EXPORT_SYMBOL_GPL(devm_regulator_bulk_get_exclusive);
/**
* devm_regulator_bulk_get_const - devm_regulator_bulk_get() w/ const data
*
* @dev: device to supply
* @num_consumers: number of consumers to register
* @in_consumers: const configuration of consumers
* @out_consumers: in_consumers is copied here and this is passed to
* devm_regulator_bulk_get().
*
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/err.h`, `linux/regmap.h`, `linux/regulator/consumer.h`, `linux/regulator/driver.h`, `linux/module.h`, `internal.h`.
- Detected declarations: `struct regulator_bulk_devres`, `struct regulator_supply_alias_match`, `struct regulator_notifier_match`, `function devm_regulator_release`, `function regulator_get`, `function regulator_get_exclusive`, `function regulator_action_disable`, `function _devm_regulator_get_enable`, `function regulator_disable`, `function regulator_disable`.
- Atlas domain: Driver Families / drivers/regulator.
- 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.