Another small batch of patches to be seen as preparation for adding
support of the newly available esd CAN-USB/3 to esd_usb.c.
Due to some unresolved questions adding support for
CAN_CTRLMODE_BERR_REPORTING has been postponed to one of the future
patches.
*Resend of the whole series as v3 for easier handling.*
---
* Changelog *
v2 -> v3:
* More specific subjects
* Try to use imperative instead of past tense
v1 -> v2:
* [Patch v2 1/3]: No changes.
* [Patch v2 2/3]: Make use of can_change_state() and relocate testing
alloc_can_err_skb() for NULL to the end of esd_usb_rx_event(), to
have things like can_bus_off(), can_change_state() working even in
out of memory conditions.
* [Patch v2 3/3]: No changes. I will 'declare esd_usb_msg as an union
instead of a struct' in a separate follow-up patch.
v1:
Link: https://lore.kernel.org/all/[email protected]/
Link: https://lore.kernel.org/all/[email protected]/
Frank Jungclaus (3):
can: esd_usb: Move mislocated storage of SJA1000_ECC_SEG bits in case
of a bus error
can: esd_usb: Make use of can_change_state() and relocate checking skb
for NULL
can: esd_usb: Improve readability on decoding ESD_EV_CAN_ERROR_EXT
messages
drivers/net/can/usb/esd_usb.c | 70 ++++++++++++++++++++---------------
1 file changed, 40 insertions(+), 30 deletions(-)
base-commit: fa1d915a624f72b153a9ff9700232056758a2b6c
--
2.25.1
Move the supply for cf->data[3] (bit stream position of CAN error), in
case of a bus- or protocol-error, outside of the "switch (ecc &
SJA1000_ECC_MASK){}"-statement, because this bit stream position is
independent of the error type.
Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device")
Signed-off-by: Frank Jungclaus <[email protected]>
---
drivers/net/can/usb/esd_usb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
index 42323f5e6f3a..5e182fadd875 100644
--- a/drivers/net/can/usb/esd_usb.c
+++ b/drivers/net/can/usb/esd_usb.c
@@ -286,7 +286,6 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
cf->data[2] |= CAN_ERR_PROT_STUFF;
break;
default:
- cf->data[3] = ecc & SJA1000_ECC_SEG;
break;
}
@@ -294,6 +293,9 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
if (!(ecc & SJA1000_ECC_DIR))
cf->data[2] |= CAN_ERR_PROT_TX;
+ /* Bit stream position in CAN frame as the error was detected */
+ cf->data[3] = ecc & SJA1000_ECC_SEG;
+
if (priv->can.state == CAN_STATE_ERROR_WARNING ||
priv->can.state == CAN_STATE_ERROR_PASSIVE) {
cf->data[1] = (txerr > rxerr) ?
--
2.25.1
On 16.02.2023 20:04:47, Frank Jungclaus wrote:
> Another small batch of patches to be seen as preparation for adding
> support of the newly available esd CAN-USB/3 to esd_usb.c.
>
> Due to some unresolved questions adding support for
> CAN_CTRLMODE_BERR_REPORTING has been postponed to one of the future
> patches.
>
> *Resend of the whole series as v3 for easier handling.*
Applied to linux-can-next/testing.
Thanks,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |