drivers: regulator: fix reference count underflow
Fixes regulator reference count underflow and adds error code for attempting to disable an already disabled regulator Signed-off-by: Vladislav Litvinov <vladislav.litvinov@nordicsemi.no>
This commit is contained in:
parent
08cd4b6cce
commit
95622e49b2
1 changed files with 7 additions and 5 deletions
|
|
@ -183,6 +183,7 @@ int regulator_disable(const struct device *dev)
|
|||
(void)k_mutex_lock(&data->lock, K_FOREVER);
|
||||
#endif
|
||||
|
||||
if (data->refcnt > 0) {
|
||||
data->refcnt--;
|
||||
|
||||
if (data->refcnt == 0) {
|
||||
|
|
@ -191,6 +192,7 @@ int regulator_disable(const struct device *dev)
|
|||
data->refcnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_REGULATOR_THREAD_SAFE_REFCNT
|
||||
k_mutex_unlock(&data->lock);
|
||||
|
|
|
|||
Loading…
Reference in a new issue