base: genlock: Remove genlock_release_lock and associated ioctl

Allowing a lock to be asynchronously released while a handle
was still active turned out to be too dangerous to use in a
multi-threaded environment and it served no pratical
purpose anyway.  Handles now hold an attached lock until they
are destroyed.

CRs-fixed: 333141
Change-Id: Ic0dedbad8050ff01927ddb165c65a939bf297c10
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
This commit is contained in:
Jordan Crouse
2012-01-25 14:40:51 -07:00
parent a73ed09742
commit 4df70a254d
3 changed files with 14 additions and 18 deletions

View File

@@ -82,15 +82,13 @@ descriptor.
Release a handle. Release a handle.
* struct genlock * genlock_create_lock(struct genlock_handle *) * struct genlock * genlock_create_lock(struct genlock_handle *)
Create a new lock and attach it to the handle. Create a new lock and attach it to the handle. Once a lock is attached to a
handle it stays attached until the handle is destroyed.
* struct genlock * genlock_attach_lock(struct genlock_handle *handle, int fd) * struct genlock * genlock_attach_lock(struct genlock_handle *handle, int fd)
Given a valid file descriptor, get the lock associated with it and attach it to Given a valid file descriptor, get the lock associated with it and attach it to
the handle. the handle.
* void genlock_release_lock(struct genlock_handle *)
Release a lock attached to a handle.
* int genlock_lock(struct genlock_handle *, int op, int flags, u32 timeout) * int genlock_lock(struct genlock_handle *, int op, int flags, u32 timeout)
Lock or unlock the lock attached to the handle. A zero timeout value will Lock or unlock the lock attached to the handle. A zero timeout value will
be treated just like if the GENOCK_NOBLOCK flag is passed; if the lock be treated just like if the GENOCK_NOBLOCK flag is passed; if the lock
@@ -155,7 +153,4 @@ passed in genlock_lock.timeout. Returns 0 when the lock has been released,
-EINVAL if a zero timeout is passed, or -ETIMEDOUT if the timeout expires. -EINVAL if a zero timeout is passed, or -ETIMEDOUT if the timeout expires.
* GENLOCK_IOC_RELEASE * GENLOCK_IOC_RELEASE
Use this to release an existing lock. This is useful if you wish to attach a This ioctl has been deprecated. Do not use.
different lock to the same handle. You do not need to call this under normal
circumstances; when the handle is closed the reference to the lock is released.
No data is passed from the user for this ioctl.

View File

@@ -496,12 +496,7 @@ done:
return ret; return ret;
} }
/** static void genlock_release_lock(struct genlock_handle *handle)
* genlock_release_lock - Release a lock attached to a handle
* @handle - Pointer to the handle holding the lock
*/
void genlock_release_lock(struct genlock_handle *handle)
{ {
unsigned long flags; unsigned long flags;
@@ -522,7 +517,6 @@ void genlock_release_lock(struct genlock_handle *handle)
handle->lock = NULL; handle->lock = NULL;
handle->active = 0; handle->active = 0;
} }
EXPORT_SYMBOL(genlock_release_lock);
/* /*
* Release function called when all references to a handle are released * Release function called when all references to a handle are released
@@ -671,8 +665,13 @@ static long genlock_dev_ioctl(struct file *filep, unsigned int cmd,
return genlock_wait(handle, param.timeout); return genlock_wait(handle, param.timeout);
} }
case GENLOCK_IOC_RELEASE: { case GENLOCK_IOC_RELEASE: {
genlock_release_lock(handle); /*
return 0; * Return error - this ioctl has been deprecated.
* Locks should only be released when the handle is
* destroyed
*/
GENLOCK_LOG_ERR("Deprecated RELEASE ioctl called\n");
return -EINVAL;
} }
default: default:
GENLOCK_LOG_ERR("Invalid ioctl\n"); GENLOCK_LOG_ERR("Invalid ioctl\n");

View File

@@ -12,7 +12,7 @@ void genlock_put_handle(struct genlock_handle *handle);
struct genlock *genlock_create_lock(struct genlock_handle *); struct genlock *genlock_create_lock(struct genlock_handle *);
struct genlock *genlock_attach_lock(struct genlock_handle *, int fd); struct genlock *genlock_attach_lock(struct genlock_handle *, int fd);
int genlock_wait(struct genlock_handle *handle, u32 timeout); int genlock_wait(struct genlock_handle *handle, u32 timeout);
void genlock_release_lock(struct genlock_handle *); /* genlock_release_lock was deprecated */
int genlock_lock(struct genlock_handle *handle, int op, int flags, int genlock_lock(struct genlock_handle *handle, int op, int flags,
u32 timeout); u32 timeout);
#endif #endif
@@ -39,6 +39,8 @@ struct genlock_lock {
struct genlock_lock) struct genlock_lock)
#define GENLOCK_IOC_LOCK _IOW(GENLOCK_IOC_MAGIC, 3, \ #define GENLOCK_IOC_LOCK _IOW(GENLOCK_IOC_MAGIC, 3, \
struct genlock_lock) struct genlock_lock)
/* Deprecated */
#define GENLOCK_IOC_RELEASE _IO(GENLOCK_IOC_MAGIC, 4) #define GENLOCK_IOC_RELEASE _IO(GENLOCK_IOC_MAGIC, 4)
#define GENLOCK_IOC_WAIT _IOW(GENLOCK_IOC_MAGIC, 5, \ #define GENLOCK_IOC_WAIT _IOW(GENLOCK_IOC_MAGIC, 5, \
struct genlock_lock) struct genlock_lock)