Skip to content

Commit 26927fc

Browse files
pabigotcarlescufi
authored andcommitted
gpio: esp32: retrieve pinmux from devicetree reference
Need to declare the device before the pointer can be obtained, and to validate the device before trying to use it. Signed-off-by: Peter Bigot <[email protected]>
1 parent 8c1bef5 commit 26927fc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/gpio/gpio_esp32.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,19 @@ static void gpio_esp32_fire_callbacks(const struct device *device)
265265

266266
static void gpio_esp32_isr(const void *param);
267267

268+
DEVICE_DT_DECLARE(DT_NODELABEL(pinmux));
269+
268270
static int gpio_esp32_init(const struct device *device)
269271
{
270272
struct gpio_esp32_data *data = device->data;
271273
static bool isr_connected;
272274

273275
data->pinmux = DEVICE_DT_GET(DT_NODELABEL(pinmux));
276+
if ((data->pinmux != NULL)
277+
&& !device_is_ready(data->pinmux)) {
278+
data->pinmux = NULL;
279+
}
280+
274281
if (!data->pinmux) {
275282
return -ENOTSUP;
276283
}

0 commit comments

Comments
 (0)