4 * @brief Provides the subdevice lock class.
5 * @note Copyright (C) 2006 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
12 #include <linux/spinlock.h>
17 * @brief The subdevice lock class.
19 typedef struct me_slock {
20 struct file *filep; /**< Pointer to file structure holding the subdevice. */
21 int count; /**< Number of tasks which are inside the subdevice. */
22 spinlock_t spin_lock; /**< Spin lock protecting the attributes from concurrent access. */
26 * @brief Tries to enter a subdevice.
28 * @param slock The subdevice lock instance.
29 * @param filep The file structure identifying the calling process.
31 * @return 0 on success.
33 int me_slock_enter(struct me_slock *slock, struct file *filep);
36 * @brief Exits a subdevice.
38 * @param slock The subdevice lock instance.
39 * @param filep The file structure identifying the calling process.
41 * @return 0 on success.
43 int me_slock_exit(struct me_slock *slock, struct file *filep);
46 * @brief Tries to perform a locking action on a subdevice.
48 * @param slock The subdevice lock instance.
49 * @param filep The file structure identifying the calling process.
50 * @param The action to be done.
52 * @return 0 on success.
54 int me_slock_lock(struct me_slock *slock, struct file *filep, int lock);
57 * @brief Initializes a lock structure.
59 * @param slock The lock structure to initialize.
60 * @return 0 on success.
62 int me_slock_init(me_slock_t * slock);
65 * @brief Deinitializes a lock structure.
67 * @param slock The lock structure to deinitialize.
68 * @return 0 on success.
70 void me_slock_deinit(me_slock_t * slock);