Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firewire: core: use helper inline functions to deserialize self ID packet

This commit replaces the existing implementation with the helper
functions for self ID packet.

Link: https://lore.kernel.org/r/20240605235155.116468-9-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+10 -16
+10 -16
drivers/firewire/core-topology.c
··· 23 23 #include "phy-packet-definitions.h" 24 24 #include <trace/events/firewire.h> 25 25 26 - #define SELF_ID_PHY_ID(q) (((q) >> 24) & 0x3f) 27 - #define SELF_ID_LINK_ON(q) (((q) >> 22) & 0x01) 28 - #define SELF_ID_GAP_COUNT(q) (((q) >> 16) & 0x3f) 29 - #define SELF_ID_PHY_SPEED(q) (((q) >> 14) & 0x03) 30 - #define SELF_ID_CONTENDER(q) (((q) >> 11) & 0x01) 31 - #define SELF_ID_PHY_INITIATOR(q) (((q) >> 1) & 0x01) 32 - 33 26 static struct fw_node *fw_node_create(u32 sid, int port_count, int color) 34 27 { 35 28 struct fw_node *node; ··· 32 39 return NULL; 33 40 34 41 node->color = color; 35 - node->node_id = LOCAL_BUS | SELF_ID_PHY_ID(sid); 36 - node->link_on = SELF_ID_LINK_ON(sid); 37 - node->phy_speed = SELF_ID_PHY_SPEED(sid); 38 - node->initiated_reset = SELF_ID_PHY_INITIATOR(sid); 42 + node->node_id = LOCAL_BUS | phy_packet_self_id_get_phy_id(sid); 43 + node->link_on = phy_packet_self_id_zero_get_link_active(sid); 44 + // NOTE: Only two bits, thus only for SCODE_100, SCODE_200, SCODE_400, and SCODE_BETA. 45 + node->phy_speed = phy_packet_self_id_zero_get_scode(sid); 46 + node->initiated_reset = phy_packet_self_id_zero_get_initiated_reset(sid); 39 47 node->port_count = port_count; 40 48 41 49 refcount_set(&node->ref_count, 1); ··· 113 119 stack_depth = 0; 114 120 phy_id = 0; 115 121 irm_node = NULL; 116 - gap_count = SELF_ID_GAP_COUNT(*sid); 122 + gap_count = phy_packet_self_id_zero_get_gap_count(*sid); 117 123 beta_repeaters_present = false; 118 124 119 125 while (enumerator.quadlet_count > 0) { ··· 156 162 } 157 163 } 158 164 159 - if (phy_id != SELF_ID_PHY_ID(self_id_sequence[0])) { 165 + if (phy_id != phy_packet_self_id_get_phy_id(self_id_sequence[0])) { 160 166 fw_err(card, "PHY ID mismatch in self ID: %d != %d\n", 161 - phy_id, SELF_ID_PHY_ID(self_id_sequence[0])); 167 + phy_id, phy_packet_self_id_get_phy_id(self_id_sequence[0])); 162 168 return NULL; 163 169 } 164 170 ··· 188 194 if (phy_id == (card->node_id & 0x3f)) 189 195 local_node = node; 190 196 191 - if (SELF_ID_CONTENDER(self_id_sequence[0])) 197 + if (phy_packet_self_id_zero_get_contender(self_id_sequence[0])) 192 198 irm_node = node; 193 199 194 200 for (port_index = 0; port_index < total_port_count; ++port_index) { ··· 237 243 238 244 // If PHYs report different gap counts, set an invalid count which will force a gap 239 245 // count reconfiguration and a reset. 240 - if (SELF_ID_GAP_COUNT(self_id_sequence[0]) != gap_count) 246 + if (phy_packet_self_id_zero_get_gap_count(self_id_sequence[0]) != gap_count) 241 247 gap_count = 0; 242 248 243 249 update_hop_count(node);