drivers: adc: use adc_is_ready_dt helper function

Update  `struct adc_dt_spec` use with adc_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
This commit is contained in:
Nick Ward 2023-07-16 22:04:41 +10:00 committed by Fabio Baltieri
commit 371f0f2503
6 changed files with 7 additions and 7 deletions

View file

@ -102,7 +102,7 @@ static int init(const struct device *dev)
struct mcp970x_data *data = dev->data; struct mcp970x_data *data = dev->data;
int ret; int ret;
if (!device_is_ready(config->adc.dev)) { if (!adc_is_ready_dt(&config->adc)) {
LOG_ERR("ADC is not ready"); LOG_ERR("ADC is not ready");
return -ENODEV; return -ENODEV;
} }

View file

@ -83,7 +83,7 @@ static int ntc_thermistor_init(const struct device *dev)
const struct ntc_thermistor_config *cfg = dev->config; const struct ntc_thermistor_config *cfg = dev->config;
int err; int err;
if (!device_is_ready(cfg->adc_channel.dev)) { if (!adc_is_ready_dt(&cfg->adc_channel)) {
LOG_ERR("ADC controller device is not ready\n"); LOG_ERR("ADC controller device is not ready\n");
return -ENODEV; return -ENODEV;
} }

View file

@ -42,7 +42,7 @@ int main(void)
/* Configure channels individually prior to sampling. */ /* Configure channels individually prior to sampling. */
for (size_t i = 0U; i < ARRAY_SIZE(adc_channels); i++) { for (size_t i = 0U; i < ARRAY_SIZE(adc_channels); i++) {
if (!device_is_ready(adc_channels[i].dev)) { if (!adc_is_ready_dt(&adc_channels[i])) {
printk("ADC controller device %s not ready\n", adc_channels[i].dev->name); printk("ADC controller device %s not ready\n", adc_channels[i].dev->name);
return 0; return 0;
} }

View file

@ -35,7 +35,7 @@ static const int adc_channels_count = ARRAY_SIZE(adc_channels);
const struct device *get_adc_device(void) const struct device *get_adc_device(void)
{ {
if (!device_is_ready(adc_channels[0].dev)) { if (!adc_is_ready_dt(&adc_channels[0])) {
printk("ADC device is not ready\n"); printk("ADC device is not ready\n");
return NULL; return NULL;
} }
@ -47,7 +47,7 @@ static void init_adc(void)
{ {
int i, ret; int i, ret;
zassert_true(device_is_ready(adc_channels[0].dev), "ADC device is not ready"); zassert_true(adc_is_ready_dt(&adc_channels[0]), "ADC device is not ready");
for (int i = 0; i < adc_channels_count; i++) { for (int i = 0; i < adc_channels_count; i++) {
ret = adc_channel_setup_dt(&adc_channels[i]); ret = adc_channel_setup_dt(&adc_channels[i]);

View file

@ -37,7 +37,7 @@ static int init_adc(const struct adc_dt_spec *spec, int input_mv)
{ {
int ret; int ret;
zassert_true(device_is_ready(spec->dev), "ADC device is not ready"); zassert_true(adc_is_ready_dt(spec), "ADC device is not ready");
ret = adc_channel_setup_dt(spec); ret = adc_channel_setup_dt(spec);
zassert_equal(ret, 0, "Setting up of the first channel failed with code %d", ret); zassert_equal(ret, 0, "Setting up of the first channel failed with code %d", ret);

View file

@ -114,7 +114,7 @@ void *setup(void)
for (size_t i = 0U; i < ARRAY_SIZE(regs); i++) { for (size_t i = 0U; i < ARRAY_SIZE(regs); i++) {
zassert_true(device_is_ready(regs[i])); zassert_true(device_is_ready(regs[i]));
zassert_true(device_is_ready(adc_chs[i].dev)); zassert_true(adc_is_ready_dt(&adc_chs[i]));
zassert_equal(adc_channel_setup_dt(&adc_chs[i]), 0); zassert_equal(adc_channel_setup_dt(&adc_chs[i]), 0);
} }