lib: snprintf_can_error_frame: print counter errors if CAN_ERR_CNT is set
Since version 6.0.0 (specifically [1]), the kernel has a new flag:
CAN_ERR_CNT to notify whether or not the error counter is set. Use
this to decide whether on not the error-counter-tx-rx should be
printed.
This way, when a driver set data[6] and data[7] to zero, it is
possible to differentiate whether the error counter is not available
or if the drivers simply reported both counters to be zero.
For interoperability reasons, continue to check data[6] and data[7]
against zero so that the code still works with the old behavior if
run on a kernel version lower than 6.0.0.
[1] commit 3e5c291c7942 ("can: add CAN_ERR_CNT flag to notify
availability of error counter")
Link: https://git.kernel.org/torvalds/linux/c/3e5c291c7942
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://lore.kernel.org/all/20221114163848.3398-4-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
pull/387/head
parent
f3ce3efe66
commit
21fb43532e
2
lib.c
2
lib.c
|
|
@ -680,7 +680,7 @@ void snprintf_can_error_frame(char *buf, size_t len, const struct canfd_frame *c
|
|||
}
|
||||
}
|
||||
|
||||
if (cf->data[6] || cf->data[7]) {
|
||||
if (cf->can_id & CAN_ERR_CNT || cf->data[6] || cf->data[7]) {
|
||||
n += snprintf(buf + n, len - n, "%s", sep);
|
||||
n += snprintf(buf + n, len - n, "error-counter-tx-rx{{%d}{%d}}",
|
||||
cf->data[6], cf->data[7]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue