forked from luck/tmp_suning_uos_patched
uio: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "Hans J. Koch" <hjk@hansjkoch.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
6deb69face
commit
6d77093129
|
@ -369,26 +369,15 @@ static void uio_dev_del_attributes(struct uio_device *idev)
|
||||||
static int uio_get_minor(struct uio_device *idev)
|
static int uio_get_minor(struct uio_device *idev)
|
||||||
{
|
{
|
||||||
int retval = -ENOMEM;
|
int retval = -ENOMEM;
|
||||||
int id;
|
|
||||||
|
|
||||||
mutex_lock(&minor_lock);
|
mutex_lock(&minor_lock);
|
||||||
if (idr_pre_get(&uio_idr, GFP_KERNEL) == 0)
|
retval = idr_alloc(&uio_idr, idev, 0, UIO_MAX_DEVICES, GFP_KERNEL);
|
||||||
goto exit;
|
if (retval >= 0) {
|
||||||
|
idev->minor = retval;
|
||||||
retval = idr_get_new(&uio_idr, idev, &id);
|
} else if (retval == -ENOSPC) {
|
||||||
if (retval < 0) {
|
|
||||||
if (retval == -EAGAIN)
|
|
||||||
retval = -ENOMEM;
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
if (id < UIO_MAX_DEVICES) {
|
|
||||||
idev->minor = id;
|
|
||||||
} else {
|
|
||||||
dev_err(idev->dev, "too many uio devices\n");
|
dev_err(idev->dev, "too many uio devices\n");
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
idr_remove(&uio_idr, id);
|
|
||||||
}
|
}
|
||||||
exit:
|
|
||||||
mutex_unlock(&minor_lock);
|
mutex_unlock(&minor_lock);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user