mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-05-15 11:07:34 +08:00
[dm][regulator] fixup the ref of enabled status
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
utest_auto_run / A9 :components/dfs.cfg (push) Has been cancelled
utest_auto_run / A9 :components/lwip.cfg (push) Has been cancelled
utest_auto_run / A9 :components/netdev.cfg (push) Has been cancelled
utest_auto_run / A9 :components/sal.cfg (push) Has been cancelled
utest_auto_run / A9 :cpp11/cpp11.cfg (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/mem.cfg (push) Has been cancelled
ToolsCI / Tools (push) Has been cancelled
Weekly CI Scheduler / Trigger and Monitor CIs (push) Has been cancelled
Weekly CI Scheduler / Create Discussion Report (push) Has been cancelled
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
utest_auto_run / A9 :components/dfs.cfg (push) Has been cancelled
utest_auto_run / A9 :components/lwip.cfg (push) Has been cancelled
utest_auto_run / A9 :components/netdev.cfg (push) Has been cancelled
utest_auto_run / A9 :components/sal.cfg (push) Has been cancelled
utest_auto_run / A9 :cpp11/cpp11.cfg (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/mem.cfg (push) Has been cancelled
ToolsCI / Tools (push) Has been cancelled
Weekly CI Scheduler / Trigger and Monitor CIs (push) Has been cancelled
Weekly CI Scheduler / Create Discussion Report (push) Has been cancelled
Signed-off-by: GuEe-GUI <2991707448@qq.com>
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
|
||||
struct rt_regulator
|
||||
{
|
||||
struct rt_regulator_node *reg_np;
|
||||
@@ -359,7 +358,6 @@ static rt_err_t regulator_enable(struct rt_regulator_node *reg_np)
|
||||
regulator_delay(enable_delay);
|
||||
}
|
||||
|
||||
rt_atomic_add(®_np->enabled_count, 1);
|
||||
err = regulator_notifier_call_chain(reg_np, RT_REGULATOR_MSG_ENABLE, RT_NULL);
|
||||
}
|
||||
}
|
||||
@@ -434,7 +432,7 @@ static rt_err_t regulator_disable(struct rt_regulator_node *reg_np)
|
||||
|
||||
rt_err_t rt_regulator_disable(struct rt_regulator *reg)
|
||||
{
|
||||
rt_err_t err;
|
||||
rt_err_t err = RT_EOK;
|
||||
int enabled_cnt;
|
||||
|
||||
if (!reg)
|
||||
@@ -450,20 +448,13 @@ rt_err_t rt_regulator_disable(struct rt_regulator *reg)
|
||||
rt_hw_spin_lock(&_regulator_lock.lock);
|
||||
|
||||
enabled_cnt = rt_atomic_load(®->reg_np->enabled_count);
|
||||
if (enabled_cnt > 0)
|
||||
rt_atomic_sub(®->reg_np->enabled_count, 1);
|
||||
|
||||
if (enabled_cnt == 1)
|
||||
{
|
||||
rt_atomic_sub(®->reg_np->enabled_count, 1);
|
||||
enabled_cnt--;
|
||||
|
||||
if (enabled_cnt > 0)
|
||||
{
|
||||
rt_hw_spin_unlock(&_regulator_lock.lock);
|
||||
return RT_EOK;
|
||||
}
|
||||
err = regulator_disable(reg->reg_np);
|
||||
}
|
||||
|
||||
err = regulator_disable(reg->reg_np);
|
||||
|
||||
rt_hw_spin_unlock(&_regulator_lock.lock);
|
||||
|
||||
return err;
|
||||
@@ -473,7 +464,7 @@ rt_bool_t rt_regulator_is_enabled(struct rt_regulator *reg)
|
||||
{
|
||||
if (!reg)
|
||||
{
|
||||
return -RT_EINVAL;
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
if (reg->reg_np->ops->is_enabled)
|
||||
|
||||
Reference in New Issue
Block a user