drivers: gpio: check if clock device is ready before accessing

Add check for device_is_ready() before accessing clock control devices.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2022-08-08 13:35:27 +02:00 committed by Carles Cufí
parent c1a35b7b39
commit 9c71615f83
4 changed files with 16 additions and 1 deletions

View file

@ -525,6 +525,10 @@ static int gpio_lpc11u6x_init(const struct device *dev)
return 0;
}
if (!device_is_ready(config->shared->clock_dev)) {
return -ENODEV;
}
/* Enable GPIO and PINT clocks. */
ret = clock_control_on(config->shared->clock_dev, config->shared->clock_subsys);
if (ret < 0) {

View file

@ -247,6 +247,10 @@ static int gpio_rcar_init(const struct device *dev)
const struct gpio_rcar_cfg *config = dev->config;
int ret;
if (!device_is_ready(config->clock_dev)) {
return -ENODEV;
}
ret = clock_control_on(config->clock_dev,
(clock_control_subsys_t *) &config->mod_clk);

View file

@ -270,8 +270,11 @@ static int gpio_rv32m1_init(const struct device *dev)
int ret;
if (config->clock_dev) {
ret = clock_control_on(config->clock_dev, config->clock_subsys);
if (!device_is_ready(config->clock_dev)) {
return -ENODEV;
}
ret = clock_control_on(config->clock_dev, config->clock_subsys);
if (ret < 0) {
return ret;
}

View file

@ -697,6 +697,10 @@ static int gpio_stm32_init(const struct device *dev)
data->dev = dev;
if (!device_is_ready(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE))) {
return -ENODEV;
}
#if defined(PWR_CR2_IOSV) && DT_NODE_HAS_STATUS(DT_NODELABEL(gpiog), okay)
z_stm32_hsem_lock(CFG_HW_RCC_SEMID, HSEM_LOCK_DEFAULT_RETRY);
/* Port G[15:2] requires external power supply */