Skip to content

Commit

Permalink
drivers: regulator: fix getting gpio for level control
Browse files Browse the repository at this point in the history
Swap the 2 calls to find gpio property in "regulator-gpio" compiatble
node. Obviously the first call expects to get the GPIO resource
while the second check that the node does not define 2 or more GPIOs
to control the regulator level as the implementation only supports one,
as described in the inline comment.

Fixes: f164f0f ("drivers: regulator: GPIO controlled regulator")
Signed-off-by: Etienne Carriere <[email protected]>
  • Loading branch information
etienne-lms committed Nov 24, 2023
1 parent c7f9abc commit 09d7611
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/drivers/regulator/regulator_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ static TEE_Result get_voltage_level_gpio(const void *fdt, int node,
void *gpio_ref = &gpio;
int len = 0;

res = dt_driver_device_from_node_idx_prop("gpios", fdt, node, 0,
DT_DRIVER_GPIO, gpio_ref);
if (res)
return res;

/*
* DT bindings allows more than 1 GPIO to control more than
* 2 voltage levels. As it's not used so far in known platforms
Expand All @@ -161,11 +166,6 @@ static TEE_Result get_voltage_level_gpio(const void *fdt, int node,
return TEE_ERROR_GENERIC;
}

res = dt_driver_device_from_node_idx_prop("gpios", fdt, node, 0,
DT_DRIVER_GPIO, gpio_ref);
if (res)
return res;

cuint = fdt_getprop(fdt, node, "states", &len);
if (!cuint || len != 4 * sizeof(fdt32_t)) {
EMSG("Node %s expects 2 levels from property \"states\"",
Expand Down

0 comments on commit 09d7611

Please sign in to comment.