| 304 | } |
| 305 | |
| 306 | rt_err_t rt_regulator_disable(struct rt_regulator *reg) |
| 307 | { |
| 308 | rt_err_t err; |
| 309 | |
| 310 | if (!reg) |
| 311 | { |
| 312 | return -RT_EINVAL; |
| 313 | } |
| 314 | |
| 315 | if (!rt_regulator_is_enabled(reg)) |
| 316 | { |
| 317 | return RT_EOK; |
| 318 | } |
| 319 | |
| 320 | if (rt_atomic_load(®->reg_np->enabled_count) != 0) |
| 321 | { |
| 322 | rt_atomic_sub(®->reg_np->enabled_count, 1); |
| 323 | |
| 324 | return RT_EOK; |
| 325 | } |
| 326 | |
| 327 | rt_hw_spin_lock(&_regulator_lock.lock); |
| 328 | |
| 329 | err = regulator_disable(reg->reg_np); |
| 330 | |
| 331 | rt_hw_spin_unlock(&_regulator_lock.lock); |
| 332 | |
| 333 | return err; |
| 334 | } |
| 335 | |
| 336 | rt_bool_t rt_regulator_is_enabled(struct rt_regulator *reg) |
| 337 | { |
no test coverage detected