summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/default/src/thermistor.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/test/drivers/default/src/thermistor.c')
-rw-r--r--zephyr/test/drivers/default/src/thermistor.c47
1 files changed, 8 insertions, 39 deletions
diff --git a/zephyr/test/drivers/default/src/thermistor.c b/zephyr/test/drivers/default/src/thermistor.c
index edbe7acad5..417b482d99 100644
--- a/zephyr/test/drivers/default/src/thermistor.c
+++ b/zephyr/test/drivers/default/src/thermistor.c
@@ -3,20 +3,19 @@
* found in the LICENSE file.
*/
-#include "../driver/temp_sensor/thermistor.h"
-#include "common.h"
-#include "temp_sensor/temp_sensor.h"
-#include "test/drivers/test_state.h"
-
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
#include <zephyr/drivers/adc.h>
#include <zephyr/drivers/adc/adc_emul.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include <temp_sensor.h>
+#include "common.h"
+#include "../driver/temp_sensor/thermistor.h"
+#include "temp_sensor/temp_sensor.h"
+#include "test/drivers/test_state.h"
+
#define GPIO_PG_EC_DSW_PWROK_PATH DT_PATH(named_gpios, pg_ec_dsw_pwrok)
#define GPIO_PG_EC_DSW_PWROK_PORT DT_GPIO_PIN(GPIO_PG_EC_DSW_PWROK_PATH, gpios)
@@ -59,10 +58,6 @@ ZTEST_USER(thermistor, test_thermistor_power_pin)
sensor_idx++) {
const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
- /* Skip for sensors that are not thermistors */
- if (sensor->zephyr_info->thermistor == NULL)
- continue;
-
zassert_ok(adc_emul_const_value_set(adc_dev, sensor->idx,
A_VALID_VOLTAGE),
"adc_emul_value_func_set() failed on %s",
@@ -77,10 +72,6 @@ ZTEST_USER(thermistor, test_thermistor_power_pin)
sensor_idx++) {
const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
- /* Skip for sensors that are not thermistors */
- if (sensor->zephyr_info->thermistor == NULL)
- continue;
-
zassert_equal(EC_ERROR_NOT_POWERED,
sensor->zephyr_info->read(sensor, &temp),
"%s failed", sensor->name);
@@ -94,10 +85,6 @@ ZTEST_USER(thermistor, test_thermistor_power_pin)
sensor_idx++) {
const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
- /* Skip for sensors that are not thermistors */
- if (sensor->zephyr_info->thermistor == NULL)
- continue;
-
zassert_equal(EC_SUCCESS,
sensor->zephyr_info->read(sensor, &temp),
"%s failed", sensor->name);
@@ -126,10 +113,6 @@ ZTEST_USER(thermistor, test_thermistor_adc_read_error)
sensor_idx++) {
const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
- /* Skip for sensors that are not thermistors */
- if (sensor->zephyr_info->thermistor == NULL)
- continue;
-
zassert_ok(adc_emul_value_func_set(adc_dev, sensor->idx,
adc_error_func, NULL),
"adc_emul_value_func_set() failed on %s",
@@ -140,10 +123,6 @@ ZTEST_USER(thermistor, test_thermistor_adc_read_error)
sensor_idx++) {
const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
- /* Skip for sensors that are not thermistors */
- if (sensor->zephyr_info->thermistor == NULL)
- continue;
-
zassert_equal(EC_ERROR_UNKNOWN,
sensor->zephyr_info->read(sensor, &temp),
"%s failed", sensor->name);
@@ -286,16 +265,10 @@ ZTEST_USER(thermistor, test_thermistors_adc_temperature_conversion)
const static int reference_res_arr[] = { DT_FOREACH_STATUS_OKAY(
THERMISTOR_COMPAT, GET_THERMISTOR_REF_RES) };
- for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE;
- sensor_idx++) {
- /* Skip for sensors that are not thermistors */
- if (temp_sensors[sensor_idx].zephyr_info->thermistor == NULL)
- continue;
-
+ for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE; sensor_idx++)
do_thermistor_test(&temp_sensors[sensor_idx],
reference_mv_arr[sensor_idx],
reference_res_arr[sensor_idx]);
- }
}
ZTEST_USER(thermistor, test_device_nodes_enabled)
@@ -339,10 +312,6 @@ static void thermistor_cleanup(void *state)
for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE;
sensor_idx++) {
- /* Skip for sensors that are not thermistors */
- if (temp_sensors[sensor_idx].zephyr_info->thermistor == NULL)
- continue;
-
/* Setup ADC to return 27*C (300K) which is reasonable value */
adc_emul_const_value_set(
adc_dev, temp_sensors[sensor_idx].idx,