Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sync.h
Go to the documentation of this file.
1 /*
2  * sync.h
3  *
4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5  *
6  * Provide synchronization services.
7  *
8  * Copyright (C) 2005-2006 Texas Instruments, Inc.
9  *
10  * This package is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17  */
18 
19 #ifndef _SYNC_H
20 #define _SYNC_H
21 
22 #include <dspbridge/dbdefs.h>
23 #include <dspbridge/host_os.h>
24 
25 
26 /* Special timeout value indicating an infinite wait: */
27 #define SYNC_INFINITE 0xffffffff
28 
35 struct sync_object{
36  struct completion comp;
38 };
39 
47 static inline void sync_init_event(struct sync_object *event)
48 {
49  init_completion(&event->comp);
50  event->multi_comp = NULL;
51 }
52 
60 static inline void sync_reset_event(struct sync_object *event)
61 {
62  INIT_COMPLETION(event->comp);
63  event->multi_comp = NULL;
64 }
65 
74 void sync_set_event(struct sync_object *event);
75 
87 static inline int sync_wait_on_event(struct sync_object *event,
88  unsigned timeout)
89 {
90  int res;
91 
93  msecs_to_jiffies(timeout));
94  if (!res)
95  res = -ETIME;
96  else if (res > 0)
97  res = 0;
98 
99  return res;
100 }
101 
116  unsigned count, unsigned timeout,
117  unsigned *index);
118 
119 #endif /* _SYNC_H */