]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
firewire: core: use switch statement to evaluate transaction result to CSR_BUS_MANAGER_ID
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Thu, 18 Sep 2025 23:54:44 +0000 (08:54 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Thu, 18 Sep 2025 23:58:34 +0000 (08:58 +0900)
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 <o-takashi@sakamocchi.jp>
drivers/firewire/core-card.c

index ef00125fb01ac8fb4580497732976c580f84351f..e9bf8d93f5b78103c195e985fb0de08f6aff66f2 100644 (file)
@@ -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) {
                /*