4 * @brief Provides the device 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 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. */
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
);
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
);
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
);
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
);
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
);