drivers: gpio: use gpio_is_ready_dt in TLE9104

Use gpio_is_ready_dt in the driver for the TLE9104 before
actually using the GPIO.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
This commit is contained in:
Benedikt Schmidt 2023-12-11 13:37:01 +01:00 committed by Henrik Brix Andersen
parent f26da17723
commit 23ed31383e

View file

@ -415,8 +415,8 @@ static int tle9104_init(const struct device *dev)
register_cfg |= TLE9104_CFG_OUT1DD_BIT << i;
if (!device_is_ready(current->port)) {
LOG_ERR("control GPIO %s is not ready", current->port->name);
if (!gpio_is_ready_dt(current)) {
LOG_ERR("%s: control GPIO is not ready", dev->name);
return -ENODEV;
}
@ -428,8 +428,8 @@ static int tle9104_init(const struct device *dev)
}
if (config->gpio_enable.port != NULL) {
if (!device_is_ready(config->gpio_enable.port)) {
LOG_ERR("enable GPIO %s is not ready", config->gpio_enable.port->name);
if (!gpio_is_ready_dt(&config->gpio_enable)) {
LOG_ERR("%s: enable GPIO is not ready", dev->name);
return -ENODEV;
}
@ -441,6 +441,11 @@ static int tle9104_init(const struct device *dev)
}
if (config->gpio_reset.port != NULL) {
if (!gpio_is_ready_dt(&config->gpio_reset)) {
LOG_ERR("%s: reset GPIO is not yet ready", dev->name);
return -ENODEV;
}
result = gpio_pin_configure_dt(&config->gpio_reset, GPIO_OUTPUT_ACTIVE);
if (result != 0) {
LOG_ERR("failed to initialize GPIO for reset");