blob: 60bc84c5363a119e7bb64320e97048944dc66da6 [file] [log] [blame]
Jordan Crouse29f66af2011-11-17 13:39:20 -07001#ifndef _GENLOCK_H_
2#define _GENLOCK_H_
3
Jeff Boody6d9076f2012-04-26 11:12:44 -06004#include <linux/bitops.h>
5
Jordan Crouse29f66af2011-11-17 13:39:20 -07006#ifdef __KERNEL__
7
8struct genlock;
9struct genlock_handle;
10
11struct genlock_handle *genlock_get_handle(void);
12struct genlock_handle *genlock_get_handle_fd(int fd);
13void genlock_put_handle(struct genlock_handle *handle);
14struct genlock *genlock_create_lock(struct genlock_handle *);
15struct genlock *genlock_attach_lock(struct genlock_handle *, int fd);
16int genlock_wait(struct genlock_handle *handle, u32 timeout);
Jordan Crouse4df70a22012-01-25 14:40:51 -070017/* genlock_release_lock was deprecated */
Jordan Crouse29f66af2011-11-17 13:39:20 -070018int genlock_lock(struct genlock_handle *handle, int op, int flags,
19 u32 timeout);
20#endif
21
22#define GENLOCK_UNLOCK 0
23#define GENLOCK_WRLOCK 1
24#define GENLOCK_RDLOCK 2
25
Jeff Boody6d9076f2012-04-26 11:12:44 -060026#define GENLOCK_NOBLOCK BIT(0)
27#define GENLOCK_WRITE_TO_READ BIT(1)
Jordan Crouse29f66af2011-11-17 13:39:20 -070028
29struct genlock_lock {
30 int fd;
31 int op;
32 int flags;
33 int timeout;
34};
35
36#define GENLOCK_IOC_MAGIC 'G'
37
38#define GENLOCK_IOC_NEW _IO(GENLOCK_IOC_MAGIC, 0)
39#define GENLOCK_IOC_EXPORT _IOR(GENLOCK_IOC_MAGIC, 1, \
40 struct genlock_lock)
41#define GENLOCK_IOC_ATTACH _IOW(GENLOCK_IOC_MAGIC, 2, \
42 struct genlock_lock)
Jeff Boody6d9076f2012-04-26 11:12:44 -060043
44/* Deprecated */
Jordan Crouse29f66af2011-11-17 13:39:20 -070045#define GENLOCK_IOC_LOCK _IOW(GENLOCK_IOC_MAGIC, 3, \
46 struct genlock_lock)
Jordan Crouse4df70a22012-01-25 14:40:51 -070047
48/* Deprecated */
Jordan Crouse29f66af2011-11-17 13:39:20 -070049#define GENLOCK_IOC_RELEASE _IO(GENLOCK_IOC_MAGIC, 4)
50#define GENLOCK_IOC_WAIT _IOW(GENLOCK_IOC_MAGIC, 5, \
51 struct genlock_lock)
Jeff Boody6d9076f2012-04-26 11:12:44 -060052#define GENLOCK_IOC_DREADLOCK _IOW(GENLOCK_IOC_MAGIC, 6, \
53 struct genlock_lock)
Jordan Crouse29f66af2011-11-17 13:39:20 -070054#endif