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:
parent
aa856bb00d
commit
68230cb1a7
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) || \
|
||||
|
|
Loading…
Reference in a new issue