From: Takashi Sakamoto Date: Thu, 18 Sep 2025 23:54:44 +0000 (+0900) Subject: firewire: core: use switch statement to evaluate transaction result to CSR_BUS_MANAGER_ID X-Git-Tag: v6.18-rc1~159^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=52561ebfae9dc9871d6ca2c9e72a4a4e246c4476;p=thirdparty%2Fkernel%2Flinux.git firewire: core: use switch statement to evaluate transaction result to CSR_BUS_MANAGER_ID The result of the lock transaction to swap bus manager on isochronous resource manager looks like an ad-hoc style. It is hard to read. This commit uses switch statement to evaluate the result. Link: https://lore.kernel.org/r/20250918235448.129705-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto --- diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index ef00125fb01ac..e9bf8d93f5b78 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c @@ -355,11 +355,18 @@ static void bm_work(struct work_struct *work) CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID, data, sizeof(data)); - // Another bus reset, BM work has been rescheduled. - if (rcode == RCODE_GENERATION) + switch (rcode) { + case RCODE_GENERATION: + // Another bus reset, BM work has been rescheduled. return; - - if (rcode == RCODE_COMPLETE) { + case RCODE_SEND_ERROR: + // We have been unable to send the lock request due to + // some local problem. Let's try again later and hope + // that the problem has gone away by then. + fw_schedule_bm_work(card, msecs_to_jiffies(125)); + return; + case RCODE_COMPLETE: + { int bm_id = be32_to_cpu(data[0]); // Used by cdev layer for "struct fw_cdev_event_bus_reset". @@ -376,29 +383,20 @@ static void bm_work(struct work_struct *work) allocate_broadcast_channel(card, generation); return; } + break; } - - if (rcode == RCODE_SEND_ERROR) { - /* - * We have been unable to send the lock request due to - * some local problem. Let's try again later and hope - * that the problem has gone away by then. - */ - fw_schedule_bm_work(card, msecs_to_jiffies(125)); - return; - } - - if (rcode != RCODE_COMPLETE && !keep_this_irm) { - /* - * The lock request failed, maybe the IRM - * isn't really IRM capable after all. Let's - * do a bus reset and pick the local node as - * root, and thus, IRM. - */ - new_root_id = local_id; - fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", - fw_rcode_string(rcode), new_root_id); - goto pick_me; + default: + if (!keep_this_irm) { + // The lock request failed, maybe the IRM + // isn't really IRM capable after all. Let's + // do a bus reset and pick the local node as + // root, and thus, IRM. + new_root_id = local_id; + fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", + fw_rcode_string(rcode), new_root_id); + goto pick_me; + } + break; } } else if (card->bm_generation != generation) { /*