diff options
| author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2026-05-01 22:58:21 +0900 |
|---|---|---|
| committer | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2026-05-03 20:44:21 +0900 |
| commit | 92750bccf01f2e65976429acee06984a95803354 (patch) | |
| tree | 509748f343812d87f259763e5860824fb80cfcd3 /drivers/firewire/core-cdev.c | |
| parent | 834b33f9c95174606b25848b43b32432a3e98713 (diff) | |
| download | linux-next-92750bccf01f2e65976429acee06984a95803354.tar.gz linux-next-92750bccf01f2e65976429acee06984a95803354.zip | |
firewire: core: use switch statement for post-processing of isoc resource management in cdev
The iso_resource_auto structure object has three states. The current
implementation of state evaluation before managing the actual isochronous
resources can be improved.
This commit refactors the evaluation logic using a switch statement.
Link: https://lore.kernel.org/r/20260501135823.241940-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Diffstat (limited to 'drivers/firewire/core-cdev.c')
| -rw-r--r-- | drivers/firewire/core-cdev.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 887783e4bd52..0d57b61ade12 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c @@ -1331,7 +1331,7 @@ static void iso_resource_auto_work(struct work_struct *work) unsigned long index = r->resource.handle; int current_generation, resource_generation, channel, bandwidth, todo; u64 reset_jiffies; - bool skip, free, success; + bool free = false, success; scoped_guard(spinlock_irq, &client->lock) { reset_jiffies = client->device->card->reset_jiffies; @@ -1341,27 +1341,29 @@ static void iso_resource_auto_work(struct work_struct *work) todo = r->todo; } - // Allow 1000ms grace period for other reallocations. - if (todo == ISO_RES_AUTO_ALLOC && - time_is_after_jiffies64(reset_jiffies + secs_to_jiffies(1))) { - schedule_iso_resource_auto(r, msecs_to_jiffies(333)); - skip = true; - } else { + switch (todo) { + case ISO_RES_AUTO_ALLOC: + // Allow 1000ms grace period for other reallocations. + if (time_is_after_jiffies64(reset_jiffies + secs_to_jiffies(1))) { + schedule_iso_resource_auto(r, msecs_to_jiffies(333)); + goto out; + } + break; + case ISO_RES_AUTO_REALLOC: // We could be called twice within the same generation. - skip = todo == ISO_RES_AUTO_REALLOC && - resource_generation == current_generation; + if (resource_generation == current_generation) + goto out; + break; + case ISO_RES_AUTO_DEALLOC: + default: + break; } - free = todo == ISO_RES_AUTO_DEALLOC; - - if (skip) - goto out; bandwidth = r->params.bandwidth; - fw_iso_resource_manage(client->device->card, current_generation, - r->params.channels, &channel, &bandwidth, - todo == ISO_RES_AUTO_ALLOC || - todo == ISO_RES_AUTO_REALLOC); + fw_iso_resource_manage(client->device->card, current_generation, r->params.channels, + &channel, &bandwidth, todo != ISO_RES_AUTO_DEALLOC); + /* * Is this generation outdated already? As long as this resource sticks * in the xarray, it will be scheduled again for a newer generation or at @@ -1398,6 +1400,7 @@ static void iso_resource_auto_work(struct work_struct *work) e = r->e_alloc; r->e_alloc = NULL; } else { + free = true; e = r->e_dealloc; r->e_dealloc = NULL; } |
