.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * CAN driver for esd CAN-USB/2 and CAN-USB/Micro |
---|
3 | 4 | * |
---|
4 | 5 | * 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. |
---|
18 | 6 | */ |
---|
19 | 7 | #include <linux/signal.h> |
---|
20 | 8 | #include <linux/slab.h> |
---|
.. | .. |
---|
239 | 227 | u8 rxerr = msg->msg.rx.data[2]; |
---|
240 | 228 | u8 txerr = msg->msg.rx.data[3]; |
---|
241 | 229 | |
---|
| 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 | + |
---|
242 | 234 | skb = alloc_can_err_skb(priv->netdev, &cf); |
---|
243 | 235 | if (skb == NULL) { |
---|
244 | 236 | stats->rx_dropped++; |
---|
.. | .. |
---|
265 | 257 | break; |
---|
266 | 258 | default: |
---|
267 | 259 | priv->can.state = CAN_STATE_ERROR_ACTIVE; |
---|
| 260 | + txerr = 0; |
---|
| 261 | + rxerr = 0; |
---|
268 | 262 | break; |
---|
269 | 263 | } |
---|
270 | 264 | } else { |
---|
.. | .. |
---|
284 | 278 | cf->data[2] |= CAN_ERR_PROT_STUFF; |
---|
285 | 279 | break; |
---|
286 | 280 | default: |
---|
287 | | - cf->data[3] = ecc & SJA1000_ECC_SEG; |
---|
288 | 281 | break; |
---|
289 | 282 | } |
---|
290 | 283 | |
---|
.. | .. |
---|
292 | 285 | if (!(ecc & SJA1000_ECC_DIR)) |
---|
293 | 286 | cf->data[2] |= CAN_ERR_PROT_TX; |
---|
294 | 287 | |
---|
| 288 | + /* Bit stream position in CAN frame as the error was detected */ |
---|
| 289 | + cf->data[3] = ecc & SJA1000_ECC_SEG; |
---|
| 290 | + |
---|
295 | 291 | if (priv->can.state == CAN_STATE_ERROR_WARNING || |
---|
296 | 292 | priv->can.state == CAN_STATE_ERROR_PASSIVE) { |
---|
297 | 293 | cf->data[1] = (txerr > rxerr) ? |
---|