diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:05 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:15 -0500 |
commit | 37b61890d757f606c25ac5a247572cb7d5efde96 (patch) | |
tree | b81abfb289f4d2be4ee77a2b555c26bde6dae6e7 /drivers/firewire/core-device.c | |
parent | 3bec60d511179853138836ae6e1b61fe34d9235f (diff) |
firewire: convert to idr_alloc()
Convert to the much saner new idr interface.
v2: Stefan pointed out that add_client_resource() may be called from
non-process context. Preload iff @gfp_mask contains __GFP_WAIT.
Also updated to include minor upper limit check.
[tim.gardner@canonical.com: fix accidentally orphaned 'minor'[
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/firewire/core-device.c')
-rw-r--r-- | drivers/firewire/core-device.c | 11 |
1 files changed, 3 insertions, 8 deletions
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; |