Skip to content

Commit 3f9c262

Browse files
vincent-mailholmarckleinebudde
authored andcommitted
can: error: add definitions for the different CAN error thresholds
Currently, drivers are using magic numbers to derive the CAN error states from the error counter. Add three macro declarations to remediate this. For reference, the error-active, error-passive and bus-off are defined in ISO 11898, section 12.1.4.2 "Error counting". Although ISO 11898 does not define error-warning state, this extra value is also commonly used and is thus also added. Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Vincent Mailhol <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 3e5c291 commit 3f9c262

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

include/uapi/linux/can/error.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,17 @@
127127
/* TX error counter / data[6] */
128128
/* RX error counter / data[7] */
129129

130+
/* CAN state thresholds
131+
*
132+
* Error counter Error state
133+
* -----------------------------------
134+
* 0 - 95 Error-active
135+
* 96 - 127 Error-warning
136+
* 128 - 255 Error-passive
137+
* 256 and greater Bus-off
138+
*/
139+
#define CAN_ERROR_WARNING_THRESHOLD 96
140+
#define CAN_ERROR_PASSIVE_THRESHOLD 128
141+
#define CAN_BUS_OFF_THRESHOLD 256
142+
130143
#endif /* _UAPI_CAN_ERROR_H */

0 commit comments

Comments
 (0)