blob: 587c49df7444a7550a8c004e4f94753f68d84bc0 [file] [log] [blame]
Jordan Crouse29f66af2011-11-17 13:39:20 -07001#ifndef _GENLOCK_H_
2#define _GENLOCK_H_
3
4#ifdef __KERNEL__
5
6struct genlock;
7struct genlock_handle;
8
9struct genlock_handle *genlock_get_handle(void);
10struct genlock_handle *genlock_get_handle_fd(int fd);
11void genlock_put_handle(struct genlock_handle *handle);
12struct genlock *genlock_create_lock(struct genlock_handle *);
13struct genlock *genlock_attach_lock(struct genlock_handle *, int fd);
14int genlock_wait(struct genlock_handle *handle, u32 timeout);
Jordan Crouse4df70a22012-01-25 14:40:51 -070015/* genlock_release_lock was deprecated */
Jordan Crouse29f66af2011-11-17 13:39:20 -070016int genlock_lock(struct genlock_handle *handle, int op, int flags,
17 u32 timeout);
18#endif
19
20#define GENLOCK_UNLOCK 0
21#define GENLOCK_WRLOCK 1
22#define GENLOCK_RDLOCK 2
23
Jeff Boody09775102012-05-09 11:36:13 -060024#define GENLOCK_NOBLOCK (1 << 0)
25#define GENLOCK_WRITE_TO_READ (1 << 1)
Jordan Crouse29f66af2011-11-17 13:39:20 -070026
27struct genlock_lock {
28 int fd;
29 int op;
30 int flags;
31 int timeout;
32};
33
34#define GENLOCK_IOC_MAGIC 'G'
35
36#define GENLOCK_IOC_NEW _IO(GENLOCK_IOC_MAGIC, 0)
37#define GENLOCK_IOC_EXPORT _IOR(GENLOCK_IOC_MAGIC, 1, \
38 struct genlock_lock)
39#define GENLOCK_IOC_ATTACH _IOW(GENLOCK_IOC_MAGIC, 2, \
40 struct genlock_lock)
Jeff Boody6d9076f2012-04-26 11:12:44 -060041
42/* Deprecated */
Jordan Crouse29f66af2011-11-17 13:39:20 -070043#define GENLOCK_IOC_LOCK _IOW(GENLOCK_IOC_MAGIC, 3, \
44 struct genlock_lock)
Jordan Crouse4df70a22012-01-25 14:40:51 -070045
46/* Deprecated */
Jordan Crouse29f66af2011-11-17 13:39:20 -070047#define GENLOCK_IOC_RELEASE _IO(GENLOCK_IOC_MAGIC, 4)
48#define GENLOCK_IOC_WAIT _IOW(GENLOCK_IOC_MAGIC, 5, \
49 struct genlock_lock)
Jeff Boody6d9076f2012-04-26 11:12:44 -060050#define GENLOCK_IOC_DREADLOCK _IOW(GENLOCK_IOC_MAGIC, 6, \
51 struct genlock_lock)
Jordan Crouse29f66af2011-11-17 13:39:20 -070052#endif