drivers: flash: 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:
parent
5ade8908a7
commit
c1a35b7b39
3 changed files with 15 additions and 0 deletions
|
@ -358,6 +358,11 @@ static int stm32_flash_init(const struct device *dev)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!device_is_ready(clk)) {
|
||||
LOG_ERR("clock control device not ready");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* enable clock */
|
||||
if (clock_control_on(clk, (clock_control_subsys_t *)&p->pclken) != 0) {
|
||||
LOG_ERR("Failed to enable clock");
|
||||
|
|
|
@ -1583,6 +1583,11 @@ static int flash_stm32_ospi_init(const struct device *dev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
if (!device_is_ready(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE))) {
|
||||
LOG_ERR("clock control device not ready");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Clock configuration */
|
||||
if (clock_control_on(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE),
|
||||
(clock_control_subsys_t) &dev_cfg->pclken[0]) != 0) {
|
||||
|
|
|
@ -666,6 +666,11 @@ static int stm32h7_flash_init(const struct device *dev)
|
|||
struct flash_stm32_priv *p = FLASH_STM32_PRIV(dev);
|
||||
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;
|
||||
}
|
||||
|
||||
/* enable clock */
|
||||
if (clock_control_on(clk, (clock_control_subsys_t *)&p->pclken) != 0) {
|
||||
LOG_ERR("Failed to enable clock");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue