1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 #include "ata_idle_notify.h"
28 void register_ata_idle_func(ata_idle_notify function
)
30 #if USING_ATA_CALLBACK
31 add_event(DISK_EVENT_SPINUP
, true, function
);
33 function(); /* just call the function now */
34 /* this _may_ cause problems later if the calling function
35 sets a variable expecting the callback to unset it, because
36 the callback will be run before this function exits, so before the var is set */
40 #if USING_ATA_CALLBACK
41 void unregister_ata_idle_func(ata_idle_notify func
, bool run
)
43 remove_event(DISK_EVENT_SPINUP
, func
);
49 bool call_ata_idle_notifys(bool force
)
51 static int lock_until
= 0;
55 if (TIME_BEFORE(current_tick
,lock_until
) )
58 lock_until
= current_tick
+ 30*HZ
;
60 send_event(DISK_EVENT_SPINUP
, NULL
);