Skip to content

Commit 3b443fe

Browse files
committed
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.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
1 parent 7a0a57c commit 3b443fe

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

drivers/firewire/core-cdev.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,15 +512,14 @@ static int release_client_resource(struct client *client, u32 handle,
512512

513513
scoped_guard(spinlock_irq, &client->lock) {
514514
if (client->in_shutdown)
515-
resource = NULL;
516-
else
517-
resource = idr_find(&client->resource_idr, handle);
518-
if (resource && resource->release == release)
519-
idr_remove(&client->resource_idr, handle);
520-
}
515+
return -EINVAL;
521516

522-
if (!(resource && resource->release == release))
523-
return -EINVAL;
517+
resource = idr_find(&client->resource_idr, handle);
518+
if (!resource || resource->release != release)
519+
return -EINVAL;
520+
521+
idr_remove(&client->resource_idr, handle);
522+
}
524523

525524
if (return_resource)
526525
*return_resource = resource;

0 commit comments

Comments
 (0)