summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Baltieri <fabiobaltieri@google.com>2021-06-24 17:24:55 +0000
committerCommit Bot <commit-bot@chromium.org>2021-06-28 12:57:02 +0000
commitd1c28d2974d8f573e727abb41e783b855b52f99d (patch)
tree1647614c99db0c73e18e2dd0ed1e0459f56dd6ff
parent96528ae712a9ebfa3658ba4943b60c7a527cfba4 (diff)
downloadchrome-ec-stabilize-RUST-14057.B-main.tar.gz
zephyr: test: convert tests to DEVICE_DT_GETstabilize-RUST-14057.B-mainstabilize-14057.B-main
Convert Zephyr tests from device_get_binding to DEVICE_DT_GET. BRANCH=none BUG=none TEST=cq dry drun Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I0da71b58d70c66bf68503b7c80e57051aace60c7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2985465 Reviewed-by: Yuval Peress <peress@chromium.org>
-rw-r--r--zephyr/test/drivers/src/temp_sensor.c4
-rw-r--r--zephyr/test/drivers/src/thermistor.c14
-rw-r--r--zephyr/test/i2c_dts/src/main.c10
3 files changed, 14 insertions, 14 deletions
diff --git a/zephyr/test/drivers/src/temp_sensor.c b/zephyr/test/drivers/src/temp_sensor.c
index 2e25bab67a..7cfc40b9d5 100644
--- a/zephyr/test/drivers/src/temp_sensor.c
+++ b/zephyr/test/drivers/src/temp_sensor.c
@@ -19,7 +19,7 @@
#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)
-#define ADC_DEVICE_NAME DT_LABEL(DT_NODELABEL(adc0))
+#define ADC_DEVICE_NODE DT_NODELABEL(adc0)
#define ADC_CHANNELS_NUM DT_PROP(DT_NODELABEL(adc0), nchannels)
/** Test error code when invalid sensor is passed to temp_sensor_read() */
@@ -96,7 +96,7 @@ static void check_valid_temperature(const struct device *adc_dev, int sensor)
/** Test if temp_sensor_read() returns temperature on success */
static void test_temp_sensor_read(void)
{
- const struct device *adc_dev = device_get_binding(ADC_DEVICE_NAME);
+ const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
int chan;
zassert_not_null(adc_dev, "Cannot get ADC device");
diff --git a/zephyr/test/drivers/src/thermistor.c b/zephyr/test/drivers/src/thermistor.c
index 621cdfaa68..f6e3b5f732 100644
--- a/zephyr/test/drivers/src/thermistor.c
+++ b/zephyr/test/drivers/src/thermistor.c
@@ -17,7 +17,7 @@
#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)
-#define ADC_DEVICE_NAME DT_LABEL(DT_NODELABEL(adc0))
+#define ADC_DEVICE_NODE DT_NODELABEL(adc0)
#define TEMP_3V3_13K7_47K_4050B_INST DT_INST(0, temp_3v3_13k7_47k_4050b)
#define ADC_CHANNEL_3V3_13K7_47K_4050B \
@@ -46,7 +46,7 @@ static void test_thermistor_power_pin(void)
{
const struct device *gpio_dev =
DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_PG_EC_DSW_PWROK_PATH, gpios));
- const struct device *adc_dev = device_get_binding(ADC_DEVICE_NAME);
+ const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
int temp;
zassert_not_null(gpio_dev, "Cannot get GPIO device");
@@ -122,7 +122,7 @@ static int adc_error_func(const struct device *dev, unsigned int channel,
/** Test if get temp function return expected error on ADC malfunction */
static void test_thermistor_adc_read_error(void)
{
- const struct device *adc_dev = device_get_binding(ADC_DEVICE_NAME);
+ const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
int temp;
zassert_not_null(adc_dev, "Cannot get ADC device");
@@ -230,7 +230,7 @@ static int adc_temperature_func(const struct device *dev, unsigned int channel,
/** Test conversion from ADC raw value to temperature */
static void test_thermistor_3v3_13k7_47k_4050b(void)
{
- const struct device *adc_dev = device_get_binding(ADC_DEVICE_NAME);
+ const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
struct thermistor_state state = {
.v = 3300,
.r = 13700,
@@ -281,7 +281,7 @@ static void test_thermistor_3v3_13k7_47k_4050b(void)
/** Test conversion from ADC raw value to temperature */
static void test_thermistor_3v3_30k9_47k_4050b(void)
{
- const struct device *adc_dev = device_get_binding(ADC_DEVICE_NAME);
+ const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
struct thermistor_state state = {
.v = 3300,
.r = 30900,
@@ -332,7 +332,7 @@ static void test_thermistor_3v3_30k9_47k_4050b(void)
/** Test conversion from ADC raw value to temperature */
static void test_thermistor_3v3_51k1_47k_4050b(void)
{
- const struct device *adc_dev = device_get_binding(ADC_DEVICE_NAME);
+ const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
struct thermistor_state state = {
.v = 3300,
.r = 51100,
@@ -383,7 +383,7 @@ static void test_thermistor_3v3_51k1_47k_4050b(void)
/** Test conversion from ADC raw value to temperature */
static void test_thermistor_3v0_22k6_47k_4050b(void)
{
- const struct device *adc_dev = device_get_binding(ADC_DEVICE_NAME);
+ const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
struct thermistor_state state = {
.v = 3000,
.r = 22600,
diff --git a/zephyr/test/i2c_dts/src/main.c b/zephyr/test/i2c_dts/src/main.c
index 359808776b..ccd58dde67 100644
--- a/zephyr/test/i2c_dts/src/main.c
+++ b/zephyr/test/i2c_dts/src/main.c
@@ -9,11 +9,11 @@
static void test_i2c_get_device(void)
{
- const struct device *accel0 = device_get_binding(
- DT_PROP_BY_PHANDLE(DT_PATH(named_i2c_ports, accel_0), i2c_port,
- label));
- const struct device *bmi_i2c = device_get_binding(
- DT_LABEL(DT_NODELABEL(bmi_i2c)));
+ const struct device *accel0 = DEVICE_DT_GET(
+ DT_PHANDLE(DT_PATH(named_i2c_ports, accel_0),
+ i2c_port));
+ const struct device *bmi_i2c = DEVICE_DT_GET(
+ DT_NODELABEL(bmi_i2c));
zassert_not_null(accel0, "accel0 was NULL");
zassert_not_null(bmi_i2c, "bmi_i2c was NULL");