drivers: adc: 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:29:32 +02:00 committed by Carles Cufí
parent aa856bb00d
commit 68230cb1a7
2 changed files with 10 additions and 0 deletions

View file

@ -741,6 +741,11 @@ static int adc_npcx_init(const struct device *dev)
const struct device *const clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
int prescaler = 0, ret;
if (!device_is_ready(clk_dev)) {
LOG_ERR("clock control device not ready");
return -ENODEV;
}
/* Save ADC device in data */
data->adc_dev = dev;

View file

@ -975,6 +975,11 @@ static int adc_stm32_init(const struct device *dev)
LOG_DBG("Initializing....");
if (!device_is_ready(clk)) {
LOG_ERR("clock control device not ready");
return -ENODEV;
}
data->dev = dev;
#if defined(CONFIG_SOC_SERIES_STM32F0X) || \
defined(CONFIG_SOC_SERIES_STM32G0X) || \