1
0
Fork 0
forked from nuttx/nuttx-update

clk:optimized the clk_set_rate for mux

clk_mux_determine_rate->clk_get_parent_by_index

this path consume time too much

Signed-off-by: dulibo1 <dulibo1@xiaomi.com>
This commit is contained in:
dulibo1 2023-12-20 19:27:57 +08:00 committed by Xiang Xiao
parent a6cf57dbac
commit 347154c01e
2 changed files with 27 additions and 1 deletions

View file

@ -727,6 +727,11 @@ static void clk_init_parent(FAR struct clk_s *clk)
return;
}
for (index = 0; index < clk->num_parents; index++)
{
clk->parents[index] = clk_get(clk->parent_names[index]);
}
if (!clk->ops->get_parent)
{
return;
@ -1205,7 +1210,12 @@ FAR struct clk_s *clk_get_parent_by_index(FAR struct clk_s *clk,
return NULL;
}
return clk_get(clk->parent_names[index]);
if (clk->parents[index] == NULL)
{
clk->parents[index] = clk_get(clk->parent_names[index]);
}
return clk->parents[index];
}
FAR struct clk_s *clk_get_parent(FAR struct clk_s *clk)
@ -1308,6 +1318,15 @@ FAR struct clk_s *clk_register(FAR const char *name,
}
}
if (num_parents > 0)
{
clk->parents = kmm_zalloc(sizeof(struct clk_s *) * num_parents);
if (clk->parents == NULL)
{
goto out;
}
}
list_initialize(&clk->node);
list_initialize(&clk->children);
@ -1318,7 +1337,13 @@ FAR struct clk_s *clk_register(FAR const char *name,
return clk;
}
out:
clk_list_unlock(irqflags);
if (clk->parents)
{
kmm_free(clk->parents);
}
kmm_free(clk);
return NULL;
}

View file

@ -93,6 +93,7 @@ struct clk_s
FAR const char *name;
FAR const struct clk_ops_s *ops;
FAR struct clk_s *parent;
FAR struct clk_s **parents;
uint8_t num_parents;
uint8_t new_parent_index;
uint8_t enable_count;