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>