Skip to content

Commit

Permalink
drivers: blink: Use DEVICE_API
Browse files Browse the repository at this point in the history
Demonstrate DEVICE_API usage for blink_driver_api.

Signed-off-by: Pieter De Gendt <[email protected]>
  • Loading branch information
pdgendt authored and kartben committed Nov 28, 2024
1 parent 459cec1 commit b2d670a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion drivers/blink/gpio_led.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
5 changes: 2 additions & 3 deletions include/app/drivers/blink.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b2d670a

Please sign in to comment.