diff --git a/apps/plugin.c b/apps/plugin.c index f1f44c680f..35e56c7fb5 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -412,7 +412,7 @@ static const struct plugin_api rockbox_api = { storage_sleep, STORAGE_FUNCTION(spin), STORAGE_FUNCTION(spindown), -#if USING_STORAGE_CALLBACK +#ifdef USING_STORAGE_CALLBACK register_storage_idle_func, unregister_storage_idle_func, #endif /* USING_STORAGE_CALLBACK */ diff --git a/apps/plugin.h b/apps/plugin.h index e7a91cd9c0..e8fe95b5a6 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -474,7 +474,7 @@ struct plugin_api { void (*storage_sleep)(void); void (*storage_spin)(void); void (*storage_spindown)(int seconds); -#if USING_STORAGE_CALLBACK +#ifdef USING_STORAGE_CALLBACK void (*register_storage_idle_func)(void (*function)(void)); void (*unregister_storage_idle_func)(void (*function)(void), bool run); #endif /* USING_STORAGE_CALLBACK */ diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index caa9f7a4d1..925653842f 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c @@ -458,7 +458,7 @@ static void thread(void) bat[buf_idx].flags = charge_state(); #endif buf_idx++; -#if USING_STORAGE_CALLBACK +#ifdef USING_STORAGE_CALLBACK rb->register_storage_idle_func(flush_buffer); #endif } @@ -497,7 +497,7 @@ static void thread(void) } } -#if USING_STORAGE_CALLBACK +#ifdef USING_STORAGE_CALLBACK /* unregister flush callback and flush to disk */ rb->unregister_storage_idle_func(flush_buffer, true); #else diff --git a/firmware/ata_idle_notify.c b/firmware/ata_idle_notify.c index a50866dcdc..f56dea5c11 100644 --- a/firmware/ata_idle_notify.c +++ b/firmware/ata_idle_notify.c @@ -25,7 +25,7 @@ #include "kernel.h" #include "string.h" -#if USING_STORAGE_CALLBACK +#if defined(USING_STORAGE_CALLBACK) static void wrapper(unsigned short id, void *ev_data, void *user_data) { (void)id; @@ -37,7 +37,7 @@ static void wrapper(unsigned short id, void *ev_data, void *user_data) void register_storage_idle_func(void (*function)(void)) { -#if USING_STORAGE_CALLBACK +#if defined(USING_STORAGE_CALLBACK) add_event_ex(DISK_EVENT_SPINUP, true, wrapper, function); #else function(); /* just call the function now */ @@ -47,11 +47,11 @@ void register_storage_idle_func(void (*function)(void)) #endif } -#if USING_STORAGE_CALLBACK +#if defined(USING_STORAGE_CALLBACK) void unregister_storage_idle_func(void (*func)(void), bool run) { remove_event_ex(DISK_EVENT_SPINUP, wrapper, func); - + if (run) func(); } @@ -68,7 +68,7 @@ bool call_storage_idle_notifys(bool force) lock_until = current_tick + 30*HZ; send_event(DISK_EVENT_SPINUP, NULL); - + return true; } #endif diff --git a/firmware/export/ata_idle_notify.h b/firmware/export/ata_idle_notify.h index 0443f8e516..8f2d4e26c4 100644 --- a/firmware/export/ata_idle_notify.h +++ b/firmware/export/ata_idle_notify.h @@ -27,7 +27,7 @@ /* NOTE: storage_idle_notify usage notes.. - + 1) The callbacks are called in the ata thread, not main/your thread. 2) Asynchronous callbacks (like the buffer refill) should be avoided. If you must use an async callback, remember to check storage_is_active() before @@ -46,10 +46,12 @@ enum { /* Enable storage callbacks everywhere except for bootloaders. Both * hosted and native targets need this. */ -#define USING_STORAGE_CALLBACK !defined(BOOTLOADER) && !defined(APPLICATION) && !defined(__PCTOOL__) +#if !defined(BOOTLOADER) && !defined(APPLICATION) && !defined(__PCTOOL__) +#define USING_STORAGE_CALLBACK +#endif extern void register_storage_idle_func(void (*function)(void)); -#if USING_STORAGE_CALLBACK +#ifdef USING_STORAGE_CALLBACK extern void unregister_storage_idle_func(void (*function)(void), bool run); extern bool call_storage_idle_notifys(bool force); #else diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 100f4be2ed..20059288dc 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -131,9 +131,10 @@ static const char power_thread_name[] = "power"; /* Time estimation requires 64 bit math so don't use it in the bootloader. * Also we need to be able to measure current, and not have a better time * estimate source available. */ -#define HAVE_TIME_ESTIMATION \ - (!defined(BOOTLOADER) && !(CONFIG_BATTERY_MEASURE & TIME_MEASURE) && \ +#if (!defined(BOOTLOADER) && !(CONFIG_BATTERY_MEASURE & TIME_MEASURE) && \ (defined(CURRENT_NORMAL) || (CONFIG_BATTERY_MEASURE & CURRENT_MEASURE))) +#define HAVE_TIME_ESTIMATION +#endif #if !(CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE) int _battery_level(void) { return -1; } @@ -146,7 +147,7 @@ int _battery_time(void) { return -1; } static int time_now; /* Cached to avoid polling too often */ #endif -#if HAVE_TIME_ESTIMATION +#ifdef HAVE_TIME_ESTIMATION static int time_now; /* reported time in minutes */ static int64_t time_cnt; /* reported time in seconds */ static int64_t time_err; /* error... it's complicated */ @@ -186,7 +187,7 @@ int battery_level(void) * on the battery level and the actual current usage. */ int battery_time(void) { -#if (CONFIG_BATTERY_MEASURE & TIME_MEASURE) || HAVE_TIME_ESTIMATION +#if (CONFIG_BATTERY_MEASURE & TIME_MEASURE) || defined(HAVE_TIME_ESTIMATION) return time_now; #else return -1; @@ -401,7 +402,7 @@ static void battery_status_update(void) #if CONFIG_BATTERY_MEASURE & TIME_MEASURE time_now = _battery_time(); -#elif HAVE_TIME_ESTIMATION +#elif defined(HAVE_TIME_ESTIMATION) /* TODO: This is essentially a bad version of coloumb counting, * so in theory using coloumb counters when they are available * should provide a more accurate result. Also note that this diff --git a/tools/configure b/tools/configure index 8e3bc96287..9c7bd8ecd0 100755 --- a/tools/configure +++ b/tools/configure @@ -4614,7 +4614,7 @@ else if test "$gccnum" -ge "700"; then # gcc 7 spews a bunch of warnings by default - GCCOPTS="$GCCOPTS -Wno-expansion-to-defined -Wimplicit-fallthrough=0" + GCCOPTS="$GCCOPTS -Wimplicit-fallthrough=0" fi case "$GCCOPTS" in