summaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2024-06-06 01:51:47 +0200
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>2024-06-17 01:37:03 +0200
commit10f5aee03787571057895762679c0bc3e1574692 (patch)
tree4072c14acdd0a93c2afbfae7c1db1cf0c549a4ee /drivers/firewire
parentfirewire: core: add helper function to handle port status from self ID sequen... (diff)
downloadlinux-10f5aee03787571057895762679c0bc3e1574692.tar.xz
linux-10f5aee03787571057895762679c0bc3e1574692.zip
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>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/core-topology.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topology.c
index 8107eebd4296..6edba604f5cf 100644
--- a/drivers/firewire/core-topology.c
+++ b/drivers/firewire/core-topology.c
@@ -38,14 +38,11 @@
#define SELFID_PORT_NCONN 0x1
#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;
int port_type, shift, seq;
- *total_port_count = 0;
- *child_port_count = 0;
-
shift = 6;
q = *sid;
seq = 0;
@@ -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;
@@ -169,13 +166,12 @@ static inline struct fw_node *fw_node(struct list_head *l)
* internally consistent. On success this function returns the
* fw_node corresponding to the local card otherwise NULL.
*/
-static struct fw_node *build_tree(struct fw_card *card,
- u32 *sid, int self_id_count)
+static struct fw_node *build_tree(struct fw_card *card, const u32 *sid, int self_id_count)
{
struct fw_node *node, *child, *local_node, *irm_node;
- struct list_head stack, *h;
- u32 *next_sid, *end, q;
- int i, port_count, child_port_count, phy_id, parent_count, stack_depth;
+ struct list_head stack;
+ const u32 *end;
+ int phy_id, stack_depth;
int gap_count;
bool beta_repeaters_present;
@@ -190,8 +186,15 @@ static struct fw_node *build_tree(struct fw_card *card,
beta_repeaters_present = false;
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) {
fw_err(card, "inconsistent extended self IDs\n");
return NULL;