1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 Jonathan Gordon
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
22 #include "ata_idle_notify.h"
26 void register_ata_idle_func(ata_idle_notify function
)
28 #if USING_ATA_CALLBACK
29 add_event(DISK_EVENT_SPINUP
, true, function
);
31 function(); /* just call the function now */
32 /* this _may_ cause problems later if the calling function
33 sets a variable expecting the callback to unset it, because
34 the callback will be run before this function exits, so before the var is set */
38 #if USING_ATA_CALLBACK
39 void unregister_ata_idle_func(ata_idle_notify func
, bool run
)
41 remove_event(DISK_EVENT_SPINUP
, func
);
47 bool call_ata_idle_notifys(bool force
)
49 static int lock_until
= 0;
53 if (TIME_BEFORE(current_tick
,lock_until
) )
56 lock_until
= current_tick
+ 30*HZ
;
58 send_event(DISK_EVENT_SPINUP
, NULL
);