From b2d670a3cc7b3adbd0e6691ac62ed493808c0523 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Tue, 30 Apr 2024 23:08:07 +0200 Subject: [PATCH] drivers: blink: Use DEVICE_API Demonstrate DEVICE_API usage for blink_driver_api. Signed-off-by: Pieter De Gendt --- drivers/blink/gpio_led.c | 2 +- include/app/drivers/blink.h | 5 ++--- west.yml | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/blink/gpio_led.c b/drivers/blink/gpio_led.c index ec482b78..471adea9 100644 --- a/drivers/blink/gpio_led.c +++ b/drivers/blink/gpio_led.c @@ -53,7 +53,7 @@ static int blink_gpio_led_set_period_ms(const struct device *dev, return 0; } -static const struct blink_driver_api blink_gpio_led_api = { +static DEVICE_API(blink, blink_gpio_led_api) = { .set_period_ms = &blink_gpio_led_set_period_ms, }; diff --git a/include/app/drivers/blink.h b/include/app/drivers/blink.h index 278c9549..a5beeb96 100644 --- a/include/app/drivers/blink.h +++ b/include/app/drivers/blink.h @@ -82,10 +82,9 @@ __syscall int blink_set_period_ms(const struct device *dev, static inline int z_impl_blink_set_period_ms(const struct device *dev, unsigned int period_ms) { - const struct blink_driver_api *api = - (const struct blink_driver_api *)dev->api; + __ASSERT_NO_MSG(DEVICE_API_IS(blink, dev)); - return api->set_period_ms(dev, period_ms); + return DEVICE_API_GET(blink, dev)->set_period_ms(dev, period_ms); } /** diff --git a/west.yml b/west.yml index 5a99b35f..6bb551cb 100644 --- a/west.yml +++ b/west.yml @@ -12,7 +12,7 @@ manifest: projects: - name: zephyr remote: zephyrproject-rtos - revision: pull/72293/head + revision: main import: # By using name-allowlist we can clone only the modules that are # strictly needed by the application.