ion: update idr to avoid deprecated apis
authorColin Cross <ccross@android.com>
Fri, 13 Dec 2013 22:25:05 +0000 (14:25 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2013 16:57:19 +0000 (08:57 -0800)
Use idr_alloc instead if idr_pre_get/idr_get_new_above, and
remove idr_remove_all.

Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/ion/ion.c

index 8d568caa0f33e63e7175af1cbf1bad5196f80745..199ab9ae0dcac3b7634949a5a51b77d81d887375 100644 (file)
@@ -432,22 +432,16 @@ static bool ion_handle_validate(struct ion_client *client, struct ion_handle *ha
 
 static int ion_handle_add(struct ion_client *client, struct ion_handle *handle)
 {
-       int rc;
+       int id;
        struct rb_node **p = &client->handles.rb_node;
        struct rb_node *parent = NULL;
        struct ion_handle *entry;
 
-       do {
-               int id;
-               rc = idr_pre_get(&client->idr, GFP_KERNEL);
-               if (!rc)
-                       return -ENOMEM;
-               rc = idr_get_new_above(&client->idr, handle, 1, &id);
-               handle->id = id;
-       } while (rc == -EAGAIN);
+       id = idr_alloc(&client->idr, handle, 1, 0, GFP_KERNEL);
+       if (id < 0)
+               return id;
 
-       if (rc < 0)
-               return rc;
+       handle->id = id;
 
        while (*p) {
                parent = *p;
@@ -786,7 +780,6 @@ void ion_client_destroy(struct ion_client *client)
                ion_handle_destroy(&handle->ref);
        }
 
-       idr_remove_all(&client->idr);
        idr_destroy(&client->idr);
 
        down_write(&dev->lock);