hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/can/usb/esd_usb2.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * CAN driver for esd CAN-USB/2 and CAN-USB/Micro
34 *
45 * Copyright (C) 2010-2012 Matthias Fuchs <matthias.fuchs@esd.eu>, esd gmbh
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License as published
8
- * by the Free Software Foundation; version 2 of the License.
9
- *
10
- * This program is distributed in the hope that it will be useful, but
11
- * WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- * General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License along
16
- * with this program; if not, write to the Free Software Foundation, Inc.,
17
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
186 */
197 #include <linux/signal.h>
208 #include <linux/slab.h>
....@@ -239,6 +227,10 @@
239227 u8 rxerr = msg->msg.rx.data[2];
240228 u8 txerr = msg->msg.rx.data[3];
241229
230
+ netdev_dbg(priv->netdev,
231
+ "CAN_ERR_EV_EXT: dlc=%#02x state=%02x ecc=%02x rec=%02x tec=%02x\n",
232
+ msg->msg.rx.dlc, state, ecc, rxerr, txerr);
233
+
242234 skb = alloc_can_err_skb(priv->netdev, &cf);
243235 if (skb == NULL) {
244236 stats->rx_dropped++;
....@@ -265,6 +257,8 @@
265257 break;
266258 default:
267259 priv->can.state = CAN_STATE_ERROR_ACTIVE;
260
+ txerr = 0;
261
+ rxerr = 0;
268262 break;
269263 }
270264 } else {
....@@ -284,7 +278,6 @@
284278 cf->data[2] |= CAN_ERR_PROT_STUFF;
285279 break;
286280 default:
287
- cf->data[3] = ecc & SJA1000_ECC_SEG;
288281 break;
289282 }
290283
....@@ -292,6 +285,9 @@
292285 if (!(ecc & SJA1000_ECC_DIR))
293286 cf->data[2] |= CAN_ERR_PROT_TX;
294287
288
+ /* Bit stream position in CAN frame as the error was detected */
289
+ cf->data[3] = ecc & SJA1000_ECC_SEG;
290
+
295291 if (priv->can.state == CAN_STATE_ERROR_WARNING ||
296292 priv->can.state == CAN_STATE_ERROR_PASSIVE) {
297293 cf->data[1] = (txerr > rxerr) ?