Skip to contentSkip to conversation

ARM: stm32: Fix SoM and board coding strap GPIO handling on DHSOM

PATCH In review Marek Vasut 3 participants 4 messages Nov 13, 2021 – Nov 30, 2021 Arm STM32

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: stm32: Fix SoM and board coding strap GPIO handling on DHSOM

The variables retaining the strap values have to be initialized, always, make it so. Moreover, free the requested GPIO list at the end to avoid wasting memory.

Cc Patrice Chotard <[email protected]>
Cc Patrick Delaunay <[email protected]>
---
 board/dhelectronics/dh_stm32mp1/board.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
board/dhelectronics/dh_stm32mp1/board.c +10 -4
index a8402e24572..f44afb01e27 100644
@@ -212,34 +212,40 @@ static void board_get_coding_straps(void)
 	ofnode node;
 	int i, ret;
 
+	brdcode = 0;
+	ddr3code = 0;
+	somcode = 0;
+
 	node = ofnode_path("/config");
 	if (!ofnode_valid(node)) {
 		printf("%s: no /config node?\n", __func__);
 		return;
 	}
 
-	brdcode = 0;
-	ddr3code = 0;
-	somcode = 0;
-
 	ret = gpio_request_list_by_name_nodev(node, "dh,som-coding-gpios",
 					      gpio, ARRAY_SIZE(gpio),
 					      GPIOD_IS_IN);
 	for (i = 0; i < ret; i++)
 		somcode |= !!dm_gpio_get_value(&(gpio[i])) << i;
 
+	gpio_free_list_nodev(gpio, ret);
+
 	ret = gpio_request_list_by_name_nodev(node, "dh,ddr3-coding-gpios",
 					      gpio, ARRAY_SIZE(gpio),
 					      GPIOD_IS_IN);
 	for (i = 0; i < ret; i++)
 		ddr3code |= !!dm_gpio_get_value(&(gpio[i])) << i;
 
+	gpio_free_list_nodev(gpio, ret);
+
 	ret = gpio_request_list_by_name_nodev(node, "dh,board-coding-gpios",
 					      gpio, ARRAY_SIZE(gpio),
 					      GPIOD_IS_IN);
 	for (i = 0; i < ret; i++)
 		brdcode |= !!dm_gpio_get_value(&(gpio[i])) << i;
 
+	gpio_free_list_nodev(gpio, ret);
+
 	printf("Code:  SoM:rev=%d,ddr3=%d Board:rev=%d\n",
 		somcode, ddr3code, brdcode);
 }
Signature · 1 line
2.33.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Marek

Quoted 51 lines · Marek Vasut

The variables retaining the strap values have to be initialized, always, make it so. Moreover, free the requested GPIO list at the end to avoid wasting memory.

Cc Patrice Chotard <[email protected]>
Cc Patrick Delaunay <[email protected]>
---
 board/dhelectronics/dh_stm32mp1/board.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
board/dhelectronics/dh_stm32mp1/board.c +8 -4
index a8402e24572..f44afb01e27 100644
@@ -212,34 +212,40 @@ static void board_get_coding_straps(void)
 	ofnode node;
 	int i, ret;
 
+	brdcode = 0;
+	ddr3code = 0;
+	somcode = 0;
+
 	node = ofnode_path("/config");
 	if (!ofnode_valid(node)) {
 		printf("%s: no /config node?\n", __func__);
 		return;
 	}
 
-	brdcode = 0;
-	ddr3code = 0;
-	somcode = 0;
-
 	ret = gpio_request_list_by_name_nodev(node, "dh,som-coding-gpios",
 					      gpio, ARRAY_SIZE(gpio),
 					      GPIOD_IS_IN);
 	for (i = 0; i < ret; i++)
 		somcode |= !!dm_gpio_get_value(&(gpio[i])) << i;
 
+	gpio_free_list_nodev(gpio, ret);
+
 	ret = gpio_request_list_by_name_nodev(node, "dh,ddr3-coding-gpios",
 					      gpio, ARRAY_SIZE(gpio),
 					      GPIOD_IS_IN);
 	for (i = 0; i < ret; i++)
 		ddr3code |= !!dm_gpio_get_value(&(gpio[i])) << i;
 
+	gpio_free_list_nodev(gpio, ret);
+
 	ret = gpio_request_list_by_name_nodev(node, "dh,board-coding-gpios",

board/dhelectronics/dh_stm32mp1/board.c static void board_get_coding_straps(void) · line 251

Quoted 10 lines
board/dhelectronics/dh_stm32mp1/board.c +2 -0
 					      gpio, ARRAY_SIZE(gpio),
 					      GPIOD_IS_IN);
 	for (i = 0; i < ret; i++)
 		brdcode |= !!dm_gpio_get_value(&(gpio[i])) << i;
 
+	gpio_free_list_nodev(gpio, ret);
+
 	printf("Code:  SoM:rev=%d,ddr3=%d Board:rev=%d\n",
 		somcode, ddr3code, brdcode);
 }

Thanks
Patrice

Reviewed-by on v1 1/1
#2 lore raw
In reply to Marek Vasut

Hi Marek,

Quoted 11 lines · Marek Vasut

The variables retaining the strap values have to be initialized, always, make it so. Moreover, free the requested GPIO list at the end to avoid wasting memory.

Cc Patrice Chotard <[email protected]>
Cc Patrick Delaunay <[email protected]>
---
  board/dhelectronics/dh_stm32mp1/board.c | 14 ++++++++++----
  1 file changed, 10 insertions(+), 4 deletions(-)

Thanks
Patrick

#3 lore raw

Hi Marek

Quoted 16 lines · Patrick DELAUNAY

Hi Marek,

Quoted 11 lines · Marek Vasut

The variables retaining the strap values have to be initialized, always, make it so. Moreover, free the requested GPIO list at the end to avoid wasting memory.

Cc Patrice Chotard <[email protected]>
Cc Patrick Delaunay <[email protected]>

---
  board/dhelectronics/dh_stm32mp1/board.c | 14 ++++++++++----

  1 file changed, 10 insertions(+), 4 deletions(-)
Quoted 7 lines

Thanks
Patrick

Applied to u-boot-stm32/next

Thanks
Patrice