Commit ca17601b authored by Takashi Sakamoto's avatar Takashi Sakamoto
Browse files

firewire: core: code refactoring to detect both IEEE 1394:1995 IRM and Canon MV5i

The detection of IEEE 1394:1995 and Canon MV5i is just required within
some of the condition branches. In this case, these check can be
capsulated within these branches.

This commit refactors the checks.

Link: https://lore.kernel.org/r/20250908012108.514698-10-o-takashi@sakamocchi.jp


Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
parent 8c2d2fcd
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -289,15 +289,13 @@ static void bm_work(struct work_struct *work)
		63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40
	};
	struct fw_card *card __free(card_unref) = from_work(card, work, bm_work.work);
	struct fw_device *root_device, *irm_device;
	struct fw_device *root_device;
	struct fw_node *root_node __free(node_unref) = NULL;
	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;
	bool irm_is_1394_1995_only;
	bool keep_this_irm;

	lockdep_assert_held(&card->lock);

@@ -316,14 +314,6 @@ static void bm_work(struct work_struct *work)
			atomic_read(&root_device->state) == FW_DEVICE_RUNNING;
	root_device_is_cmc = root_device && root_device->cmc;

	irm_device = fw_node_get_device(card->irm_node);
	irm_is_1394_1995_only = irm_device && irm_device->config_rom &&
			(irm_device->config_rom[2] & 0x000000f0) == 0;

	/* Canon MV5i works unreliably if it is not root node. */
	keep_this_irm = irm_device && irm_device->config_rom &&
			irm_device->config_rom[3] >> 8 == CANON_OUI;

	root_id  = root_node->node_id;
	irm_id   = card->irm_node->node_id;
	local_id = card->local_node->node_id;
@@ -349,6 +339,9 @@ static void bm_work(struct work_struct *work)
			cpu_to_be32(0x3f),
			cpu_to_be32(local_id),
		};
		struct fw_device *irm_device = fw_node_get_device(card->irm_node);
		bool irm_is_1394_1995_only = false;
		bool keep_this_irm = false;
		int rcode;

		if (!card->irm_node->link_on) {
@@ -358,6 +351,13 @@ static void bm_work(struct work_struct *work)
			goto pick_me;
		}

		if (irm_device && irm_device->config_rom) {
			irm_is_1394_1995_only = (irm_device->config_rom[2] & 0x000000f0) == 0;

			// Canon MV5i works unreliably if it is not root node.
			keep_this_irm = irm_device->config_rom[3] >> 8 == CANON_OUI;
		}

		if (irm_is_1394_1995_only && !keep_this_irm) {
			new_root_id = local_id;
			fw_notice(card, "%s, making local node (%02x) root\n",