drivers/regulator/core.c
Source file repositories/reference/linux-study-clean/drivers/regulator/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/regulator/core.c- Extension
.c- Size
- 180955 bytes
- Lines
- 6891
- Domain
- Driver Families
- Bucket
- drivers/regulator
- 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.
- 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/init.hlinux/debugfs.hlinux/device.hlinux/slab.hlinux/async.hlinux/err.hlinux/mutex.hlinux/suspend.hlinux/delay.hlinux/gpio/consumer.hlinux/of.hlinux/reboot.hlinux/regmap.hlinux/regulator/of_regulator.hlinux/regulator/consumer.hlinux/regulator/coupler.hlinux/regulator/driver.hlinux/regulator/machine.hlinux/module.htrace/events/regulator.hdummy.hinternal.hregnl.h
Detected Declarations
struct regulator_mapstruct regulator_enable_gpiostruct regulator_supply_aliasstruct regulator_event_workstruct summary_datastruct summary_lock_datafunction have_full_constraintsfunction regulator_ops_is_validfunction regulator_lock_nestedfunction regulator_lockfunction regulator_unlockfunction regulator_lock_twofunction regulator_lock_twofunction regulator_supply_is_couplefunction regulator_unlock_recursivefunction regulator_lock_recursivefunction regulator_unlock_dependentfunction regulator_lock_recursivefunction regulator_check_voltagefunction regulator_check_statesfunction regulator_check_consumersfunction list_for_each_entryfunction regulator_check_current_limitfunction regulator_mode_constrainfunction regulator_get_suspend_statefunction regulator_get_suspend_state_checkfunction microvolts_showfunction microamps_showfunction name_showfunction regulator_print_opmodefunction opmode_showfunction regulator_print_statefunction state_showfunction status_showfunction min_microamps_showfunction max_microamps_showfunction min_microvolts_showfunction max_microvolts_showfunction requested_microamps_showfunction num_users_showfunction type_showfunction suspend_mem_microvolts_showfunction suspend_disk_microvolts_showfunction suspend_standby_microvolts_showfunction suspend_mem_mode_showfunction suspend_disk_mode_showfunction suspend_standby_mode_showfunction suspend_mem_state_show
Annotated Snippet
static const struct bus_type regulator_bus;
static struct dentry *debugfs_root;
/*
* struct regulator_map
*
* Used to provide symbolic supply names to devices.
*/
struct regulator_map {
struct list_head list;
const char *dev_name; /* The dev_name() for the consumer */
const char *supply;
struct regulator_dev *regulator;
};
/*
* struct regulator_enable_gpio
*
* Management for shared enable GPIO pin
*/
struct regulator_enable_gpio {
struct list_head list;
struct gpio_desc *gpiod;
u32 enable_count; /* a number of enabled shared GPIO */
u32 request_count; /* a number of requested shared GPIO */
};
/*
* struct regulator_supply_alias
*
* Used to map lookups for a supply onto an alternative device.
*/
struct regulator_supply_alias {
struct list_head list;
struct device *src_dev;
const char *src_supply;
struct device *alias_dev;
const char *alias_supply;
};
/*
* Work item used to forward regulator events.
*
* @work: workqueue entry
* @rdev: regulator device to notify (consumer receiving the forwarded event)
* @event: event code to be forwarded
*/
struct regulator_event_work {
struct work_struct work;
struct regulator_dev *rdev;
unsigned long event;
};
static int _regulator_enable(struct regulator *regulator);
static int _regulator_is_enabled(struct regulator_dev *rdev);
static int _regulator_disable(struct regulator *regulator);
static int _regulator_get_error_flags(struct regulator_dev *rdev, unsigned int *flags);
static int _regulator_get_current_limit(struct regulator_dev *rdev);
static unsigned int _regulator_get_mode(struct regulator_dev *rdev);
static int _notifier_call_chain(struct regulator_dev *rdev,
unsigned long event, void *data);
static int _regulator_do_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV);
static int regulator_balance_voltage(struct regulator_dev *rdev,
suspend_state_t state);
static struct regulator *create_regulator(struct regulator_dev *rdev,
struct device *dev,
const char *supply_name);
static void destroy_regulator(struct regulator *regulator);
static void _regulator_put(struct regulator *regulator);
const char *rdev_get_name(struct regulator_dev *rdev)
{
if (rdev->constraints && rdev->constraints->name)
return rdev->constraints->name;
else if (rdev->desc->name)
return rdev->desc->name;
else
return "";
}
EXPORT_SYMBOL_GPL(rdev_get_name);
static bool have_full_constraints(void)
{
return has_full_constraints || of_have_populated_dt();
}
static bool regulator_ops_is_valid(struct regulator_dev *rdev, int ops)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/debugfs.h`, `linux/device.h`, `linux/slab.h`, `linux/async.h`, `linux/err.h`, `linux/mutex.h`.
- Detected declarations: `struct regulator_map`, `struct regulator_enable_gpio`, `struct regulator_supply_alias`, `struct regulator_event_work`, `struct summary_data`, `struct summary_lock_data`, `function have_full_constraints`, `function regulator_ops_is_valid`, `function regulator_lock_nested`, `function regulator_lock`.
- Atlas domain: Driver Families / drivers/regulator.
- Implementation status: pattern 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.