summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2006-11-26 09:53:42 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2006-11-26 09:53:42 +0000
commit4049d44b03d4a17cbf2f48f5f1360ac397da5ef5 (patch)
tree821366dcb8e02a3045976f7b24e78565b817f854
parente25c840b982fbdf9c61f789e08df244f7cb91845 (diff)
downloadrockbox-4049d44b03d4a17cbf2f48f5f1360ac397da5ef5.tar.gz
rockbox-4049d44b03d4a17cbf2f48f5f1360ac397da5ef5.zip
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
-rw-r--r--apps/gui/gwps.c4
-rw-r--r--apps/misc.c4
-rw-r--r--firmware/ata_idle_notify.c16
-rw-r--r--firmware/drivers/ata.c2
-rw-r--r--firmware/export/ata_idle_notify.h4
5 files changed, 17 insertions, 13 deletions
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index 482442cb53..9dabe2c733 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -141,7 +141,7 @@ long gui_wps_show(void)
141 if (wps_state.paused) { 141 if (wps_state.paused) {
142 settings_save(); 142 settings_save();
143#if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) 143#if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
144 call_ata_idle_notifys(false); 144 call_ata_idle_notifys(true);
145#endif 145#endif
146 } 146 }
147 } 147 }
@@ -255,7 +255,7 @@ long gui_wps_show(void)
255 audio_pause(); 255 audio_pause();
256 settings_save(); 256 settings_save();
257#if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF) 257#if !defined(HAVE_RTC_RAM) && !defined(HAVE_SW_POWEROFF)
258 call_ata_idle_notifys(false); /* make sure resume info is saved */ 258 call_ata_idle_notifys(true); /* make sure resume info is saved */
259#endif 259#endif
260 } 260 }
261 break; 261 break;
diff --git a/apps/misc.c b/apps/misc.c
index 709bc49208..2f3251431b 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -555,7 +555,7 @@ bool settings_parseline(char* line, char** name, char** value)
555 555
556static void system_flush(void) 556static void system_flush(void)
557{ 557{
558 call_ata_idle_notifys(false); /*doesnt work on usb and shutdown from ata thread */ 558 call_ata_idle_notifys(true); /*doesnt work on usb and shutdown from ata thread */
559 tree_flush(); 559 tree_flush();
560} 560}
561 561
@@ -569,7 +569,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
569#ifdef SIMULATOR 569#ifdef SIMULATOR
570 (void)callback; 570 (void)callback;
571 (void)parameter; 571 (void)parameter;
572 call_ata_idle_notifys(false); 572 call_ata_idle_notifys(true);
573 exit(0); 573 exit(0);
574#else 574#else
575 int i; 575 int i;
diff --git a/firmware/ata_idle_notify.c b/firmware/ata_idle_notify.c
index c51c3800ce..17adbc1192 100644
--- a/firmware/ata_idle_notify.c
+++ b/firmware/ata_idle_notify.c
@@ -20,7 +20,7 @@
20#include "system.h" 20#include "system.h"
21#include "ata.h" 21#include "ata.h"
22#include "ata_idle_notify.h" 22#include "ata_idle_notify.h"
23#include "logf.h" 23#include "kernel.h"
24#include "string.h" 24#include "string.h"
25 25
26#if USING_ATA_CALLBACK 26#if USING_ATA_CALLBACK
@@ -28,10 +28,13 @@ static ata_idle_notify ata_idle_notify_funcs[MAX_ATA_CALLBACKS];
28static int ata_callback_count = 0; 28static int ata_callback_count = 0;
29#endif 29#endif
30 30
31
31bool register_ata_idle_func(ata_idle_notify function) 32bool register_ata_idle_func(ata_idle_notify function)
32{ 33{
33#if USING_ATA_CALLBACK 34#if USING_ATA_CALLBACK
34 int i; 35 int i;
36 if (ata_callback_count >= MAX_ATA_CALLBACKS)
37 return false;
35 for (i=0; i<MAX_ATA_CALLBACKS; i++) 38 for (i=0; i<MAX_ATA_CALLBACKS; i++)
36 { 39 {
37 if (ata_idle_notify_funcs[i] == NULL) 40 if (ata_idle_notify_funcs[i] == NULL)
@@ -69,13 +72,15 @@ void unregister_ata_idle_func(ata_idle_notify func, bool run)
69 return; 72 return;
70} 73}
71 74
72bool call_ata_idle_notifys(bool sleep_after) 75bool call_ata_idle_notifys(bool force)
73{ 76{
74 int i; 77 int i;
78 static int lock_until = 0;
75 ata_idle_notify function; 79 ata_idle_notify function;
76 if (ata_callback_count == 0) 80 if (!force && TIME_BEFORE(current_tick,lock_until) )
77 return false; 81 return false;
78 ata_callback_count = 0; /* so we dont re-enter every time the callbacks read/write */ 82 lock_until = current_tick + 30*HZ;
83
79 for (i = 0; i < MAX_ATA_CALLBACKS; i++) 84 for (i = 0; i < MAX_ATA_CALLBACKS; i++)
80 { 85 {
81 if (ata_idle_notify_funcs[i]) 86 if (ata_idle_notify_funcs[i])
@@ -83,10 +88,9 @@ bool call_ata_idle_notifys(bool sleep_after)
83 function = ata_idle_notify_funcs[i]; 88 function = ata_idle_notify_funcs[i];
84 ata_idle_notify_funcs[i] = NULL; 89 ata_idle_notify_funcs[i] = NULL;
85 function(); 90 function();
91 ata_callback_count--;
86 } 92 }
87 } 93 }
88 if (sleep_after)
89 ata_sleep();
90 return true; 94 return true;
91} 95}
92 96
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index bb8eef9dd9..0de2eb1804 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -1285,7 +1285,7 @@ static void ata_thread(void)
1285 break; 1285 break;
1286#endif 1286#endif
1287 case Q_SLEEP: 1287 case Q_SLEEP:
1288 call_ata_idle_notifys(true); 1288 call_ata_idle_notifys(false);
1289 last_disk_activity = current_tick - sleep_timeout + (HZ/2); 1289 last_disk_activity = current_tick - sleep_timeout + (HZ/2);
1290 break; 1290 break;
1291 1291
diff --git a/firmware/export/ata_idle_notify.h b/firmware/export/ata_idle_notify.h
index 65c181302a..ee825c967e 100644
--- a/firmware/export/ata_idle_notify.h
+++ b/firmware/export/ata_idle_notify.h
@@ -44,10 +44,10 @@ extern bool register_ata_idle_func(ata_idle_notify function);
44#if USING_ATA_CALLBACK 44#if USING_ATA_CALLBACK
45extern void ata_idle_notify_init(void); 45extern void ata_idle_notify_init(void);
46extern void unregister_ata_idle_func(ata_idle_notify function, bool run); 46extern void unregister_ata_idle_func(ata_idle_notify function, bool run);
47extern bool call_ata_idle_notifys(bool sleep_after); 47extern bool call_ata_idle_notifys(bool force);
48#else 48#else
49#define unregister_ata_idle_func(f,r) 49#define unregister_ata_idle_func(f,r)
50#define call_ata_idle_notifys(s) 50#define call_ata_idle_notifys(f)
51#define ata_idle_notify_init(s) 51#define ata_idle_notify_init(s)
52#endif 52#endif
53 53