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:
parent
0f645b445c
commit
371f0f2503
6 changed files with 7 additions and 7 deletions
|
@ -102,7 +102,7 @@ static int init(const struct device *dev)
|
|||
struct mcp970x_data *data = dev->data;
|
||||
int ret;
|
||||
|
||||
if (!device_is_ready(config->adc.dev)) {
|
||||
if (!adc_is_ready_dt(&config->adc)) {
|
||||
LOG_ERR("ADC is not ready");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ static int ntc_thermistor_init(const struct device *dev)
|
|||
const struct ntc_thermistor_config *cfg = dev->config;
|
||||
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");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ int main(void)
|
|||
|
||||
/* Configure channels individually prior to sampling. */
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ static const int adc_channels_count = ARRAY_SIZE(adc_channels);
|
|||
|
||||
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");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ static void init_adc(void)
|
|||
{
|
||||
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++) {
|
||||
ret = adc_channel_setup_dt(&adc_channels[i]);
|
||||
|
|
|
@ -37,7 +37,7 @@ static int init_adc(const struct adc_dt_spec *spec, int input_mv)
|
|||
{
|
||||
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);
|
||||
zassert_equal(ret, 0, "Setting up of the first channel failed with code %d", ret);
|
||||
|
|
|
@ -114,7 +114,7 @@ void *setup(void)
|
|||
|
||||
for (size_t i = 0U; i < ARRAY_SIZE(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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue