Commit 8671fdd8 authored by Khoa Nguyen's avatar Khoa Nguyen Committed by Benjamin Cabé
Browse files

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: default avatarKhoa Nguyen <khoa.nguyen.xh@renesas.com>
parent 0d36361b
Loading
Loading
Loading
Loading
+2 −11
Changes for drivers/adc/adc_renesas_ra.c: 2 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -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),                                                         \
+0 −5
Changes for dts/bindings/adc/renesas,ra-adc.yaml: 0 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -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