diff --git a/drivers/adc/adc_renesas_ra.c b/drivers/adc/adc_renesas_ra.c index af929606022..e448fcb4c40 100644 --- a/drivers/adc/adc_renesas_ra.c +++ b/drivers/adc/adc_renesas_ra.c @@ -36,8 +36,6 @@ void adc_scan_end_isr(void); * This structure contains constant data for given instance of RA ADC. */ struct adc_ra_config { - /** Number of supported channels */ - uint8_t num_channels; /** Mask for channels existed in each board */ uint32_t channel_available_mask; /** pinctrl configs */ @@ -155,16 +153,10 @@ static void adc_ra_isr(const struct device *dev) */ static int adc_ra_check_buffer_size(const struct device *dev, const struct adc_sequence *sequence) { - const struct adc_ra_config *config = dev->config; uint8_t channels = 0; size_t needed; - uint32_t mask; - for (mask = BIT(config->num_channels - 1); mask != 0; mask >>= 1) { - if (mask & sequence->channels) { - channels++; - } - } + channels = POPCOUNT(sequence->channels); needed = channels * sizeof(uint16_t); if (sequence->options) { @@ -202,7 +194,7 @@ static int adc_ra_start_read(const struct device *dev, const struct adc_sequence return -ENOTSUP; } - if (find_msb_set(sequence->channels) > config->num_channels) { + if ((sequence->channels & ~config->channel_available_mask) != 0) { LOG_ERR("unsupported channels in mask: 0x%08x", sequence->channels); return -ENOTSUP; } @@ -355,7 +347,6 @@ static int adc_ra_init(const struct device *dev) .ref_internal = DT_INST_PROP(idx, vref_mv), \ IF_ENABLED(CONFIG_ADC_ASYNC, (.read_async = adc_ra_read_async))}; \ static const struct adc_ra_config adc_ra_config_##idx = { \ - .num_channels = DT_INST_PROP(idx, channel_count), \ .channel_available_mask = DT_INST_PROP(idx, channel_available_mask), \ .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(idx), \ IRQ_CONFIGURE_DEFINE(idx), \ diff --git a/dts/bindings/adc/renesas,ra-adc.yaml b/dts/bindings/adc/renesas,ra-adc.yaml index 1e5f4315ab0..0ce2649529a 100644 --- a/dts/bindings/adc/renesas,ra-adc.yaml +++ b/dts/bindings/adc/renesas,ra-adc.yaml @@ -16,11 +16,6 @@ properties: required: true description: ADC reference voltage (Unit:mV) - channel-count: - type: int - required: true - description: The number of ADC channels - "#io-channel-cells": const: 1