提交 7ee7c12b 编写于 作者: A Alexey Dobriyan 提交者: Al Viro

[PATCH] devpts: switch to IDA

Devpts code wants just numbers for tty indexes.
Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 9a185409
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#define DEVPTS_DEFAULT_MODE 0600 #define DEVPTS_DEFAULT_MODE 0600
extern int pty_limit; /* Config limit on Unix98 ptys */ extern int pty_limit; /* Config limit on Unix98 ptys */
static DEFINE_IDR(allocated_ptys); static DEFINE_IDA(allocated_ptys);
static DEFINE_MUTEX(allocated_ptys_lock); static DEFINE_MUTEX(allocated_ptys_lock);
static struct vfsmount *devpts_mnt; static struct vfsmount *devpts_mnt;
...@@ -180,24 +180,24 @@ static struct dentry *get_node(int num) ...@@ -180,24 +180,24 @@ static struct dentry *get_node(int num)
int devpts_new_index(void) int devpts_new_index(void)
{ {
int index; int index;
int idr_ret; int ida_ret;
retry: retry:
if (!idr_pre_get(&allocated_ptys, GFP_KERNEL)) { if (!ida_pre_get(&allocated_ptys, GFP_KERNEL)) {
return -ENOMEM; return -ENOMEM;
} }
mutex_lock(&allocated_ptys_lock); mutex_lock(&allocated_ptys_lock);
idr_ret = idr_get_new(&allocated_ptys, NULL, &index); ida_ret = ida_get_new(&allocated_ptys, &index);
if (idr_ret < 0) { if (ida_ret < 0) {
mutex_unlock(&allocated_ptys_lock); mutex_unlock(&allocated_ptys_lock);
if (idr_ret == -EAGAIN) if (ida_ret == -EAGAIN)
goto retry; goto retry;
return -EIO; return -EIO;
} }
if (index >= pty_limit) { if (index >= pty_limit) {
idr_remove(&allocated_ptys, index); ida_remove(&allocated_ptys, index);
mutex_unlock(&allocated_ptys_lock); mutex_unlock(&allocated_ptys_lock);
return -EIO; return -EIO;
} }
...@@ -208,7 +208,7 @@ int devpts_new_index(void) ...@@ -208,7 +208,7 @@ int devpts_new_index(void)
void devpts_kill_index(int idx) void devpts_kill_index(int idx)
{ {
mutex_lock(&allocated_ptys_lock); mutex_lock(&allocated_ptys_lock);
idr_remove(&allocated_ptys, idx); ida_remove(&allocated_ptys, idx);
mutex_unlock(&allocated_ptys_lock); mutex_unlock(&allocated_ptys_lock);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册