summaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2016-12-22 13:30:22 -0500
committerMatthew Wilcox <mawilcox@microsoft.com>2017-02-13 21:44:03 -0500
commitd3e709e63e97e5f3f129b639991cfe266da60bae (patch)
tree78647f4029b9e83087fefa19144a689f6909f8d2 /drivers/target
parent8ac04868315c6ffcb2c5a5ad9cd5cec61cad3576 (diff)
idr: Return the deleted entry from idr_remove
It is a relatively common idiom (8 instances) to first look up an IDR entry, and then remove it from the tree if it is found, possibly doing further operations upon the entry afterwards. If we change idr_remove() to return the removed object, all of these users can save themselves a walk of the IDR tree. Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_user.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 8041710b6972..18f0ec2e1f9c 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -642,9 +642,7 @@ static unsigned int tcmu_handle_completions(struct tcmu_dev *udev)
642 WARN_ON(tcmu_hdr_get_op(entry->hdr.len_op) != TCMU_OP_CMD); 642 WARN_ON(tcmu_hdr_get_op(entry->hdr.len_op) != TCMU_OP_CMD);
643 643
644 spin_lock(&udev->commands_lock); 644 spin_lock(&udev->commands_lock);
645 cmd = idr_find(&udev->commands, entry->hdr.cmd_id); 645 cmd = idr_remove(&udev->commands, entry->hdr.cmd_id);
646 if (cmd)
647 idr_remove(&udev->commands, cmd->cmd_id);
648 spin_unlock(&udev->commands_lock); 646 spin_unlock(&udev->commands_lock);
649 647
650 if (!cmd) { 648 if (!cmd) {