summaryrefslogtreecommitdiffstats
path: root/drivers/uio
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-02-27 17:04:47 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 19:10:19 -0800
commit6d770931291eec7e7be774a5272db28d29899a66 (patch)
tree42e2d59915de9875caf17b7548098f1c07c99225 /drivers/uio
parent6deb69facebb2f9a2b15a8e5e33ab00ebc7c44cb (diff)
downloadlinux-6d770931291eec7e7be774a5272db28d29899a66.tar.gz
linux-6d770931291eec7e7be774a5272db28d29899a66.tar.bz2
linux-6d770931291eec7e7be774a5272db28d29899a66.zip
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>
Diffstat (limited to 'drivers/uio')
-rw-r--r--drivers/uio/uio.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 5110f367f1f1..c8b926291e28 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -369,26 +369,15 @@ static void uio_dev_del_attributes(struct uio_device *idev)
static int uio_get_minor(struct uio_device *idev)
{
int retval = -ENOMEM;
- int id;
mutex_lock(&minor_lock);
- if (idr_pre_get(&uio_idr, GFP_KERNEL) == 0)
- goto exit;
-
- retval = idr_get_new(&uio_idr, idev, &id);
- if (retval < 0) {
- if (retval == -EAGAIN)
- retval = -ENOMEM;
- goto exit;
- }
- if (id < UIO_MAX_DEVICES) {
- idev->minor = id;
- } else {
+ retval = idr_alloc(&uio_idr, idev, 0, UIO_MAX_DEVICES, GFP_KERNEL);
+ if (retval >= 0) {
+ idev->minor = retval;
+ } else if (retval == -ENOSPC) {
dev_err(idev->dev, "too many uio devices\n");
retval = -EINVAL;
- idr_remove(&uio_idr, id);
}
-exit:
mutex_unlock(&minor_lock);
return retval;
}