Commit 3b443fe0 authored by Takashi Sakamoto's avatar Takashi Sakamoto

firewire: core: minor code refactoring to release client resource

Current implementation checks and validates the result to find resource
entry two times. It is redundant.

This commit refactors the redundancy.

Link: https://lore.kernel.org/r/20240812235210.28458-2-o-takashi@sakamocchi.jpSigned-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
parent 7a0a57cf
......@@ -512,15 +512,14 @@ static int release_client_resource(struct client *client, u32 handle,
scoped_guard(spinlock_irq, &client->lock) {
if (client->in_shutdown)
resource = NULL;
else
resource = idr_find(&client->resource_idr, handle);
if (resource && resource->release == release)
idr_remove(&client->resource_idr, handle);
}
return -EINVAL;
if (!(resource && resource->release == release))
return -EINVAL;
resource = idr_find(&client->resource_idr, handle);
if (!resource || resource->release != release)
return -EINVAL;
idr_remove(&client->resource_idr, handle);
}
if (return_resource)
*return_resource = resource;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment