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

Configure Feed

Select the types of activity you want to include in your feed.

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.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+14 -11
+14 -11
drivers/firewire/core-topology.c
··· 38 38 #define SELFID_PORT_NCONN 0x1 39 39 #define SELFID_PORT_NONE 0x0 40 40 41 - static u32 *count_ports(u32 *sid, int *total_port_count, int *child_port_count) 41 + static const u32 *count_ports(const u32 *sid, int *total_port_count, int *child_port_count) 42 42 { 43 43 u32 q; 44 44 int port_type, shift, seq; 45 - 46 - *total_port_count = 0; 47 - *child_port_count = 0; 48 45 49 46 shift = 6; 50 47 q = *sid; ··· 86 89 } 87 90 } 88 91 89 - static int get_port_type(u32 *sid, int port_index) 92 + static int get_port_type(const u32 *sid, int port_index) 90 93 { 91 94 int index, shift; 92 95 ··· 166 169 * internally consistent. On success this function returns the 167 170 * fw_node corresponding to the local card otherwise NULL. 168 171 */ 169 - static struct fw_node *build_tree(struct fw_card *card, 170 - u32 *sid, int self_id_count) 172 + static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self_id_count) 171 173 { 172 174 struct fw_node *node, *child, *local_node, *irm_node; 173 - struct list_head stack, *h; 174 - u32 *next_sid, *end, q; 175 - int i, port_count, child_port_count, phy_id, parent_count, stack_depth; 175 + struct list_head stack; 176 + const u32 *end; 177 + int phy_id, stack_depth; 176 178 int gap_count; 177 179 bool beta_repeaters_present; 178 180 ··· 186 190 beta_repeaters_present = false; 187 191 188 192 while (sid < end) { 189 - next_sid = count_ports(sid, &port_count, &child_port_count); 193 + int port_count = 0; 194 + int child_port_count = 0; 195 + int parent_count = 0; 196 + const u32 *next_sid; 197 + u32 q; 198 + struct list_head *h; 199 + int i; 190 200 201 + next_sid = count_ports(sid, &port_count, &child_port_count); 191 202 if (next_sid == NULL) { 192 203 fw_err(card, "inconsistent extended self IDs\n"); 193 204 return NULL;