dont allow the ata callbacks to be run less than once every 30s unless

explicitly forced to.
The sleep_after param is only true in the Q_SLEEP event, so its uneeded,
so removed


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11599 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2006-11-26 09:53:42 +00:00
parent e25c840b98
commit 4049d44b03
5 changed files with 17 additions and 13 deletions

View file

@ -141,7 +141,7 @@ long gui_wps_show(void)
if (wps_state.paused) { if (wps_state.paused) {
settings_save(); settings_save();
#if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
call_ata_idle_notifys(false); call_ata_idle_notifys(true);
#endif #endif
} }
} }
@ -255,7 +255,7 @@ long gui_wps_show(void)
audio_pause(); audio_pause();
settings_save(); settings_save();
#if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) #if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
call_ata_idle_notifys(false); /* make sure resume info is saved */ call_ata_idle_notifys(true); /* make sure resume info is saved */
#endif #endif
} }
break; break;

View file

@ -555,7 +555,7 @@ bool settings_parseline(char* line, char** name, char** value)
static void system_flush(void) static void system_flush(void)
{ {
call_ata_idle_notifys(false); /*doesnt work on usb and shutdown from ata thread */ call_ata_idle_notifys(true); /*doesnt work on usb and shutdown from ata thread */
tree_flush(); tree_flush();
} }
@ -569,7 +569,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
#ifdef SIMULATOR #ifdef SIMULATOR
(void)callback; (void)callback;
(void)parameter; (void)parameter;
call_ata_idle_notifys(false); call_ata_idle_notifys(true);
exit(0); exit(0);
#else #else
int i; int i;

View file

@ -20,7 +20,7 @@
#include "system.h" #include "system.h"
#include "ata.h" #include "ata.h"
#include "ata_idle_notify.h" #include "ata_idle_notify.h"
#include "logf.h" #include "kernel.h"
#include "string.h" #include "string.h"
#if USING_ATA_CALLBACK #if USING_ATA_CALLBACK
@ -28,10 +28,13 @@ static ata_idle_notify ata_idle_notify_funcs[MAX_ATA_CALLBACKS];
static int ata_callback_count = 0; static int ata_callback_count = 0;
#endif #endif
bool register_ata_idle_func(ata_idle_notify function) bool register_ata_idle_func(ata_idle_notify function)
{ {
#if USING_ATA_CALLBACK #if USING_ATA_CALLBACK
int i; int i;
if (ata_callback_count >= MAX_ATA_CALLBACKS)
return false;
for (i=0; i<MAX_ATA_CALLBACKS; i++) for (i=0; i<MAX_ATA_CALLBACKS; i++)
{ {
if (ata_idle_notify_funcs[i] == NULL) if (ata_idle_notify_funcs[i] == NULL)
@ -69,13 +72,15 @@ void unregister_ata_idle_func(ata_idle_notify func, bool run)
return; return;
} }
bool call_ata_idle_notifys(bool sleep_after) bool call_ata_idle_notifys(bool force)
{ {
int i; int i;
static int lock_until = 0;
ata_idle_notify function; ata_idle_notify function;
if (ata_callback_count == 0) if (!force && TIME_BEFORE(current_tick,lock_until) )
return false; return false;
ata_callback_count = 0; /* so we dont re-enter every time the callbacks read/write */ lock_until = current_tick + 30*HZ;
for (i = 0; i < MAX_ATA_CALLBACKS; i++) for (i = 0; i < MAX_ATA_CALLBACKS; i++)
{ {
if (ata_idle_notify_funcs[i]) if (ata_idle_notify_funcs[i])
@ -83,10 +88,9 @@ bool call_ata_idle_notifys(bool sleep_after)
function = ata_idle_notify_funcs[i]; function = ata_idle_notify_funcs[i];
ata_idle_notify_funcs[i] = NULL; ata_idle_notify_funcs[i] = NULL;
function(); function();
ata_callback_count--;
} }
} }
if (sleep_after)
ata_sleep();
return true; return true;
} }

View file

@ -1285,7 +1285,7 @@ static void ata_thread(void)
break; break;
#endif #endif
case Q_SLEEP: case Q_SLEEP:
call_ata_idle_notifys(true); call_ata_idle_notifys(false);
last_disk_activity = current_tick - sleep_timeout + (HZ/2); last_disk_activity = current_tick - sleep_timeout + (HZ/2);
break; break;

View file

@ -44,10 +44,10 @@ extern bool register_ata_idle_func(ata_idle_notify function);
#if USING_ATA_CALLBACK #if USING_ATA_CALLBACK
extern void ata_idle_notify_init(void); extern void ata_idle_notify_init(void);
extern void unregister_ata_idle_func(ata_idle_notify function, bool run); extern void unregister_ata_idle_func(ata_idle_notify function, bool run);
extern bool call_ata_idle_notifys(bool sleep_after); extern bool call_ata_idle_notifys(bool force);
#else #else
#define unregister_ata_idle_func(f,r) #define unregister_ata_idle_func(f,r)
#define call_ata_idle_notifys(s) #define call_ata_idle_notifys(f)
#define ata_idle_notify_init(s) #define ata_idle_notify_init(s)
#endif #endif