]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
greybus: vibrator: convert idr to be an ida
authorGreg Kroah-Hartman <gregkh@google.com>
Thu, 14 May 2015 17:39:35 +0000 (10:39 -0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 14 May 2015 20:35:10 +0000 (13:35 -0700)
All we need is a simple ida, so use that interface instead of the more
"complex" idr one.  Bonus is we don't need to fix the locking issue I
forgot about when using an idr, as ida has one built-in.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
drivers/staging/greybus/vibrator.c

index aefd2cd3f18e4c35b0f7a0960efa7a5d8c6d032e..20f09bba5fac6b805a0104ea97e6c6c2b506c420 100644 (file)
@@ -93,7 +93,7 @@ static struct class vibrator_class = {
 #endif
 };
 
-static DEFINE_IDR(minors);
+static DEFINE_IDA(minors);
 
 static int gb_vibrator_connection_init(struct gb_connection *connection)
 {
@@ -117,7 +117,7 @@ static int gb_vibrator_connection_init(struct gb_connection *connection)
         * there is a "real" device somewhere in the kernel for this, but I
         * can't find it at the moment...
         */
-       vib->minor = idr_alloc(&minors, vib, 0, 0, GFP_KERNEL);
+       vib->minor = ida_simple_get(&minors, 0, 0, GFP_KERNEL);
        if (vib->minor < 0) {
                retval = vib->minor;
                goto error;
@@ -126,7 +126,7 @@ static int gb_vibrator_connection_init(struct gb_connection *connection)
                            "vibrator%d", vib->minor);
        if (IS_ERR(dev)) {
                retval = -EINVAL;
-               goto err_idr_remove;
+               goto err_ida_remove;
        }
        vib->dev = dev;
 
@@ -139,14 +139,14 @@ static int gb_vibrator_connection_init(struct gb_connection *connection)
        retval = sysfs_create_group(&dev->kobj, vibrator_groups[0]);
        if (retval) {
                device_unregister(dev);
-               goto err_idr_remove;
+               goto err_ida_remove;
        }
 #endif
 
        return 0;
 
-err_idr_remove:
-       idr_remove(&minors, vib->minor);
+err_ida_remove:
+       ida_simple_remove(&minors, vib->minor);
 error:
        kfree(vib);
        return retval;
@@ -159,7 +159,7 @@ static void gb_vibrator_connection_exit(struct gb_connection *connection)
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(3,11,0)
        sysfs_remove_group(&vib->dev->kobj, vibrator_groups[0]);
 #endif
-       idr_remove(&minors, vib->minor);
+       ida_simple_remove(&minors, vib->minor);
        device_unregister(vib->dev);
        kfree(vib);
 }