mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 09:31:14 +00:00
fs/proc/generic.c: switch to ida_simple_get/remove
The code can be much simplified by switching to ida_simple_get/remove. Link: http://lkml.kernel.org/r/8d1cc9f7-5115-c9dc-028e-c0770b6bfe1f@gmail.com Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
b6d0f14abb
commit
cde1b69389
1 changed files with 7 additions and 25 deletions
|
@ -180,7 +180,6 @@ static int xlate_proc_name(const char *name, struct proc_dir_entry **ret,
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEFINE_IDA(proc_inum_ida);
|
static DEFINE_IDA(proc_inum_ida);
|
||||||
static DEFINE_SPINLOCK(proc_inum_lock); /* protects the above */
|
|
||||||
|
|
||||||
#define PROC_DYNAMIC_FIRST 0xF0000000U
|
#define PROC_DYNAMIC_FIRST 0xF0000000U
|
||||||
|
|
||||||
|
@ -190,37 +189,20 @@ static DEFINE_SPINLOCK(proc_inum_lock); /* protects the above */
|
||||||
*/
|
*/
|
||||||
int proc_alloc_inum(unsigned int *inum)
|
int proc_alloc_inum(unsigned int *inum)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
int i;
|
||||||
int error;
|
|
||||||
|
|
||||||
retry:
|
i = ida_simple_get(&proc_inum_ida, 0, UINT_MAX - PROC_DYNAMIC_FIRST + 1,
|
||||||
if (!ida_pre_get(&proc_inum_ida, GFP_KERNEL))
|
GFP_KERNEL);
|
||||||
return -ENOMEM;
|
if (i < 0)
|
||||||
|
return i;
|
||||||
|
|
||||||
spin_lock_irq(&proc_inum_lock);
|
*inum = PROC_DYNAMIC_FIRST + (unsigned int)i;
|
||||||
error = ida_get_new(&proc_inum_ida, &i);
|
|
||||||
spin_unlock_irq(&proc_inum_lock);
|
|
||||||
if (error == -EAGAIN)
|
|
||||||
goto retry;
|
|
||||||
else if (error)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
if (i > UINT_MAX - PROC_DYNAMIC_FIRST) {
|
|
||||||
spin_lock_irq(&proc_inum_lock);
|
|
||||||
ida_remove(&proc_inum_ida, i);
|
|
||||||
spin_unlock_irq(&proc_inum_lock);
|
|
||||||
return -ENOSPC;
|
|
||||||
}
|
|
||||||
*inum = PROC_DYNAMIC_FIRST + i;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void proc_free_inum(unsigned int inum)
|
void proc_free_inum(unsigned int inum)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
ida_simple_remove(&proc_inum_ida, inum - PROC_DYNAMIC_FIRST);
|
||||||
spin_lock_irqsave(&proc_inum_lock, flags);
|
|
||||||
ida_remove(&proc_inum_ida, inum - PROC_DYNAMIC_FIRST);
|
|
||||||
spin_unlock_irqrestore(&proc_inum_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue