Skip to content

Commit

Permalink
[nrf fromtree] drivers: regulator: Fixed reference counting during en…
Browse files Browse the repository at this point in the history
…able

Reference counting was broken when adding the enable delay.
Now reverted to previous pattern.

Signed-off-by: Andy Sinclair <[email protected]>
(cherry picked from commit c3a54ae)
  • Loading branch information
aasinclair authored and rlubos committed Jan 18, 2024
1 parent 5d7a30b commit 9087637
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/regulator/regulator_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ int regulator_enable(const struct device *dev)
(void)k_mutex_lock(&data->lock, K_FOREVER);
#endif

if (data->refcnt == 0) {
data->refcnt++;

if (data->refcnt == 1) {
ret = api->enable(dev);
if (ret == 0) {
data->refcnt++;
if (ret < 0) {
data->refcnt--;
} else {
regulator_delay(config->off_on_delay_us);
}
}
Expand Down

0 comments on commit 9087637

Please sign in to comment.