Commit ffd461f8 authored by Oliver Hartkopp's avatar Oliver Hartkopp Committed by Marc Kleine-Budde

can: fix assignment of error location in CAN error messages

As Dan Carpenter reported in http://marc.info/?l=linux-can&m=144793696016187
the assignment of the error location in CAN error messages had some bit wise
overlaps. Indeed the value to be assigned in data[3] is no bitfield but defines
a single value which points to a location inside the CAN frame on the wire.

This patch fixes the assignments for the error locations in error messages.
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 7cecd9ab
...@@ -975,8 +975,7 @@ static int c_can_handle_bus_err(struct net_device *dev, ...@@ -975,8 +975,7 @@ static int c_can_handle_bus_err(struct net_device *dev,
break; break;
case LEC_ACK_ERROR: case LEC_ACK_ERROR:
netdev_dbg(dev, "ack error\n"); netdev_dbg(dev, "ack error\n");
cf->data[3] |= (CAN_ERR_PROT_LOC_ACK | cf->data[3] = CAN_ERR_PROT_LOC_ACK;
CAN_ERR_PROT_LOC_ACK_DEL);
break; break;
case LEC_BIT1_ERROR: case LEC_BIT1_ERROR:
netdev_dbg(dev, "bit1 error\n"); netdev_dbg(dev, "bit1 error\n");
...@@ -988,8 +987,7 @@ static int c_can_handle_bus_err(struct net_device *dev, ...@@ -988,8 +987,7 @@ static int c_can_handle_bus_err(struct net_device *dev,
break; break;
case LEC_CRC_ERROR: case LEC_CRC_ERROR:
netdev_dbg(dev, "CRC error\n"); netdev_dbg(dev, "CRC error\n");
cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ | cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
CAN_ERR_PROT_LOC_CRC_DEL);
break; break;
default: default:
break; break;
......
...@@ -578,7 +578,7 @@ static int cc770_err(struct net_device *dev, u8 status) ...@@ -578,7 +578,7 @@ static int cc770_err(struct net_device *dev, u8 status)
cf->data[2] |= CAN_ERR_PROT_BIT0; cf->data[2] |= CAN_ERR_PROT_BIT0;
break; break;
case STAT_LEC_CRC: case STAT_LEC_CRC:
cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ; cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
break; break;
} }
} }
......
...@@ -535,13 +535,13 @@ static void do_bus_err(struct net_device *dev, ...@@ -535,13 +535,13 @@ static void do_bus_err(struct net_device *dev,
if (reg_esr & FLEXCAN_ESR_ACK_ERR) { if (reg_esr & FLEXCAN_ESR_ACK_ERR) {
netdev_dbg(dev, "ACK_ERR irq\n"); netdev_dbg(dev, "ACK_ERR irq\n");
cf->can_id |= CAN_ERR_ACK; cf->can_id |= CAN_ERR_ACK;
cf->data[3] |= CAN_ERR_PROT_LOC_ACK; cf->data[3] = CAN_ERR_PROT_LOC_ACK;
tx_errors = 1; tx_errors = 1;
} }
if (reg_esr & FLEXCAN_ESR_CRC_ERR) { if (reg_esr & FLEXCAN_ESR_CRC_ERR) {
netdev_dbg(dev, "CRC_ERR irq\n"); netdev_dbg(dev, "CRC_ERR irq\n");
cf->data[2] |= CAN_ERR_PROT_BIT; cf->data[2] |= CAN_ERR_PROT_BIT;
cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ; cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
rx_errors = 1; rx_errors = 1;
} }
if (reg_esr & FLEXCAN_ESR_FRM_ERR) { if (reg_esr & FLEXCAN_ESR_FRM_ERR) {
......
...@@ -500,8 +500,7 @@ static int m_can_handle_lec_err(struct net_device *dev, ...@@ -500,8 +500,7 @@ static int m_can_handle_lec_err(struct net_device *dev,
break; break;
case LEC_ACK_ERROR: case LEC_ACK_ERROR:
netdev_dbg(dev, "ack error\n"); netdev_dbg(dev, "ack error\n");
cf->data[3] |= (CAN_ERR_PROT_LOC_ACK | cf->data[3] = CAN_ERR_PROT_LOC_ACK;
CAN_ERR_PROT_LOC_ACK_DEL);
break; break;
case LEC_BIT1_ERROR: case LEC_BIT1_ERROR:
netdev_dbg(dev, "bit1 error\n"); netdev_dbg(dev, "bit1 error\n");
...@@ -513,8 +512,7 @@ static int m_can_handle_lec_err(struct net_device *dev, ...@@ -513,8 +512,7 @@ static int m_can_handle_lec_err(struct net_device *dev,
break; break;
case LEC_CRC_ERROR: case LEC_CRC_ERROR:
netdev_dbg(dev, "CRC error\n"); netdev_dbg(dev, "CRC error\n");
cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ | cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
CAN_ERR_PROT_LOC_CRC_DEL);
break; break;
default: default:
break; break;
......
...@@ -559,8 +559,7 @@ static void pch_can_error(struct net_device *ndev, u32 status) ...@@ -559,8 +559,7 @@ static void pch_can_error(struct net_device *ndev, u32 status)
stats->rx_errors++; stats->rx_errors++;
break; break;
case PCH_CRC_ERR: case PCH_CRC_ERR:
cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ | cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
CAN_ERR_PROT_LOC_CRC_DEL;
priv->can.can_stats.bus_error++; priv->can.can_stats.bus_error++;
stats->rx_errors++; stats->rx_errors++;
break; break;
......
...@@ -251,7 +251,7 @@ static void rcar_can_error(struct net_device *ndev) ...@@ -251,7 +251,7 @@ static void rcar_can_error(struct net_device *ndev)
tx_errors++; tx_errors++;
writeb(~RCAR_CAN_ECSR_ADEF, &priv->regs->ecsr); writeb(~RCAR_CAN_ECSR_ADEF, &priv->regs->ecsr);
if (skb) if (skb)
cf->data[3] |= CAN_ERR_PROT_LOC_ACK_DEL; cf->data[3] = CAN_ERR_PROT_LOC_ACK_DEL;
} }
if (ecsr & RCAR_CAN_ECSR_BE0F) { if (ecsr & RCAR_CAN_ECSR_BE0F) {
netdev_dbg(priv->ndev, "Bit Error (dominant)\n"); netdev_dbg(priv->ndev, "Bit Error (dominant)\n");
...@@ -272,7 +272,7 @@ static void rcar_can_error(struct net_device *ndev) ...@@ -272,7 +272,7 @@ static void rcar_can_error(struct net_device *ndev)
rx_errors++; rx_errors++;
writeb(~RCAR_CAN_ECSR_CEF, &priv->regs->ecsr); writeb(~RCAR_CAN_ECSR_CEF, &priv->regs->ecsr);
if (skb) if (skb)
cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ; cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
} }
if (ecsr & RCAR_CAN_ECSR_AEF) { if (ecsr & RCAR_CAN_ECSR_AEF) {
netdev_dbg(priv->ndev, "ACK Error\n"); netdev_dbg(priv->ndev, "ACK Error\n");
...@@ -280,7 +280,7 @@ static void rcar_can_error(struct net_device *ndev) ...@@ -280,7 +280,7 @@ static void rcar_can_error(struct net_device *ndev)
writeb(~RCAR_CAN_ECSR_AEF, &priv->regs->ecsr); writeb(~RCAR_CAN_ECSR_AEF, &priv->regs->ecsr);
if (skb) { if (skb) {
cf->can_id |= CAN_ERR_ACK; cf->can_id |= CAN_ERR_ACK;
cf->data[3] |= CAN_ERR_PROT_LOC_ACK; cf->data[3] = CAN_ERR_PROT_LOC_ACK;
} }
} }
if (ecsr & RCAR_CAN_ECSR_FEF) { if (ecsr & RCAR_CAN_ECSR_FEF) {
......
...@@ -737,13 +737,11 @@ static int ti_hecc_error(struct net_device *ndev, int int_status, ...@@ -737,13 +737,11 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
} }
if (err_status & HECC_CANES_CRCE) { if (err_status & HECC_CANES_CRCE) {
hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE); hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE);
cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ | cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
CAN_ERR_PROT_LOC_CRC_DEL;
} }
if (err_status & HECC_CANES_ACKE) { if (err_status & HECC_CANES_ACKE) {
hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE); hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE);
cf->data[3] |= CAN_ERR_PROT_LOC_ACK | cf->data[3] = CAN_ERR_PROT_LOC_ACK;
CAN_ERR_PROT_LOC_ACK_DEL;
} }
} }
......
...@@ -944,10 +944,9 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev, ...@@ -944,10 +944,9 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev,
cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT; cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT;
if (es->leaf.error_factor & M16C_EF_ACKE) if (es->leaf.error_factor & M16C_EF_ACKE)
cf->data[3] |= (CAN_ERR_PROT_LOC_ACK); cf->data[3] = CAN_ERR_PROT_LOC_ACK;
if (es->leaf.error_factor & M16C_EF_CRCE) if (es->leaf.error_factor & M16C_EF_CRCE)
cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ | cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
CAN_ERR_PROT_LOC_CRC_DEL);
if (es->leaf.error_factor & M16C_EF_FORME) if (es->leaf.error_factor & M16C_EF_FORME)
cf->data[2] |= CAN_ERR_PROT_FORM; cf->data[2] |= CAN_ERR_PROT_FORM;
if (es->leaf.error_factor & M16C_EF_STFE) if (es->leaf.error_factor & M16C_EF_STFE)
......
...@@ -402,8 +402,7 @@ static void usb_8dev_rx_err_msg(struct usb_8dev_priv *priv, ...@@ -402,8 +402,7 @@ static void usb_8dev_rx_err_msg(struct usb_8dev_priv *priv,
break; break;
case USB_8DEV_STATUSMSG_CRC: case USB_8DEV_STATUSMSG_CRC:
cf->data[2] |= CAN_ERR_PROT_UNSPEC; cf->data[2] |= CAN_ERR_PROT_UNSPEC;
cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ | cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
CAN_ERR_PROT_LOC_CRC_DEL;
rx_errors = 1; rx_errors = 1;
break; break;
case USB_8DEV_STATUSMSG_BIT0: case USB_8DEV_STATUSMSG_BIT0:
......
...@@ -618,7 +618,7 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr) ...@@ -618,7 +618,7 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr)
stats->tx_errors++; stats->tx_errors++;
if (skb) { if (skb) {
cf->can_id |= CAN_ERR_ACK; cf->can_id |= CAN_ERR_ACK;
cf->data[3] |= CAN_ERR_PROT_LOC_ACK; cf->data[3] = CAN_ERR_PROT_LOC_ACK;
} }
} }
...@@ -654,8 +654,7 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr) ...@@ -654,8 +654,7 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr)
stats->rx_errors++; stats->rx_errors++;
if (skb) { if (skb) {
cf->can_id |= CAN_ERR_PROT; cf->can_id |= CAN_ERR_PROT;
cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ | cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
CAN_ERR_PROT_LOC_CRC_DEL;
} }
} }
priv->can.can_stats.bus_error++; priv->can.can_stats.bus_error++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment