diff options
author | James Buren <braewoods+rb@braewoods.net> | 2020-11-14 11:56:53 +0000 |
---|---|---|
committer | James Buren <braewoods+rb@braewoods.net> | 2020-11-14 11:57:32 +0000 |
commit | d5a2aeb6c48d0533dddcc743154b074d1f813928 (patch) | |
tree | cff9d28eb7a177dbe0df84a6d1d31232d8e44993 | |
parent | 03cd7730510558d6434f205743d71c3e197df608 (diff) | |
download | rockbox-d5a2aeb6c48d0533dddcc743154b074d1f813928.tar.gz rockbox-d5a2aeb6c48d0533dddcc743154b074d1f813928.zip |
rockbox: revise charger_inserted and power_input_present functions
This makes it so the thread cached variable is only read if building
the regular firmware. For bootloaders the data is now read directly.
This fixes the functions for bootloaders so they do not have to import
the power management code just so these functions will work when in
the bootloader.
Change-Id: Ic425b02c08b48df7a11a6c19c022b0e1cb316a85
-rw-r--r-- | firmware/powermgmt.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index dacafee8e0..6cac300cdf 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -467,14 +467,24 @@ static inline void charging_algorithm_close(void) | |||
467 | /* Returns true if any power input is capable of charging. */ | 467 | /* Returns true if any power input is capable of charging. */ |
468 | bool charger_inserted(void) | 468 | bool charger_inserted(void) |
469 | { | 469 | { |
470 | return power_thread_inputs & POWER_INPUT_CHARGER; | 470 | #ifndef BOOTLOADER |
471 | unsigned int data = power_thread_inputs; | ||
472 | #else | ||
473 | unsigned int data = power_input_status(); | ||
474 | #endif | ||
475 | return data & POWER_INPUT_CHARGER; | ||
471 | } | 476 | } |
472 | 477 | ||
473 | /* Returns true if any power input is connected - charging-capable | 478 | /* Returns true if any power input is connected - charging-capable |
474 | * or not. */ | 479 | * or not. */ |
475 | bool power_input_present(void) | 480 | bool power_input_present(void) |
476 | { | 481 | { |
477 | return power_thread_inputs & POWER_INPUT; | 482 | #ifndef BOOTLOADER |
483 | unsigned int data = power_thread_inputs; | ||
484 | #else | ||
485 | unsigned int data = power_input_status(); | ||
486 | #endif | ||
487 | return data & POWER_INPUT; | ||
478 | } | 488 | } |
479 | 489 | ||
480 | /* | 490 | /* |