-
Notifications
You must be signed in to change notification settings - Fork 8.2k
tracing: add gpio tracing capabilities and sample #74199
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
|
|
||
| #include <zephyr/sys/__assert.h> | ||
| #include <zephyr/sys/slist.h> | ||
| #include <zephyr/tracing/tracing.h> | ||
|
|
||
| #include <zephyr/types.h> | ||
| #include <stddef.h> | ||
|
|
@@ -550,7 +551,7 @@ struct gpio_dt_spec { | |
| * .ngpios = 32, | ||
| * .gpios_reserved = 0xdeadbeef, | ||
| * // 0b1101 1110 1010 1101 1011 1110 1110 1111 | ||
| * | ||
| * }; | ||
| * static const struct some_config dev_cfg_b = { | ||
| * .ngpios = 18, | ||
| * .gpios_reserved = 0xfffc0418, | ||
|
|
@@ -875,8 +876,12 @@ static inline int z_impl_gpio_pin_interrupt_configure(const struct device *port, | |
| (const struct gpio_driver_data *)port->data; | ||
| enum gpio_int_trig trig; | ||
| enum gpio_int_mode mode; | ||
| int ret; | ||
|
|
||
| SYS_PORT_TRACING_FUNC_ENTER(gpio_pin, interrupt_configure, port, pin, flags); | ||
|
|
||
| if (api->pin_interrupt_configure == NULL) { | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, interrupt_configure, port, pin, -ENOSYS); | ||
| return -ENOSYS; | ||
| } | ||
|
|
||
|
|
@@ -921,7 +926,9 @@ static inline int z_impl_gpio_pin_interrupt_configure(const struct device *port, | |
| mode = (enum gpio_int_mode)(flags & (GPIO_INT_EDGE | GPIO_INT_DISABLE | GPIO_INT_ENABLE)); | ||
| #endif /* CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT */ | ||
|
|
||
| return api->pin_interrupt_configure(port, pin, mode, trig); | ||
| ret = api->pin_interrupt_configure(port, pin, mode, trig); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, interrupt_configure, port, pin, ret); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -972,6 +979,9 @@ static inline int z_impl_gpio_pin_configure(const struct device *port, | |
| (const struct gpio_driver_config *)port->config; | ||
| struct gpio_driver_data *data = | ||
| (struct gpio_driver_data *)port->data; | ||
| int ret; | ||
|
|
||
| SYS_PORT_TRACING_FUNC_ENTER(gpio_pin, configure, port, pin, flags); | ||
|
|
||
| __ASSERT((flags & GPIO_INT_MASK) == 0, | ||
| "Interrupt flags are not supported"); | ||
|
|
@@ -1011,7 +1021,9 @@ static inline int z_impl_gpio_pin_configure(const struct device *port, | |
| data->invert &= ~(gpio_port_pins_t)BIT(pin); | ||
| } | ||
|
|
||
| return api->pin_configure(port, pin, flags); | ||
| ret = api->pin_configure(port, pin, flags); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, configure, port, pin, ret); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1060,12 +1072,18 @@ static inline int z_impl_gpio_port_get_direction(const struct device *port, gpio | |
| gpio_port_pins_t *outputs) | ||
| { | ||
| const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->api; | ||
| int ret; | ||
|
|
||
| SYS_PORT_TRACING_FUNC_ENTER(gpio_port, get_direction, port, map, inputs, outputs); | ||
|
|
||
| if (api->port_get_direction == NULL) { | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_port, get_direction, port, -ENOSYS); | ||
| return -ENOSYS; | ||
| } | ||
|
|
||
| return api->port_get_direction(port, map, inputs, outputs); | ||
| ret = api->port_get_direction(port, map, inputs, outputs); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_port, get_direction, port, ret); | ||
| return ret; | ||
| } | ||
| #endif /* CONFIG_GPIO_GET_DIRECTION */ | ||
|
|
||
|
|
@@ -1184,11 +1202,18 @@ static inline int z_impl_gpio_pin_get_config(const struct device *port, | |
| { | ||
| const struct gpio_driver_api *api = | ||
| (const struct gpio_driver_api *)port->api; | ||
| int ret; | ||
|
|
||
| SYS_PORT_TRACING_FUNC_ENTER(gpio_pin, get_config, port, pin, *flags); | ||
|
|
||
| if (api->pin_get_config == NULL) | ||
| if (api->pin_get_config == NULL) { | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, get_config, port, pin, -ENOSYS); | ||
| return -ENOSYS; | ||
| } | ||
|
|
||
| return api->pin_get_config(port, pin, flags); | ||
| ret = api->pin_get_config(port, pin, flags); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, get_config, port, pin, ret); | ||
| return ret; | ||
| } | ||
| #endif | ||
|
|
||
|
|
@@ -1230,13 +1255,16 @@ static inline int gpio_pin_get_config_dt(const struct gpio_dt_spec *spec, | |
| __syscall int gpio_port_get_raw(const struct device *port, | ||
| gpio_port_value_t *value); | ||
|
|
||
| static inline int z_impl_gpio_port_get_raw(const struct device *port, | ||
| gpio_port_value_t *value) | ||
| static inline int z_impl_gpio_port_get_raw(const struct device *port, gpio_port_value_t *value) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. such formatting changes should be in a separate commit |
||
| { | ||
| const struct gpio_driver_api *api = | ||
| (const struct gpio_driver_api *)port->api; | ||
| const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->api; | ||
| int ret; | ||
|
|
||
| SYS_PORT_TRACING_FUNC_ENTER(gpio_port, get_raw, port, value); | ||
|
|
||
| return api->port_get_raw(port, value); | ||
| ret = api->port_get_raw(port, value); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_port, get_raw, port, ret); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1299,8 +1327,13 @@ static inline int z_impl_gpio_port_set_masked_raw(const struct device *port, | |
| { | ||
| const struct gpio_driver_api *api = | ||
| (const struct gpio_driver_api *)port->api; | ||
| int ret; | ||
|
|
||
| return api->port_set_masked_raw(port, mask, value); | ||
| SYS_PORT_TRACING_FUNC_ENTER(gpio_port, set_masked_raw, port, mask, value); | ||
|
|
||
| ret = api->port_set_masked_raw(port, mask, value); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_port, set_masked_raw, port, ret); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1353,8 +1386,13 @@ static inline int z_impl_gpio_port_set_bits_raw(const struct device *port, | |
| { | ||
| const struct gpio_driver_api *api = | ||
| (const struct gpio_driver_api *)port->api; | ||
| int ret; | ||
|
|
||
| return api->port_set_bits_raw(port, pins); | ||
| SYS_PORT_TRACING_FUNC_ENTER(gpio_port, set_bits_raw, port, pins); | ||
|
|
||
| ret = api->port_set_bits_raw(port, pins); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_port, set_bits_raw, port, ret); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1391,8 +1429,13 @@ static inline int z_impl_gpio_port_clear_bits_raw(const struct device *port, | |
| { | ||
| const struct gpio_driver_api *api = | ||
| (const struct gpio_driver_api *)port->api; | ||
| int ret; | ||
|
|
||
| return api->port_clear_bits_raw(port, pins); | ||
| SYS_PORT_TRACING_FUNC_ENTER(gpio_port, clear_bits_raw, port, pins); | ||
|
|
||
| ret = api->port_clear_bits_raw(port, pins); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_port, clear_bits_raw, port, ret); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1429,8 +1472,13 @@ static inline int z_impl_gpio_port_toggle_bits(const struct device *port, | |
| { | ||
| const struct gpio_driver_api *api = | ||
| (const struct gpio_driver_api *)port->api; | ||
| int ret; | ||
|
|
||
| return api->port_toggle_bits(port, pins); | ||
| SYS_PORT_TRACING_FUNC_ENTER(gpio_port, toggle_bits, port, pins); | ||
|
|
||
| ret = api->port_toggle_bits(port, pins); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio_port, toggle_bits, port, ret); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1693,11 +1741,15 @@ static inline void gpio_init_callback(struct gpio_callback *callback, | |
| gpio_callback_handler_t handler, | ||
| gpio_port_pins_t pin_mask) | ||
| { | ||
| SYS_PORT_TRACING_FUNC_ENTER(gpio, init_callback, callback, handler, pin_mask); | ||
|
|
||
| __ASSERT(callback, "Callback pointer should not be NULL"); | ||
| __ASSERT(handler, "Callback handler pointer should not be NULL"); | ||
|
|
||
| callback->handler = handler; | ||
| callback->pin_mask = pin_mask; | ||
|
|
||
| SYS_PORT_TRACING_FUNC_EXIT(gpio, init_callback, callback); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1719,12 +1771,18 @@ static inline int gpio_add_callback(const struct device *port, | |
| { | ||
| const struct gpio_driver_api *api = | ||
| (const struct gpio_driver_api *)port->api; | ||
| int ret; | ||
|
|
||
| SYS_PORT_TRACING_FUNC_ENTER(gpio, add_callback, port, callback); | ||
|
|
||
| if (api->manage_callback == NULL) { | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio, add_callback, port, -ENOSYS); | ||
| return -ENOSYS; | ||
| } | ||
|
|
||
| return api->manage_callback(port, callback, true); | ||
| ret = api->manage_callback(port, callback, true); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio, add_callback, port, ret); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1767,12 +1825,18 @@ static inline int gpio_remove_callback(const struct device *port, | |
| { | ||
| const struct gpio_driver_api *api = | ||
| (const struct gpio_driver_api *)port->api; | ||
| int ret; | ||
|
|
||
| SYS_PORT_TRACING_FUNC_ENTER(gpio, remove_callback, port, callback); | ||
|
|
||
| if (api->manage_callback == NULL) { | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio, remove_callback, port, -ENOSYS); | ||
| return -ENOSYS; | ||
| } | ||
|
|
||
| return api->manage_callback(port, callback, false); | ||
| ret = api->manage_callback(port, callback, false); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio, remove_callback, port, ret); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1812,12 +1876,18 @@ static inline int z_impl_gpio_get_pending_int(const struct device *dev) | |
| { | ||
| const struct gpio_driver_api *api = | ||
| (const struct gpio_driver_api *)dev->api; | ||
| int ret; | ||
|
|
||
| SYS_PORT_TRACING_FUNC_ENTER(gpio, get_pending_int, dev); | ||
|
|
||
| if (api->get_pending_int == NULL) { | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio, get_pending_int, dev, -ENOSYS); | ||
| return -ENOSYS; | ||
| } | ||
|
|
||
| return api->get_pending_int(dev); | ||
| ret = api->get_pending_int(dev); | ||
| SYS_PORT_TRACING_FUNC_EXIT(gpio, get_pending_int, dev, ret); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.