added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / drivers / staging / meilhaus / medlock.h
blob4d6ddc8e58a183f3880932e6305e9599b2ef77ec
1 /**
2 * @file medlock.h
4 * @brief Provides the device lock class.
5 * @note Copyright (C) 2006 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
7 */
9 #ifndef _MEDLOCK_H_
10 #define _MEDLOCK_H_
12 #include <linux/spinlock.h>
14 #ifdef __KERNEL__
16 /**
17 * @brief The device lock class.
19 typedef struct me_dlock {
20 struct file *filep; /**< Pointer to file structure holding the device. */
21 int count; /**< Number of tasks which are inside the device. */
22 spinlock_t spin_lock; /**< Spin lock protecting the attributes from concurrent access. */
23 } me_dlock_t;
25 /**
26 * @brief Tries to enter a device.
28 * @param dlock The device lock instance.
29 * @param filep The file structure identifying the calling process.
31 * @return 0 on success.
33 int me_dlock_enter(struct me_dlock *dlock, struct file *filep);
35 /**
36 * @brief Exits a device.
38 * @param dlock The device lock instance.
39 * @param filep The file structure identifying the calling process.
41 * @return 0 on success.
43 int me_dlock_exit(struct me_dlock *dlock, struct file *filep);
45 /**
46 * @brief Tries to perform a locking action on a device.
48 * @param dlock The device lock instance.
49 * @param filep The file structure identifying the calling process.
50 * @param The action to be done.
51 * @param flags Flags from user space.
52 * @param slist The subdevice list of the device.
54 * @return 0 on success.
56 int me_dlock_lock(struct me_dlock *dlock,
57 struct file *filep, int lock, int flags, me_slist_t * slist);
59 /**
60 * @brief Initializes a lock structure.
62 * @param dlock The lock structure to initialize.
63 * @return 0 on success.
65 int me_dlock_init(me_dlock_t * dlock);
67 /**
68 * @brief Deinitializes a lock structure.
70 * @param dlock The lock structure to deinitialize.
71 * @return 0 on success.
73 void me_dlock_deinit(me_dlock_t * dlock);
75 #endif
76 #endif