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

bluetooth: hci: spi: 0xFF is a valid payload length #69493

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

JordanYates
Copy link
Collaborator

A payload size of 0xFF is valid and should not be a reason to keep looping for more headers. The complete reqiurement is now:

header_slave[STATUS_HEADER_READY] == READY_NOW &&
header_slave[STATUS_HEADER_TOREAD] > 0

This fixes events being dropped when the payload size is 255.

A payload size of 0xFF is valid and should not be a reason to keep
looping for more headers. The complete reqiurement is now:
```
header_slave[STATUS_HEADER_READY] == READY_NOW &&
header_slave[STATUS_HEADER_TOREAD] > 0
```
This fixes events being dropped when the payload size is 255.

Signed-off-by: Jordan Yates <[email protected]>
@Thalley
Copy link
Collaborator

Thalley commented Feb 27, 2024

@JordanYates did you figure out why there was a check for 0xff?

I'm wondering if it is related to this

(void)memset(&txmsg, 0xFF, SPI_MAX_MSG_LEN);

@JordanYates
Copy link
Collaborator Author

@JordanYates did you figure out why there was a check for 0xff?

I'm wondering if it is related to this

(void)memset(&txmsg, 0xFF, SPI_MAX_MSG_LEN);

It's been there since the driver was added 7 years ago, so I'll take my best guess.

The purpose of the check if to validate that the controller is ready to send the payload, and if not, check again.
If the controller is not ready, the line state, and hence the received data, will be 0x00 or 0xFF, depending on the controller SPI slave implementation.
The original condition did not include header_slave[STATUS_HEADER_READY] == READY_NOW.
The original check was probably trying to check against the idle line state, but missed the simplest solution of checking header_slave[STATUS_HEADER_READY] == READY_NOW.

@dleach02 dleach02 merged commit bb27f05 into zephyrproject-rtos:main Feb 29, 2024
27 checks passed
@JordanYates JordanYates deleted the 240227_spi_hci_255 branch February 29, 2024 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants