-
Notifications
You must be signed in to change notification settings - Fork 7.6k
drivers: serial: stm32: return error for bad baud #92119
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
base: main
Are you sure you want to change the base?
drivers: serial: stm32: return error for bad baud #92119
Conversation
Hello @edenfrosst, and thank you very much for your first pull request to the Zephyr project! |
232d3eb
to
8949a45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the STM32 serial driver to propagate errors when setting the baud rate, ensuring the API reflects possible failures during configuration.
- Change uart_stm32_set_baudrate and uart_stm32_parameters_set to return error codes.
- Propagate error checks in uart_stm32_configure and uart_stm32_registers_configure.
- Update return statements to provide specific error codes for failure cases.
Comments suppressed due to low confidence (2)
drivers/serial/uart_stm32.c:184
- The error code returned when the baud rate prescaler index is out of range differs from the error code used in uart_stm32_configure (-ENOTSUP) and uart_stm32_registers_configure (-EINVAL). Consider standardizing the error codes returned across functions for a more consistent API.
return -EINVAL;
drivers/serial/uart_stm32.c:491
- Since the return type of uart_stm32_parameters_set has been changed from void to int for error propagation, ensure that the function's documentation (comments or API docs) is updated to reflect this change.
static int uart_stm32_parameters_set(const struct device *dev,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comment and a free question.
Otherwise LGTM.
8949a45
to
4631b47
Compare
4631b47
to
e4bc214
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Maybe could you fix the commit message header line:
-drivers: serial: stm32: return error for bad baud
+drivers: serial: stm32: return error for bad baud rate
or
drivers: serial: stm32: propagate baud rate config failure
The uart_stm32 driver gives no way for a user to tell if setting a new baud rate was successful. Propagate error checks up to the API level. Signed-off-by: Eden Frosst <edenfrosst@gmail.com>
e4bc214
to
23e3549
Compare
|
The uart_stm32 driver gives no way for a user to tell if setting a new baud rate was successful.
Propagate error checks up to the API level.