Skip to content

hw: aspeed_gpio: Fix GPIO array indexing

[email protected] qemu-arm qemu-devel 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest1 patch 0 repliesNew
  2. v11 patch 4 repliesSuperseded

Changes in v2 from the cover letter

- Standardized the size of the GPIOSetProperties array for each Aspeed SOC so that we can use the constant "ASPEED_GPIO_MAX_NR_SETS" to iterate over all of them.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1hw: aspeed_gpio: Fix GPIO array indexinghw/gpio/aspeed_gpio.c include/hw/gpio/aspeed_gpio.h+35 -500 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/1] hw: aspeed_gpio: Fix GPIO array indexing

From: Peter Delevoryas <[email protected]>

v1: https://lore.kernel.org/qemu-devel/[email protected]/
v2:
- Standardized the size of the GPIOSetProperties array for each Aspeed SOC so that we can use the constant "ASPEED_GPIO_MAX_NR_SETS" to iterate over all of them.

This adds some unused, zeroed memory, and the for-loops spend some time skipping over zeroed entries, but I don't think it's a big deal, and it's simpler than tracking a variable-length nr_sets property on the classes.

Thanks,
Peter

Peter Delevoryas (1):
hw: aspeed_gpio: Fix GPIO array indexing

 hw/gpio/aspeed_gpio.c         | 80 +++++++++++++++--------------------
 include/hw/gpio/aspeed_gpio.h |  5 +--
 2 files changed, 35 insertions(+), 50 deletions(-)

Interdiff against v1:

hw/gpio/aspeed_gpio.c +4 -4
index 78b0f64b03..911d21c8cf 100644
@@ -759,7 +759,7 @@ static void aspeed_gpio_set_pin(Object *obj, Visitor *v, const char *name,
 }
 
 /****************** Setup functions ******************/
-static const GPIOSetProperties ast2400_set_props[] = {
+static const GPIOSetProperties ast2400_set_props[ASPEED_GPIO_MAX_NR_SETS] = {
     [0] = {0xffffffff,  0xffffffff,  {"A", "B", "C", "D"} },
     [1] = {0xffffffff,  0xffffffff,  {"E", "F", "G", "H"} },
     [2] = {0xffffffff,  0xffffffff,  {"I", "J", "K", "L"} },
@@ -769,7 +769,7 @@ static const GPIOSetProperties ast2400_set_props[] = {
     [6] = {0x0000000f,  0x0fffff0f,  {"Y", "Z", "AA", "AB"} },
 };
 
-static const GPIOSetProperties ast2500_set_props[] = {
+static const GPIOSetProperties ast2500_set_props[ASPEED_GPIO_MAX_NR_SETS] = {
     [0] = {0xffffffff,  0xffffffff,  {"A", "B", "C", "D"} },
     [1] = {0xffffffff,  0xffffffff,  {"E", "F", "G", "H"} },
     [2] = {0xffffffff,  0xffffffff,  {"I", "J", "K", "L"} },
@@ -780,7 +780,7 @@ static const GPIOSetProperties ast2500_set_props[] = {
     [7] = {0x000000ff,  0x000000ff,  {"AC"} },
 };
 
-static GPIOSetProperties ast2600_3_3v_set_props[] = {
+static GPIOSetProperties ast2600_3_3v_set_props[ASPEED_GPIO_MAX_NR_SETS] = {
     [0] = {0xffffffff,  0xffffffff,  {"A", "B", "C", "D"} },
     [1] = {0xffffffff,  0xffffffff,  {"E", "F", "G", "H"} },
     [2] = {0xffffffff,  0xffffffff,  {"I", "J", "K", "L"} },
@@ -790,7 +790,7 @@ static GPIOSetProperties ast2600_3_3v_set_props[] = {
     [6] = {0x0000ffff,  0x0000ffff,  {"Y", "Z"} },
 };
 
-static GPIOSetProperties ast2600_1_8v_set_props[] = {
+static GPIOSetProperties ast2600_1_8v_set_props[ASPEED_GPIO_MAX_NR_SETS] = {
     [0] = {0xffffffff,  0xffffffff,  {"18A", "18B", "18C", "18D"} },
     [1] = {0x0000000f,  0x0000000f,  {"18E"} },
 };
Signature · 1 line
2.30.2