aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2025-09-08 10:21:07 +0900
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>2025-09-08 10:26:26 +0900
commitcae2d92cdcae3f2f4510feb631661e86a26da55e (patch)
tree56aa4da1d30796d3966ebe6aa7517b71eb429965 /drivers/firewire
parentfirewire: core: code refactoring to detect both IEEE 1394:1995 IRM and Canon ... (diff)
downloadlinux-cae2d92cdcae3f2f4510feb631661e86a26da55e.tar.gz
linux-cae2d92cdcae3f2f4510feb631661e86a26da55e.zip
firewire: core: code refactoring to investigate root node for bus manager
In the middle of bm_work function, both the value of gap_count and the state of root node are investigated. Current implementation is not a good shape since the investigation is aligned to be flat. This commit refactors the investigation with two large branches. Link: https://lore.kernel.org/r/20250908012108.514698-11-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/core-card.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
index 99aa98f195ba..b430a70a7eeb 100644
--- a/drivers/firewire/core-card.c
+++ b/drivers/firewire/core-card.c
@@ -294,7 +294,6 @@ static void bm_work(struct work_struct *work)
int root_id, new_root_id, irm_id, local_id;
int expected_gap_count, generation, grace;
bool do_reset = false;
- bool root_device_is_running;
bool root_device_is_cmc;
lockdep_assert_held(&card->lock);
@@ -310,8 +309,6 @@ static void bm_work(struct work_struct *work)
root_node = fw_node_get(card->root_node);
root_device = fw_node_get_device(root_node);
- root_device_is_running = root_device &&
- atomic_read(&root_device->state) == FW_DEVICE_RUNNING;
root_device_is_cmc = root_device && root_device->cmc;
root_id = root_node->node_id;
@@ -450,34 +447,35 @@ static void bm_work(struct work_struct *work)
* is inconsistent, so bypass the 5-reset limit.
*/
card->bm_retries = 0;
- } else if (root_device == NULL) {
- /*
- * Either link_on is false, or we failed to read the
- * config rom. In either case, pick another root.
- */
- new_root_id = local_id;
- } else if (!root_device_is_running) {
- /*
- * If we haven't probed this device yet, bail out now
- * and let's try again once that's done.
- */
- spin_unlock_irq(&card->lock);
- return;
- } else if (root_device_is_cmc) {
- /*
- * We will send out a force root packet for this
- * node as part of the gap count optimization.
- */
- new_root_id = root_id;
} else {
- /*
- * Current root has an active link layer and we
- * successfully read the config rom, but it's not
- * cycle master capable.
- */
- new_root_id = local_id;
- }
+ // Now investigate root node.
+ struct fw_device *root_device = fw_node_get_device(root_node);
+
+ if (root_device == NULL) {
+ // Either link_on is false, or we failed to read the
+ // config rom. In either case, pick another root.
+ new_root_id = local_id;
+ } else {
+ bool root_device_is_running =
+ atomic_read(&root_device->state) == FW_DEVICE_RUNNING;
+ if (!root_device_is_running) {
+ // If we haven't probed this device yet, bail out now
+ // and let's try again once that's done.
+ spin_unlock_irq(&card->lock);
+ return;
+ } else if (root_device->cmc) {
+ // We will send out a force root packet for this
+ // node as part of the gap count optimization.
+ new_root_id = root_id;
+ } else {
+ // Current root has an active link layer and we
+ // successfully read the config rom, but it's not
+ // cycle master capable.
+ new_root_id = local_id;
+ }
+ }
+ }
pick_me:
/*
* Pick a gap count from 1394a table E-1. The table doesn't cover