drivers: i2s: 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:56 +02:00 committed by Carles Cufí
commit 2e1f25f355
3 changed files with 11 additions and 1 deletions

View file

@ -102,6 +102,11 @@ static int i2s_stm32_enable_clock(const struct device *dev)
clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
if (!device_is_ready(clk)) {
LOG_ERR("clock control device not ready");
return -ENODEV;
}
ret = clock_control_on(clk, (clock_control_subsys_t *) &cfg->pclken);
if (ret != 0) {
LOG_ERR("Could not enable I2S clock");