mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-23 21:44:15 +00:00
Merge changes from topic "st_clk_fix" into integration
* changes: fix(st-clock): correct stm32_clk_parse_fdt_by_name fix(st-clock): check _clk_stm32_get_parent return
This commit is contained in:
commit
fa4751f245
1 changed files with 23 additions and 7 deletions
|
@ -327,6 +327,9 @@ int _clk_stm32_set_parent(struct stm32_clk_priv *priv, int clk, int clkp)
|
||||||
}
|
}
|
||||||
|
|
||||||
old_parent = _clk_stm32_get_parent(priv, clk);
|
old_parent = _clk_stm32_get_parent(priv, clk);
|
||||||
|
if (old_parent < 0) {
|
||||||
|
return old_parent;
|
||||||
|
}
|
||||||
if (old_parent == clkp) {
|
if (old_parent == clkp) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -415,7 +418,7 @@ int _clk_stm32_get_parent(struct stm32_clk_priv *priv, int clk_id)
|
||||||
sel = clk_mux_get_parent(priv, mux_id);
|
sel = clk_mux_get_parent(priv, mux_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sel < parent->num_parents) {
|
if ((sel >= 0) && (sel < parent->num_parents)) {
|
||||||
return parent->id_parents[sel];
|
return parent->id_parents[sel];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,6 +491,9 @@ unsigned long _clk_stm32_get_rate(struct stm32_clk_priv *priv, int id)
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = _clk_stm32_get_parent(priv, id);
|
parent = _clk_stm32_get_parent(priv, id);
|
||||||
|
if (parent < 0) {
|
||||||
|
return 0UL;
|
||||||
|
}
|
||||||
|
|
||||||
if (clk->ops->recalc_rate != NULL) {
|
if (clk->ops->recalc_rate != NULL) {
|
||||||
unsigned long prate = 0UL;
|
unsigned long prate = 0UL;
|
||||||
|
@ -517,6 +523,10 @@ unsigned long _clk_stm32_get_parent_rate(struct stm32_clk_priv *priv, int id)
|
||||||
{
|
{
|
||||||
int parent_id = _clk_stm32_get_parent(priv, id);
|
int parent_id = _clk_stm32_get_parent(priv, id);
|
||||||
|
|
||||||
|
if (parent_id < 0) {
|
||||||
|
return 0UL;
|
||||||
|
}
|
||||||
|
|
||||||
return _clk_stm32_get_rate(priv, parent_id);
|
return _clk_stm32_get_rate(priv, parent_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,6 +562,9 @@ static int _clk_stm32_enable_core(struct stm32_clk_priv *priv, int id)
|
||||||
|
|
||||||
if (priv->gate_refcounts[id] == 0U) {
|
if (priv->gate_refcounts[id] == 0U) {
|
||||||
parent = _clk_stm32_get_parent(priv, id);
|
parent = _clk_stm32_get_parent(priv, id);
|
||||||
|
if (parent < 0) {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
if (parent != CLK_IS_ROOT) {
|
if (parent != CLK_IS_ROOT) {
|
||||||
ret = _clk_stm32_enable_core(priv, parent);
|
ret = _clk_stm32_enable_core(priv, parent);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -616,7 +629,7 @@ static void _clk_stm32_disable_core(struct stm32_clk_priv *priv, int id)
|
||||||
clk_stm32_disable_call_ops(priv, id);
|
clk_stm32_disable_call_ops(priv, id);
|
||||||
|
|
||||||
parent = _clk_stm32_get_parent(priv, id);
|
parent = _clk_stm32_get_parent(priv, id);
|
||||||
if (parent != CLK_IS_ROOT) {
|
if ((parent >= 0) && (parent != CLK_IS_ROOT)) {
|
||||||
_clk_stm32_disable_core(priv, parent);
|
_clk_stm32_disable_core(priv, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1060,12 +1073,15 @@ int stm32_clk_parse_fdt_by_name(void *fdt, int node, const char *name, uint32_t
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
cell = fdt_getprop(fdt, node, name, &len);
|
cell = fdt_getprop(fdt, node, name, &len);
|
||||||
if (cell != NULL) {
|
if (cell == NULL) {
|
||||||
for (i = 0; i < ((uint32_t)len / sizeof(uint32_t)); i++) {
|
*nb = 0U;
|
||||||
uint32_t val = fdt32_to_cpu(cell[i]);
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
tab[i] = val;
|
for (i = 0; i < ((uint32_t)len / sizeof(uint32_t)); i++) {
|
||||||
}
|
uint32_t val = fdt32_to_cpu(cell[i]);
|
||||||
|
|
||||||
|
tab[i] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
*nb = (uint32_t)len / sizeof(uint32_t);
|
*nb = (uint32_t)len / sizeof(uint32_t);
|
||||||
|
|
Loading…
Add table
Reference in a new issue