Commit 10f5aee0 authored by Takashi Sakamoto's avatar Takashi Sakamoto

firewire: core: minor code refactoring for topology builder

Current implementation to build tree according to self ID sequences has
the rest to be refactored; e.g. putting local variables into block.

This commit is for the purpose.

Link: https://lore.kernel.org/r/20240605235155.116468-4-o-takashi@sakamocchi.jpSigned-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
parent 93389767
...@@ -38,14 +38,11 @@ ...@@ -38,14 +38,11 @@
#define SELFID_PORT_NCONN 0x1 #define SELFID_PORT_NCONN 0x1
#define SELFID_PORT_NONE 0x0 #define SELFID_PORT_NONE 0x0
static u32 *count_ports(u32 *sid, int *total_port_count, int *child_port_count) static const u32 *count_ports(const u32 *sid, int *total_port_count, int *child_port_count)
{ {
u32 q; u32 q;
int port_type, shift, seq; int port_type, shift, seq;
*total_port_count = 0;
*child_port_count = 0;
shift = 6; shift = 6;
q = *sid; q = *sid;
seq = 0; seq = 0;
...@@ -89,7 +86,7 @@ static u32 *count_ports(u32 *sid, int *total_port_count, int *child_port_count) ...@@ -89,7 +86,7 @@ static u32 *count_ports(u32 *sid, int *total_port_count, int *child_port_count)
} }
} }
static int get_port_type(u32 *sid, int port_index) static int get_port_type(const u32 *sid, int port_index)
{ {
int index, shift; int index, shift;
...@@ -169,13 +166,12 @@ static inline struct fw_node *fw_node(struct list_head *l) ...@@ -169,13 +166,12 @@ static inline struct fw_node *fw_node(struct list_head *l)
* internally consistent. On success this function returns the * internally consistent. On success this function returns the
* fw_node corresponding to the local card otherwise NULL. * fw_node corresponding to the local card otherwise NULL.
*/ */
static struct fw_node *build_tree(struct fw_card *card, static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self_id_count)
u32 *sid, int self_id_count)
{ {
struct fw_node *node, *child, *local_node, *irm_node; struct fw_node *node, *child, *local_node, *irm_node;
struct list_head stack, *h; struct list_head stack;
u32 *next_sid, *end, q; const u32 *end;
int i, port_count, child_port_count, phy_id, parent_count, stack_depth; int phy_id, stack_depth;
int gap_count; int gap_count;
bool beta_repeaters_present; bool beta_repeaters_present;
...@@ -190,8 +186,15 @@ static struct fw_node *build_tree(struct fw_card *card, ...@@ -190,8 +186,15 @@ static struct fw_node *build_tree(struct fw_card *card,
beta_repeaters_present = false; beta_repeaters_present = false;
while (sid < end) { while (sid < end) {
next_sid = count_ports(sid, &port_count, &child_port_count); int port_count = 0;
int child_port_count = 0;
int parent_count = 0;
const u32 *next_sid;
u32 q;
struct list_head *h;
int i;
next_sid = count_ports(sid, &port_count, &child_port_count);
if (next_sid == NULL) { if (next_sid == NULL) {
fw_err(card, "inconsistent extended self IDs\n"); fw_err(card, "inconsistent extended self IDs\n");
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment