mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-19 11:04:20 +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) {
|
||||
const fdt32_t *cuint;
|
||||
int pin_count;
|
||||
int pin_count = 0;
|
||||
int len;
|
||||
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) */
|
||||
pin_count = fdt32_to_cpu(*(cuint + 1)) + fdt32_to_cpu(*(cuint + 3));
|
||||
for (i = 0; i < (len / 4); i++) {
|
||||
pin_count = MAX(pin_count, (int)(fdt32_to_cpu(*(cuint + 1)) +
|
||||
fdt32_to_cpu(*(cuint + 3))));
|
||||
cuint += 4;
|
||||
for (i = 0; i < len; i += 4) {
|
||||
pin_count = MAX(pin_count, (int)(fdt32_to_cpu(cuint[i + 1]) +
|
||||
fdt32_to_cpu(cuint[i + 3])));
|
||||
}
|
||||
|
||||
return pin_count;
|
||||
|
|
Loading…
Add table
Reference in a new issue