]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/firewire/core-cdev.c
Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211
[karo-tx-linux.git] / drivers / firewire / core-cdev.c
index f8d22872d75324e4dd0b2727308804f8a139eefe..27ac423ab25e26e3a78defb81fcdad21b1050f9d 100644 (file)
@@ -487,27 +487,28 @@ static int ioctl_get_info(struct client *client, union ioctl_arg *arg)
 static int add_client_resource(struct client *client,
                               struct client_resource *resource, gfp_t gfp_mask)
 {
+       bool preload = gfp_mask & __GFP_WAIT;
        unsigned long flags;
        int ret;
 
- retry:
-       if (idr_pre_get(&client->resource_idr, gfp_mask) == 0)
-               return -ENOMEM;
-
+       if (preload)
+               idr_preload(gfp_mask);
        spin_lock_irqsave(&client->lock, flags);
+
        if (client->in_shutdown)
                ret = -ECANCELED;
        else
-               ret = idr_get_new(&client->resource_idr, resource,
-                                 &resource->handle);
+               ret = idr_alloc(&client->resource_idr, resource, 0, 0,
+                               GFP_NOWAIT);
        if (ret >= 0) {
+               resource->handle = ret;
                client_get(client);
                schedule_if_iso_resource(resource);
        }
-       spin_unlock_irqrestore(&client->lock, flags);
 
-       if (ret == -EAGAIN)
-               goto retry;
+       spin_unlock_irqrestore(&client->lock, flags);
+       if (preload)
+               idr_preload_end();
 
        return ret < 0 ? ret : 0;
 }
@@ -1779,7 +1780,6 @@ static int fw_device_op_release(struct inode *inode, struct file *file)
        wait_event(client->tx_flush_wait, !has_outbound_transactions(client));
 
        idr_for_each(&client->resource_idr, shutdown_resource, client);
-       idr_remove_all(&client->resource_idr);
        idr_destroy(&client->resource_idr);
 
        list_for_each_entry_safe(event, next_event, &client->event_list, link)