From d5a2aeb6c48d0533dddcc743154b074d1f813928 Mon Sep 17 00:00:00 2001 From: James Buren Date: Sat, 14 Nov 2020 11:56:53 +0000 Subject: 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 --- firmware/powermgmt.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'firmware/powermgmt.c') 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) /* Returns true if any power input is capable of charging. */ bool charger_inserted(void) { - return power_thread_inputs & POWER_INPUT_CHARGER; +#ifndef BOOTLOADER + unsigned int data = power_thread_inputs; +#else + unsigned int data = power_input_status(); +#endif + return data & POWER_INPUT_CHARGER; } /* Returns true if any power input is connected - charging-capable * or not. */ bool power_input_present(void) { - return power_thread_inputs & POWER_INPUT; +#ifndef BOOTLOADER + unsigned int data = power_thread_inputs; +#else + unsigned int data = power_input_status(); +#endif + return data & POWER_INPUT; } /* -- cgit v1.2.3