drivers: can: remove CAN_BUS_UNKNOWN CAN controller state

The CAN_BUS_UNKNOWN CAN controller state is only used to indicate that
the current CAN controller state could not be read.

Remove it and change the signature of the can_get_state() API function
to return an integer indicating success or failure.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2022-01-19 10:21:01 +01:00 committed by Carles Cufí
commit 2aed5a1237
15 changed files with 155 additions and 114 deletions

View file

@ -406,6 +406,7 @@ void CO_CANverifyErrors(CO_CANmodule_t *CANmodule)
enum can_state state;
uint8_t rx_overflows;
uint32_t errors;
int err;
/*
* TODO: Zephyr lacks an API for reading the rx mailbox
@ -413,7 +414,11 @@ void CO_CANverifyErrors(CO_CANmodule_t *CANmodule)
*/
rx_overflows = 0;
state = can_get_state(CANmodule->dev, &err_cnt);
err = can_get_state(CANmodule->dev, &state, &err_cnt);
if (err != 0) {
LOG_ERR("failed to get CAN controller state (err %d)", err);
return;
}
errors = ((uint32_t)err_cnt.tx_err_cnt << 16) |
((uint32_t)err_cnt.rx_err_cnt << 8) |