diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2024-08-13 01:52:06 +0200 |
---|---|---|
committer | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2024-08-13 01:52:06 +0200 |
commit | 3b443fe087889cf6c9c133638f36da5617431703 (patch) | |
tree | c8e90cfc5b0e81a96555b222e0d536191a2f307c /drivers/firewire | |
parent | firewire: core: use lock in Xarray instead of local R/W semaphore (diff) | |
download | linux-3b443fe087889cf6c9c133638f36da5617431703.tar.xz linux-3b443fe087889cf6c9c133638f36da5617431703.zip |
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>
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/core-cdev.c | 15 |
1 files 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; |