diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:47 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:19 -0500 |
commit | 6d770931291eec7e7be774a5272db28d29899a66 (patch) | |
tree | 42e2d59915de9875caf17b7548098f1c07c99225 | |
parent | 6deb69facebb2f9a2b15a8e5e33ab00ebc7c44cb (diff) |
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>
-rw-r--r-- | drivers/uio/uio.c | 19 |
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) | |||
369 | static int uio_get_minor(struct uio_device *idev) | 369 | static int uio_get_minor(struct uio_device *idev) |
370 | { | 370 | { |
371 | int retval = -ENOMEM; | 371 | int retval = -ENOMEM; |
372 | int id; | ||
373 | 372 | ||
374 | mutex_lock(&minor_lock); | 373 | mutex_lock(&minor_lock); |
375 | if (idr_pre_get(&uio_idr, GFP_KERNEL) == 0) | 374 | retval = idr_alloc(&uio_idr, idev, 0, UIO_MAX_DEVICES, GFP_KERNEL); |
376 | goto exit; | 375 | if (retval >= 0) { |
377 | 376 | idev->minor = retval; | |
378 | retval = idr_get_new(&uio_idr, idev, &id); | 377 | } else if (retval == -ENOSPC) { |
379 | if (retval < 0) { | ||
380 | if (retval == -EAGAIN) | ||
381 | retval = -ENOMEM; | ||
382 | goto exit; | ||
383 | } | ||
384 | if (id < UIO_MAX_DEVICES) { | ||
385 | idev->minor = id; | ||
386 | } else { | ||
387 | dev_err(idev->dev, "too many uio devices\n"); | 378 | dev_err(idev->dev, "too many uio devices\n"); |
388 | retval = -EINVAL; | 379 | retval = -EINVAL; |
389 | idr_remove(&uio_idr, id); | ||
390 | } | 380 | } |
391 | exit: | ||
392 | mutex_unlock(&minor_lock); | 381 | mutex_unlock(&minor_lock); |
393 | return retval; | 382 | return retval; |
394 | } | 383 | } |