Skip to content

Commit af4cbdc

Browse files
asmellbykartben
authored andcommitted
drivers: adc: gecko: Fix error return values
Enable the adc_error_cases test on Series 2 devices and change the return values in the driver for unsupported configurations to what the test expects. Ensure that the resolution configuration in the test is valid such that the invalid buffer test correctly receives -ENOMEM. Signed-off-by: Aksel Skauge Mellbye <[email protected]>
1 parent 647142f commit af4cbdc

File tree

6 files changed

+64
-4
lines changed

6 files changed

+64
-4
lines changed

drivers/adc/iadc_gecko.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static int start_read(const struct device *dev, const struct adc_sequence *seque
127127

128128
if (sequence->oversampling) {
129129
LOG_ERR("Oversampling is not supported");
130-
return -ENOTSUP;
130+
return -EINVAL;
131131
}
132132

133133
/* Check resolution setting */
@@ -331,7 +331,7 @@ static int adc_gecko_channel_setup(const struct device *dev,
331331
break;
332332
default:
333333
LOG_ERR("unsupported channel gain '%d'", channel_cfg->gain);
334-
return -ENOTSUP;
334+
return -EINVAL;
335335
}
336336

337337
/* Setup reference */
@@ -353,7 +353,7 @@ static int adc_gecko_channel_setup(const struct device *dev,
353353
default:
354354
LOG_ERR("unsupported channel reference type '%d'",
355355
channel_cfg->reference);
356-
return -ENOTSUP;
356+
return -EINVAL;
357357
}
358358

359359
channel_config->initialized = true;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2025 Silicon Laboratories Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
aliases {
9+
adc = &adc0;
10+
};
11+
};
12+
13+
&adc0 {
14+
status = "okay";
15+
#address-cells = <1>;
16+
#size-cells = <0>;
17+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2025 Silicon Laboratories Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
aliases {
9+
adc = &adc0;
10+
};
11+
};
12+
13+
&adc0 {
14+
status = "okay";
15+
#address-cells = <1>;
16+
#size-cells = <0>;
17+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2025 Silicon Laboratories Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
aliases {
9+
adc = &adc0;
10+
};
11+
};
12+
13+
&adc0 {
14+
status = "okay";
15+
#address-cells = <1>;
16+
#size-cells = <0>;
17+
};

tests/drivers/adc/adc_error_cases/src/adc_error_cases.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ static const struct adc_channel_cfg valid_channel_cfg = {
2424
#endif
2525
};
2626

27+
#if defined(CONFIG_SOC_FAMILY_SILABS_S2)
28+
#define VALID_RESOLUTION 12
29+
#else
30+
#define VALID_RESOLUTION 10
31+
#endif
32+
2733
static const struct adc_sequence valid_seq = {
2834
.buffer = m_sample_buffer,
2935
.buffer_size = BUFFER_LEN * sizeof(m_sample_buffer),
3036
.options = NULL,
31-
.resolution = 10,
37+
.resolution = VALID_RESOLUTION,
3238
.oversampling = 0,
3339
.channels = 1,
3440
};

tests/drivers/adc/adc_error_cases/testcase.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ tests:
1212
- nrf54lm20dk/nrf54lm20a/cpuapp
1313
- nrf54h20dk/nrf54h20/cpuapp
1414
- ophelia4ev/nrf54l15/cpuapp
15+
- xg24_rb4187c
16+
- xg27_dk2602a
17+
- xg29_rb4412a

0 commit comments

Comments
 (0)