mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-20 19:44:23 +00:00
fix(st): use indices when counting GPIOs in DT
Fix MISRA C2012-18.4: The +, -, += and -= operators should not be applied to an expression of pointer type. While at it, avoid computing twice the same value, by removing the initial value computation outside the loop. Signed-off-by: Yann Gautier <yann.gautier@st.com> Change-Id: Iabfe587bf72535541c94bfa341de10148aa58030
This commit is contained in:
parent
9c1aa1253c
commit
e7d75448b9
1 changed files with 4 additions and 6 deletions
|
@ -386,7 +386,7 @@ int fdt_get_gpio_bank_pin_count(unsigned int bank)
|
||||||
|
|
||||||
fdt_for_each_subnode(node, fdt, pinctrl_node) {
|
fdt_for_each_subnode(node, fdt, pinctrl_node) {
|
||||||
const fdt32_t *cuint;
|
const fdt32_t *cuint;
|
||||||
int pin_count;
|
int pin_count = 0;
|
||||||
int len;
|
int len;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -415,11 +415,9 @@ int fdt_get_gpio_bank_pin_count(unsigned int bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the last defined gpio line (offset + nb of pins) */
|
/* Get the last defined gpio line (offset + nb of pins) */
|
||||||
pin_count = fdt32_to_cpu(*(cuint + 1)) + fdt32_to_cpu(*(cuint + 3));
|
for (i = 0; i < len; i += 4) {
|
||||||
for (i = 0; i < (len / 4); i++) {
|
pin_count = MAX(pin_count, (int)(fdt32_to_cpu(cuint[i + 1]) +
|
||||||
pin_count = MAX(pin_count, (int)(fdt32_to_cpu(*(cuint + 1)) +
|
fdt32_to_cpu(cuint[i + 3])));
|
||||||
fdt32_to_cpu(*(cuint + 3))));
|
|
||||||
cuint += 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pin_count;
|
return pin_count;
|
||||||
|
|
Loading…
Add table
Reference in a new issue