Browse Source

drivers: adc: Remove channel_count property for Renesas driver

Currently, in Renesas adc driver, channel_count is used
as the maximum index of the channels can be supported.
However, the value input in dts of "channel_count"
represents the total number of supported channels.

After consideration, we have decided to remove this
reduntant property.

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
pull/86846/head
Khoa Nguyen 4 months ago committed by Benjamin Cabé
parent
commit
8671fdd86d
  1. 13
      drivers/adc/adc_renesas_ra.c
  2. 5
      dts/bindings/adc/renesas,ra-adc.yaml

13
drivers/adc/adc_renesas_ra.c

@ -36,8 +36,6 @@ void adc_scan_end_isr(void); @@ -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) @@ -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 @@ -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) @@ -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), \

5
dts/bindings/adc/renesas,ra-adc.yaml

@ -16,11 +16,6 @@ properties: @@ -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

Loading…
Cancel
Save