]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
firewire: core: use macro expression for not-registered state of BUS_MANAGER_ID
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 13 Sep 2025 10:57:37 +0000 (19:57 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 13 Sep 2025 10:59:21 +0000 (19:59 +0900)
The value of BUS_MANAGER_ID register has 0x3f when no node_id is
registered. Current implementation uses hard-coded numeric literal but
in the case the macro expression is preferable since it is easy to
distinguish the state from node ID mask.

This commit applies the idea.

Link: https://lore.kernel.org/r/20250913105737.778038-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
drivers/firewire/core-card.c
drivers/firewire/core.h

index bf2e7f55b83e6088ec32c9cc2d169a03c70f9162..adb90161c4c6ac1c7743d397761da7650d391471 100644 (file)
@@ -327,7 +327,7 @@ static void bm_work(struct work_struct *work)
                 * next generation.
                 */
                __be32 data[2] = {
-                       cpu_to_be32(0x3f),
+                       cpu_to_be32(BUS_MANAGER_ID_NOT_REGISTERED),
                        cpu_to_be32(local_id),
                };
                struct fw_device *irm_device = fw_node_get_device(card->irm_node);
@@ -372,10 +372,14 @@ static void bm_work(struct work_struct *work)
                if (rcode == RCODE_COMPLETE) {
                        int bm_id = be32_to_cpu(data[0]);
 
-                       if (generation == card->generation)
-                               card->bm_node_id = bm_id == 0x3f ? local_id : 0xffc0 | bm_id;
+                       if (generation == card->generation) {
+                               if (bm_id != BUS_MANAGER_ID_NOT_REGISTERED)
+                                       card->bm_node_id = 0xffc0 & bm_id;
+                               else
+                                       card->bm_node_id = local_id;
+                       }
 
-                       if (bm_id != 0x3f) {
+                       if (bm_id != BUS_MANAGER_ID_NOT_REGISTERED) {
                                spin_unlock_irq(&card->lock);
 
                                // Somebody else is BM.  Only act as IRM.
index 79eb57fd5812ac12ded78fc2697dac7a7bdab46b..9e68ebf0673d7355fb012a661516f556575453e0 100644 (file)
@@ -170,6 +170,9 @@ static inline void fw_iso_context_init_work(struct fw_iso_context *ctx, work_fun
 
 /* -topology */
 
+// The initial value of BUS_MANAGER_ID register, to express nothing registered.
+#define BUS_MANAGER_ID_NOT_REGISTERED  0x3f
+
 enum {
        FW_NODE_CREATED,
        FW_NODE_UPDATED,