drivers: dma: 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:33:46 +02:00 committed by Carles Cufí
parent 31681269c0
commit dc0b907f4b
2 changed files with 10 additions and 0 deletions

View file

@ -616,6 +616,11 @@ static int dma_stm32_init(const struct device *dev)
const struct dma_stm32_config *config = dev->config;
const struct device *clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
if (!device_is_ready(clk)) {
LOG_ERR("clock control device not ready");
return -ENODEV;
}
if (clock_control_on(clk,
(clock_control_subsys_t *) &config->pclken) != 0) {
LOG_ERR("clock op failed\n");

View file

@ -216,6 +216,11 @@ static int dmamux_stm32_init(const struct device *dev)
const struct dmamux_stm32_config *config = dev->config;
const struct device *clk = DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE);
if (!device_is_ready(clk)) {
LOG_ERR("clock control device not ready");
return -ENODEV;
}
if (clock_control_on(clk,
(clock_control_subsys_t *) &config->pclken) != 0) {
LOG_ERR("clock op failed\n");