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" compatible
node. The call that expects to get a TEE_ERROR_ITEM_NOT_FOUND return
value (as described in the inline comment) for an unsupported 2nd level
control GPIO can fail with TEE_ERROR_DEFER_DRIVER_INIT return value
when the 1st GPIO phandle listed in the 'gpios' DT node property relates
to a GPIO driver that is not yet probed. Fix that by first getting the
required GPIO control level and then testing presence of other GPIO
phandle in the 'gpios' DT property.

Fixes: f164f0f ("drivers: regulator: GPIO controlled regulator")
Reviewed-by: Gatien Chevallier <[email protected]>
Signed-off-by: Etienne Carriere <[email protected]>
  • Loading branch information
etienne-lms committed Nov 24, 2023
1 parent c7f9abc commit 0d9f2d6
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 0d9f2d6

Please sign in to comment.