summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Baltieri <fabiobaltieri@google.com>2021-06-24 16:57:17 +0000
committerCommit Bot <commit-bot@chromium.org>2021-06-28 12:56:52 +0000
commit96528ae712a9ebfa3658ba4943b60c7a527cfba4 (patch)
tree0bfa09d133d2b348de97b6f947bd96a0f691da82
parentf4362c1b541ad3ca10b8cb2f7b72c8063dea6fd8 (diff)
downloadchrome-ec-96528ae712a9ebfa3658ba4943b60c7a527cfba4.tar.gz
zephyr: use DEVICE_DT_GET for phandle references
Convert few device_get_binding based on DT_PROP_BY_PHANDLE to DEVICE_DT_GET. BRANCH=none BUG=none TEST=zmake configure -b -B ~/build-volteer/ zephyr/projects/volteer/volteer TEST=zmake configure -b -B ~/build-it8xxx2_evb/ zephyr/projects/it8xxx2_evb Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: Ib8feee8de759481b833010be815cdeb8178f3710 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2985464 Reviewed-by: Yuval Peress <peress@chromium.org>
-rw-r--r--zephyr/shim/src/fan.c6
-rw-r--r--zephyr/shim/src/gpio.c9
-rw-r--r--zephyr/shim/src/i2c.c3
-rw-r--r--zephyr/shim/src/pwm.c4
4 files changed, 10 insertions, 12 deletions
diff --git a/zephyr/shim/src/fan.c b/zephyr/shim/src/fan.c
index 1e38dff050..b6fa7b999a 100644
--- a/zephyr/shim/src/fan.c
+++ b/zephyr/shim/src/fan.c
@@ -60,9 +60,9 @@ const struct fan_t fans[] = {
#endif /* named_fan */
};
-#define TACHO_DEV_INIT(node_id) { \
- fan_control[node_id].tach = \
- device_get_binding(DT_PROP_BY_PHANDLE(node_id, tach, label)); \
+#define TACHO_DEV_INIT(node_id) { \
+ fan_control[node_id].tach = \
+ DEVICE_DT_GET(DT_PHANDLE(node_id, tach)); \
}
/* Rpm deviation (Unit:percent) */
diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c
index caf9c7116a..721791ab3d 100644
--- a/zephyr/shim/src/gpio.c
+++ b/zephyr/shim/src/gpio.c
@@ -23,7 +23,7 @@ struct gpio_config {
/* GPIO net name */
const char *name;
/* Set at build time for lookup */
- const char *dev_name;
+ const struct device *dev;
/* Bit number of pin within device */
gpio_pin_t pin;
/* From DTS, excludes interrupts flags */
@@ -36,7 +36,7 @@ struct gpio_config {
( \
{ \
.name = DT_LABEL(id), \
- .dev_name = DT_LABEL(DT_PHANDLE(id, gpios)), \
+ .dev = DEVICE_DT_GET(DT_PHANDLE(id, gpios)), \
.pin = DT_GPIO_PIN(id, gpios), \
.init_flags = DT_GPIO_FLAGS(id, gpios), \
}, ), \
@@ -263,12 +263,11 @@ static int init_gpios(const struct device *unused)
/* Loop through all GPIOs in device tree to set initial configuration */
for (size_t i = 0; i < ARRAY_SIZE(configs); ++i) {
- data[i].dev = device_get_binding(configs[i].dev_name);
+ data[i].dev = configs[i].dev;
int rv;
- if (data[i].dev == NULL) {
+ if (!device_is_ready(data[i].dev))
LOG_ERR("Not found (%s)", configs[i].name);
- }
/*
* The configs[i].init_flags variable is read-only, so the
diff --git a/zephyr/shim/src/i2c.c b/zephyr/shim/src/i2c.c
index 7c6ffa765b..cc4af85021 100644
--- a/zephyr/shim/src/i2c.c
+++ b/zephyr/shim/src/i2c.c
@@ -13,8 +13,7 @@
* This macro should be called from within DT_FOREACH_CHILD.
*/
#define INIT_DEV_BINDING(id) \
- i2c_devices[I2C_PORT(id)] = device_get_binding( \
- DT_PROP_BY_PHANDLE(id, i2c_port, label));
+ i2c_devices[I2C_PORT(id)] = DEVICE_DT_GET(DT_PHANDLE(id, i2c_port));
#define INIT_REMOTE_PORTS(id) \
i2c_remote_ports[I2C_PORT(id)] = DT_PROP_OR(id, remote_port, -1);
diff --git a/zephyr/shim/src/pwm.c b/zephyr/shim/src/pwm.c
index 0446fd47ce..39fd72007e 100644
--- a/zephyr/shim/src/pwm.c
+++ b/zephyr/shim/src/pwm.c
@@ -26,8 +26,8 @@ LOG_MODULE_REGISTER(pwm_shim, LOG_LEVEL_ERR);
*/
#define INIT_DEV_BINDING(id) { \
pwm_configs[PWM_CHANNEL(id)].name = DT_LABEL(id); \
- pwm_configs[PWM_CHANNEL(id)].dev = device_get_binding( \
- DT_PROP_BY_PHANDLE(id, pwms, label)); \
+ pwm_configs[PWM_CHANNEL(id)].dev = DEVICE_DT_GET( \
+ DT_PHANDLE(id, pwms)); \
pwm_configs[PWM_CHANNEL(id)].pin = DT_PWMS_CHANNEL(id); \
pwm_configs[PWM_CHANNEL(id)].flags = DT_PWMS_FLAGS(id); \
pwm_configs[PWM_CHANNEL(id)].freq = DT_PROP(id, frequency); \