Skip to content

Commit 8f03514

Browse files
committed
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>
1 parent baf9d20 commit 8f03514

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

drivers/firewire/core-topology.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@
2323
#include "phy-packet-definitions.h"
2424
#include <trace/events/firewire.h>
2525

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-
3326
static struct fw_node *fw_node_create(u32 sid, int port_count, int color)
3427
{
3528
struct fw_node *node;
@@ -39,10 +32,11 @@ static struct fw_node *fw_node_create(u32 sid, int port_count, int color)
3932
return NULL;
4033

4134
node->color = color;
42-
node->node_id = LOCAL_BUS | SELF_ID_PHY_ID(sid);
43-
node->link_on = SELF_ID_LINK_ON(sid);
44-
node->phy_speed = SELF_ID_PHY_SPEED(sid);
45-
node->initiated_reset = SELF_ID_PHY_INITIATOR(sid);
35+
node->node_id = LOCAL_BUS | phy_packet_self_id_get_phy_id(sid);
36+
node->link_on = phy_packet_self_id_zero_get_link_active(sid);
37+
// NOTE: Only two bits, thus only for SCODE_100, SCODE_200, SCODE_400, and SCODE_BETA.
38+
node->phy_speed = phy_packet_self_id_zero_get_scode(sid);
39+
node->initiated_reset = phy_packet_self_id_zero_get_initiated_reset(sid);
4640
node->port_count = port_count;
4741

4842
refcount_set(&node->ref_count, 1);
@@ -119,7 +113,7 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self
119113
stack_depth = 0;
120114
phy_id = 0;
121115
irm_node = NULL;
122-
gap_count = SELF_ID_GAP_COUNT(*sid);
116+
gap_count = phy_packet_self_id_zero_get_gap_count(*sid);
123117
beta_repeaters_present = false;
124118

125119
while (enumerator.quadlet_count > 0) {
@@ -162,9 +156,9 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self
162156
}
163157
}
164158

165-
if (phy_id != SELF_ID_PHY_ID(self_id_sequence[0])) {
159+
if (phy_id != phy_packet_self_id_get_phy_id(self_id_sequence[0])) {
166160
fw_err(card, "PHY ID mismatch in self ID: %d != %d\n",
167-
phy_id, SELF_ID_PHY_ID(self_id_sequence[0]));
161+
phy_id, phy_packet_self_id_get_phy_id(self_id_sequence[0]));
168162
return NULL;
169163
}
170164

@@ -194,7 +188,7 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self
194188
if (phy_id == (card->node_id & 0x3f))
195189
local_node = node;
196190

197-
if (SELF_ID_CONTENDER(self_id_sequence[0]))
191+
if (phy_packet_self_id_zero_get_contender(self_id_sequence[0]))
198192
irm_node = node;
199193

200194
for (port_index = 0; port_index < total_port_count; ++port_index) {
@@ -243,7 +237,7 @@ static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self
243237

244238
// If PHYs report different gap counts, set an invalid count which will force a gap
245239
// count reconfiguration and a reset.
246-
if (SELF_ID_GAP_COUNT(self_id_sequence[0]) != gap_count)
240+
if (phy_packet_self_id_zero_get_gap_count(self_id_sequence[0]) != gap_count)
247241
gap_count = 0;
248242

249243
update_hop_count(node);

0 commit comments

Comments
 (0)