Skip to content

Commit

Permalink
drivers: regulator: Fixed reference counting during enable
Browse files Browse the repository at this point in the history
Reference counting was broken when adding the enable delay.
Now reverted to previous pattern.

Signed-off-by: Andy Sinclair <[email protected]>
  • Loading branch information
aasinclair authored and fabiobaltieri committed Nov 23, 2023
1 parent 64cce48 commit c3a54ae
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 c3a54ae

Please sign in to comment.