Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: Use DEVICE_API #65

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion drivers/sensor/example_sensor/example_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static int example_sensor_channel_get(const struct device *dev,
return 0;
}

static const struct sensor_driver_api example_sensor_api = {
static DEVICE_API(sensor, example_sensor_api) = {
.sample_fetch = &example_sensor_sample_fetch,
.channel_get = &example_sensor_channel_get,
};
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