drivers/soc/samsung/exynos-regulator-coupler.c
Source file repositories/reference/linux-study-clean/drivers/soc/samsung/exynos-regulator-coupler.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/samsung/exynos-regulator-coupler.c- Extension
.c- Size
- 5380 bytes
- Lines
- 222
- Domain
- Driver Families
- Bucket
- drivers/soc
- Inferred role
- Driver Families: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/kernel.hlinux/of.hlinux/regulator/coupler.hlinux/regulator/driver.hlinux/regulator/machine.h
Detected Declarations
function Copyrightfunction exynos_coupler_balance_voltagefunction exynos_coupler_attachfunction exynos_coupler_init
Annotated Snippet
if (tmp_min == 0) {
ret = regulator_get_voltage_rdev(c_rdevs[i]);
if (ret < 0)
return ret;
tmp_min = ret;
}
/* apply constraints */
ret = regulator_check_voltage(c_rdevs[i], &tmp_min, &tmp_max);
if (ret < 0)
return ret;
highest_min_uV = max(highest_min_uV, tmp_min);
if (i == 0) {
desired_min_uV = tmp_min;
desired_max_uV = tmp_max;
}
}
max_spread = constraints->max_spread[0];
/*
* Let target_uV be equal to the desired one if possible.
* If not, set it to minimum voltage, allowed by other coupled
* regulators.
*/
target_uV = max(desired_min_uV, highest_min_uV - max_spread);
/*
* Find min and max voltages, which currently aren't violating
* max_spread.
*/
for (i = 1; i < n_coupled; i++) {
int tmp_act;
tmp_act = regulator_get_voltage_rdev(c_rdevs[i]);
if (tmp_act < 0)
return tmp_act;
min_current_uV = min(tmp_act, min_current_uV);
max_current_uV = max(tmp_act, max_current_uV);
}
/*
* Correct target voltage, so as it currently isn't
* violating max_spread
*/
possible_uV = max(target_uV, max_current_uV - max_spread);
possible_uV = min(possible_uV, min_current_uV + max_spread);
if (possible_uV > desired_max_uV)
return -EINVAL;
done = (possible_uV == target_uV);
desired_min_uV = possible_uV;
/* Set current_uV if wasn't done earlier in the code and if necessary */
if (*current_uV == -1) {
ret = regulator_get_voltage_rdev(rdev);
if (ret < 0)
return ret;
*current_uV = ret;
}
*min_uV = desired_min_uV;
*max_uV = desired_max_uV;
return done;
}
static int exynos_coupler_balance_voltage(struct regulator_coupler *coupler,
struct regulator_dev *rdev,
suspend_state_t state)
{
struct regulator_dev **c_rdevs;
struct regulator_dev *best_rdev;
struct coupling_desc *c_desc = &rdev->coupling_desc;
int i, ret, n_coupled, best_min_uV, best_max_uV, best_c_rdev;
unsigned int delta, best_delta;
unsigned long c_rdev_done = 0;
bool best_c_rdev_done;
c_rdevs = c_desc->coupled_rdevs;
n_coupled = c_desc->n_coupled;
/*
* Find the best possible voltage change on each loop. Leave the loop
* if there isn't any possible change.
*/
Annotation
- Immediate include surface: `linux/init.h`, `linux/kernel.h`, `linux/of.h`, `linux/regulator/coupler.h`, `linux/regulator/driver.h`, `linux/regulator/machine.h`.
- Detected declarations: `function Copyright`, `function exynos_coupler_balance_voltage`, `function exynos_coupler_attach`, `function exynos_coupler_init`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: source 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.