]> git.baikalelectronics.ru Git - kernel.git/commit
can: xilinx_can: use can_change_state()
authorAnssi Hannula <anssi.hannula@bitwise.fi>
Mon, 29 Jan 2018 15:28:24 +0000 (17:28 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 27 Jul 2018 08:40:17 +0000 (10:40 +0200)
commit870f8f103e10482bd6f5c1f29d98c3724eef0808
tree4f70f5427bcd94b196f93ae9d6de9dd1ace48777
parent17f1789cd35555a4b57ee8215cbc2ec111d42a73
can: xilinx_can: use can_change_state()

Replace some custom code with a call to can_change_state().

This subtly changes the error reporting behavior when both RX and TX
error counters indicate the same state.

Previously, if both RX and TX counters indicated the same state:
- if overall state is PASSIVE, report CAN_ERR_CRTL_RX_PASSIVE
- if overall state is WARNING, report CAN_ERR_CRTL_TX_WARNING or
  CAN_ERR_CRTL_RX_WARNING depending on which counter is higher,
  or CAN_ERR_CRTL_RX_WARNING if the counters have the same value.

After this commit:
- report RX_* or TX_* depending on which counter is higher, or both if
  the counters have exactly the same value.

This behavior is consistent with many other CAN drivers that use this
same code pattern.

Tested with the integrated CAN on Zynq-7000 SoC.

v2: Simplify resolving states as suggested by Andri Yngvason.

Signed-off-by: Anssi Hannula <anssi.hannula@bitwise.fi>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/xilinx_can.c