提交 a455a2e3 编写于 作者: S Stephane Grosjean 提交者: Zheng Zengkai

can: peak_usb: pcan_usb_handle_bus_evt(): fix reading rxerr/txerr values

stable inclusion
from stable-5.10.56
commit 2fc2c2816cb76fd39bf446f12a72e3bd20b52018
bugzilla: 176004 https://gitee.com/openeuler/kernel/issues/I4DYZ4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2fc2c2816cb76fd39bf446f12a72e3bd20b52018

--------------------------------

commit 590eb2b7 upstream.

This patch fixes an incorrect way of reading error counters in messages
received for this purpose from the PCAN-USB interface. These messages
inform about the increase or decrease of the error counters, whose values
are placed in bytes 1 and 2 of the message data (not 0 and 1).

Fixes: ea8b33bd ("can: pcan_usb: add support of rxerr/txerr counters")
Link: https://lore.kernel.org/r/20210625130931.27438-4-s.grosjean@peak-system.com
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: NStephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: NMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 98759a49
......@@ -117,7 +117,8 @@ MODULE_SUPPORTED_DEVICE("PEAK-System PCAN-USB adapter");
#define PCAN_USB_BERR_MASK (PCAN_USB_ERR_RXERR | PCAN_USB_ERR_TXERR)
/* identify bus event packets with rx/tx error counters */
#define PCAN_USB_ERR_CNT 0x80
#define PCAN_USB_ERR_CNT_DEC 0x00 /* counters are decreasing */
#define PCAN_USB_ERR_CNT_INC 0x80 /* counters are increasing */
/* private to PCAN-USB adapter */
struct pcan_usb {
......@@ -611,11 +612,12 @@ static int pcan_usb_handle_bus_evt(struct pcan_usb_msg_context *mc, u8 ir)
/* acccording to the content of the packet */
switch (ir) {
case PCAN_USB_ERR_CNT:
case PCAN_USB_ERR_CNT_DEC:
case PCAN_USB_ERR_CNT_INC:
/* save rx/tx error counters from in the device context */
pdev->bec.rxerr = mc->ptr[0];
pdev->bec.txerr = mc->ptr[1];
pdev->bec.rxerr = mc->ptr[1];
pdev->bec.txerr = mc->ptr[2];
break;
default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册