aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/firewire/core-cdev.c19
-rw-r--r--drivers/firewire/core-device.c11
2 files changed, 13 insertions, 17 deletions
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 68c31381cd03..27ac423ab25e 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -487,27 +487,28 @@ static int ioctl_get_info(struct client *client, union ioctl_arg *arg)
487static int add_client_resource(struct client *client, 487static int add_client_resource(struct client *client,
488 struct client_resource *resource, gfp_t gfp_mask) 488 struct client_resource *resource, gfp_t gfp_mask)
489{ 489{
490 bool preload = gfp_mask & __GFP_WAIT;
490 unsigned long flags; 491 unsigned long flags;
491 int ret; 492 int ret;
492 493
493 retry: 494 if (preload)
494 if (idr_pre_get(&client->resource_idr, gfp_mask) == 0) 495 idr_preload(gfp_mask);
495 return -ENOMEM;
496
497 spin_lock_irqsave(&client->lock, flags); 496 spin_lock_irqsave(&client->lock, flags);
497
498 if (client->in_shutdown) 498 if (client->in_shutdown)
499 ret = -ECANCELED; 499 ret = -ECANCELED;
500 else 500 else
501 ret = idr_get_new(&client->resource_idr, resource, 501 ret = idr_alloc(&client->resource_idr, resource, 0, 0,
502 &resource->handle); 502 GFP_NOWAIT);
503 if (ret >= 0) { 503 if (ret >= 0) {
504 resource->handle = ret;
504 client_get(client); 505 client_get(client);
505 schedule_if_iso_resource(resource); 506 schedule_if_iso_resource(resource);
506 } 507 }
507 spin_unlock_irqrestore(&client->lock, flags);
508 508
509 if (ret == -EAGAIN) 509 spin_unlock_irqrestore(&client->lock, flags);
510 goto retry; 510 if (preload)
511 idr_preload_end();
511 512
512 return ret < 0 ? ret : 0; 513 return ret < 0 ? ret : 0;
513} 514}
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index af3e8aa5eedc..03ce7d980c6a 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -1017,16 +1017,11 @@ static void fw_device_init(struct work_struct *work)
1017 1017
1018 fw_device_get(device); 1018 fw_device_get(device);
1019 down_write(&fw_device_rwsem); 1019 down_write(&fw_device_rwsem);
1020 ret = idr_pre_get(&fw_device_idr, GFP_KERNEL) ? 1020 minor = idr_alloc(&fw_device_idr, device, 0, 1 << MINORBITS,
1021 idr_get_new(&fw_device_idr, device, &minor) : 1021 GFP_KERNEL);
1022 -ENOMEM;
1023 if (minor >= 1 << MINORBITS) {
1024 idr_remove(&fw_device_idr, minor);
1025 minor = -ENOSPC;
1026 }
1027 up_write(&fw_device_rwsem); 1022 up_write(&fw_device_rwsem);
1028 1023
1029 if (ret < 0) 1024 if (minor < 0)
1030 goto error; 1025 goto error;
1031 1026
1032 device->device.bus = &fw_bus_type; 1027 device->device.bus = &fw_bus_type;