[PATCH 1/5] firewire: core: minor code refactoring to release client resource
Brought to you by:
aeb,
bencollins
From: Takashi S. <o-t...@sa...> - 2024-08-12 23:52:26
|
Current implementation checks and validates the result to find resource entry two times. It is redundant. This commit refactors the redundancy. Signed-off-by: Takashi Sakamoto <o-t...@sa...> --- drivers/firewire/core-cdev.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index c211bb19c94e..81fdb2be9063 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -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; -- 2.43.0 |