| 64 | } |
| 65 | |
| 66 | rt_err_t rt_regulator_unregister(struct rt_regulator_node *reg_np) |
| 67 | { |
| 68 | rt_err_t err = RT_EOK; |
| 69 | |
| 70 | if (!reg_np) |
| 71 | { |
| 72 | return -RT_EINVAL; |
| 73 | } |
| 74 | |
| 75 | rt_hw_spin_lock(&_regulator_lock.lock); |
| 76 | |
| 77 | if (rt_atomic_load(®_np->enabled_count) != 0) |
| 78 | { |
| 79 | err = -RT_EBUSY; |
| 80 | |
| 81 | LOG_E("%s was enabled by consumer", reg_np->supply_name); |
| 82 | |
| 83 | goto _unlock; |
| 84 | } |
| 85 | |
| 86 | if (!(reg_np->param->boot_on || reg_np->param->always_on)) |
| 87 | { |
| 88 | regulator_disable(reg_np); |
| 89 | } |
| 90 | |
| 91 | if (!rt_list_isempty(®_np->children_nodes) || rt_ref_read(®_np->ref) > 1) |
| 92 | { |
| 93 | err = -RT_EBUSY; |
| 94 | |
| 95 | goto _unlock; |
| 96 | } |
| 97 | |
| 98 | reg_np->parent = RT_NULL; |
| 99 | rt_list_remove(®_np->list); |
| 100 | |
| 101 | _unlock: |
| 102 | rt_hw_spin_unlock(&_regulator_lock.lock); |
| 103 | |
| 104 | return err; |
| 105 | } |
| 106 | |
| 107 | rt_err_t rt_regulator_notifier_register(struct rt_regulator *reg, |
| 108 | struct rt_regulator_notifier *notifier) |
no test coverage detected