File tree Expand file tree Collapse file tree 1 file changed +6
-15
lines changed
components/drivers/regulator Expand file tree Collapse file tree 1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change 1818#define DBG_LVL DBG_INFO
1919#include <rtdbg.h>
2020
21-
2221struct rt_regulator
2322{
2423 struct rt_regulator_node * reg_np ;
@@ -359,7 +358,6 @@ static rt_err_t regulator_enable(struct rt_regulator_node *reg_np)
359358 regulator_delay (enable_delay );
360359 }
361360
362- rt_atomic_add (& reg_np -> enabled_count , 1 );
363361 err = regulator_notifier_call_chain (reg_np , RT_REGULATOR_MSG_ENABLE , RT_NULL );
364362 }
365363 }
@@ -434,7 +432,7 @@ static rt_err_t regulator_disable(struct rt_regulator_node *reg_np)
434432
435433rt_err_t rt_regulator_disable (struct rt_regulator * reg )
436434{
437- rt_err_t err ;
435+ rt_err_t err = RT_EOK ;
438436 int enabled_cnt ;
439437
440438 if (!reg )
@@ -450,20 +448,13 @@ rt_err_t rt_regulator_disable(struct rt_regulator *reg)
450448 rt_hw_spin_lock (& _regulator_lock .lock );
451449
452450 enabled_cnt = rt_atomic_load (& reg -> reg_np -> enabled_count );
453- if (enabled_cnt > 0 )
454- {
455- rt_atomic_sub (& reg -> reg_np -> enabled_count , 1 );
456- enabled_cnt -- ;
451+ rt_atomic_sub (& reg -> reg_np -> enabled_count , 1 );
457452
458- if (enabled_cnt > 0 )
459- {
460- rt_hw_spin_unlock (& _regulator_lock .lock );
461- return RT_EOK ;
462- }
453+ if (enabled_cnt == 1 )
454+ {
455+ err = regulator_disable (reg -> reg_np );
463456 }
464457
465- err = regulator_disable (reg -> reg_np );
466-
467458 rt_hw_spin_unlock (& _regulator_lock .lock );
468459
469460 return err ;
@@ -473,7 +464,7 @@ rt_bool_t rt_regulator_is_enabled(struct rt_regulator *reg)
473464{
474465 if (!reg )
475466 {
476- return - RT_EINVAL ;
467+ return RT_FALSE ;
477468 }
478469
479470 if (reg -> reg_np -> ops -> is_enabled )
You can’t perform that action at this time.
0 commit comments