Commit 6b17492e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

greybus: vibrator: convert idr to be an ida

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: default avatarGreg Kroah-Hartman <gregkh@google.com>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
parent 6f8528e0
...@@ -93,7 +93,7 @@ static struct class vibrator_class = { ...@@ -93,7 +93,7 @@ static struct class vibrator_class = {
#endif #endif
}; };
static DEFINE_IDR(minors); static DEFINE_IDA(minors);
static int gb_vibrator_connection_init(struct gb_connection *connection) static int gb_vibrator_connection_init(struct gb_connection *connection)
{ {
...@@ -117,7 +117,7 @@ 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 * there is a "real" device somewhere in the kernel for this, but I
* can't find it at the moment... * 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) { if (vib->minor < 0) {
retval = vib->minor; retval = vib->minor;
goto error; goto error;
...@@ -126,7 +126,7 @@ static int gb_vibrator_connection_init(struct gb_connection *connection) ...@@ -126,7 +126,7 @@ static int gb_vibrator_connection_init(struct gb_connection *connection)
"vibrator%d", vib->minor); "vibrator%d", vib->minor);
if (IS_ERR(dev)) { if (IS_ERR(dev)) {
retval = -EINVAL; retval = -EINVAL;
goto err_idr_remove; goto err_ida_remove;
} }
vib->dev = dev; vib->dev = dev;
...@@ -139,14 +139,14 @@ static int gb_vibrator_connection_init(struct gb_connection *connection) ...@@ -139,14 +139,14 @@ static int gb_vibrator_connection_init(struct gb_connection *connection)
retval = sysfs_create_group(&dev->kobj, vibrator_groups[0]); retval = sysfs_create_group(&dev->kobj, vibrator_groups[0]);
if (retval) { if (retval) {
device_unregister(dev); device_unregister(dev);
goto err_idr_remove; goto err_ida_remove;
} }
#endif #endif
return 0; return 0;
err_idr_remove: err_ida_remove:
idr_remove(&minors, vib->minor); ida_simple_remove(&minors, vib->minor);
error: error:
kfree(vib); kfree(vib);
return retval; return retval;
...@@ -159,7 +159,7 @@ static void gb_vibrator_connection_exit(struct gb_connection *connection) ...@@ -159,7 +159,7 @@ static void gb_vibrator_connection_exit(struct gb_connection *connection)
#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,11,0) #if LINUX_VERSION_CODE <= KERNEL_VERSION(3,11,0)
sysfs_remove_group(&vib->dev->kobj, vibrator_groups[0]); sysfs_remove_group(&vib->dev->kobj, vibrator_groups[0]);
#endif #endif
idr_remove(&minors, vib->minor); ida_simple_remove(&minors, vib->minor);
device_unregister(vib->dev); device_unregister(vib->dev);
kfree(vib); kfree(vib);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment