drivers: usb-c: fix - check if adc_channel is ready before use
This will protect a user of this driver against driver initialisation order misconfiguration. Signed-off-by: Nick Ward <nix.ward@gmail.com>
This commit is contained in:
parent
371f0f2503
commit
2bf091f8af
1 changed files with 5 additions and 0 deletions
|
@ -139,6 +139,11 @@ static int adc_vbus_init(const struct device *dev)
|
|||
const struct gpio_dt_spec *gcd = &config->discharge_gpios;
|
||||
int ret;
|
||||
|
||||
if (!adc_is_ready_dt(&config->adc_channel)) {
|
||||
LOG_ERR("ADC controller device is not ready");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Configure VBUS Measurement enable pin if defined */
|
||||
if (gcp->port) {
|
||||
ret = device_is_ready(gcp->port);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue