staging: tidspbridge: remove IN modifier
[linux-2.6.git] / drivers / staging / tidspbridge / include / dspbridge / sync.h
blobe2651e7b1c4288bde442cc89ccfcc73e5e5e61e3
1 /*
2 * sync.h
4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * Provide synchronization services.
8 * Copyright (C) 2005-2006 Texas Instruments, Inc.
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.
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.
19 #ifndef _SYNC_H
20 #define _SYNC_H
22 #include <dspbridge/dbdefs.h>
25 /* Special timeout value indicating an infinite wait: */
26 #define SYNC_INFINITE 0xffffffff
28 /**
29 * struct sync_object - the basic sync_object structure
30 * @comp: use to signal events
31 * @multi_comp: use to signal multiple events.
34 struct sync_object{
35 struct completion comp;
36 struct completion *multi_comp;
39 /**
40 * sync_init_event() - set initial state for a sync_event element
41 * @event: event to be initialized.
43 * Set the initial state for a sync_event element.
46 static inline void sync_init_event(struct sync_object *event)
48 init_completion(&event->comp);
49 event->multi_comp = NULL;
52 /**
53 * sync_reset_event() - reset a sync_event element
54 * @event: event to be reset.
56 * This function reset to the initial state to @event.
59 static inline void sync_reset_event(struct sync_object *event)
61 INIT_COMPLETION(event->comp);
62 event->multi_comp = NULL;
65 /**
66 * sync_set_event() - set or signal and specified event
67 * @event: Event to be set..
69 * set the @event, if there is an thread waiting for the event
70 * it will be waken up, this function only wakes one thread.
73 void sync_set_event(struct sync_object *event);
75 /**
76 * sync_wait_on_event() - waits for a event to be set.
77 * @event: events to wait for it.
78 * @timeout timeout on waiting for the evetn.
80 * This functios will wait until @event is set or until timeout. In case of
81 * success the function will return 0 and
82 * in case of timeout the function will return -ETIME
85 static inline int sync_wait_on_event(struct sync_object *event,
86 unsigned timeout)
88 return wait_for_completion_timeout(&event->comp,
89 msecs_to_jiffies(timeout)) ? 0 : -ETIME;
92 /**
93 * sync_wait_on_multiple_events() - waits for multiple events to be set.
94 * @events: Array of events to wait for them.
95 * @count: number of elements of the array.
96 * @timeout timeout on waiting for the evetns.
97 * @pu_index index of the event set.
99 * This functios will wait until any of the array element is set or until
100 * timeout. In case of success the function will return 0 and
101 * @pu_index will store the index of the array element set and in case
102 * of timeout the function will return -ETIME.
105 int sync_wait_on_multiple_events(struct sync_object **events,
106 unsigned count, unsigned timeout,
107 unsigned *index);
109 #endif /* _SYNC_H */