Skip to content

Commit 10f5aee

Browse files
committed
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>
1 parent 9338976 commit 10f5aee

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

drivers/firewire/core-topology.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,11 @@
3838
#define SELFID_PORT_NCONN 0x1
3939
#define SELFID_PORT_NONE 0x0
4040

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)
4242
{
4343
u32 q;
4444
int port_type, shift, seq;
4545

46-
*total_port_count = 0;
47-
*child_port_count = 0;
48-
4946
shift = 6;
5047
q = *sid;
5148
seq = 0;
@@ -89,7 +86,7 @@ static u32 *count_ports(u32 *sid, int *total_port_count, int *child_port_count)
8986
}
9087
}
9188

92-
static int get_port_type(u32 *sid, int port_index)
89+
static int get_port_type(const u32 *sid, int port_index)
9390
{
9491
int index, shift;
9592

@@ -169,13 +166,12 @@ static inline struct fw_node *fw_node(struct list_head *l)
169166
* internally consistent. On success this function returns the
170167
* fw_node corresponding to the local card otherwise NULL.
171168
*/
172-
static struct fw_node *build_tree(struct fw_card *card,
173-
u32 *sid, int self_id_count)
169+
static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self_id_count)
174170
{
175171
struct fw_node *node, *child, *local_node, *irm_node;
176-
struct list_head stack, *h;
177-
u32 *next_sid, *end, q;
178-
int i, port_count, child_port_count, phy_id, parent_count, stack_depth;
172+
struct list_head stack;
173+
const u32 *end;
174+
int phy_id, stack_depth;
179175
int gap_count;
180176
bool beta_repeaters_present;
181177

@@ -190,8 +186,15 @@ static struct fw_node *build_tree(struct fw_card *card,
190186
beta_repeaters_present = false;
191187

192188
while (sid < end) {
193-
next_sid = count_ports(sid, &port_count, &child_port_count);
189+
int port_count = 0;
190+
int child_port_count = 0;
191+
int parent_count = 0;
192+
const u32 *next_sid;
193+
u32 q;
194+
struct list_head *h;
195+
int i;
194196

197+
next_sid = count_ports(sid, &port_count, &child_port_count);
195198
if (next_sid == NULL) {
196199
fw_err(card, "inconsistent extended self IDs\n");
197200
return NULL;

0 commit comments

Comments
 (0)