Commit f6aa90a7 authored by David S. Miller's avatar David S. Miller

Merge tag 'linux-can-next-for-6.3-20230217' of...

Merge tag 'linux-can-next-for-6.3-20230217' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next
Marc Kleine-Budde says:

====================
pull-request: can-next 2023-02-17 - fixed

this is a pull request of 4 patches for net-next/master.

The first patch is by Yang Li and converts the ctucanfd driver to
devm_platform_ioremap_resource().

The last 3 patches are by Frank Jungclaus, target the esd_usb driver
and contains preparations for the upcoming support of the esd
CAN-USB/3 hardware.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4d3e050b 6ad17274
...@@ -47,7 +47,6 @@ static void ctucan_platform_set_drvdata(struct device *dev, ...@@ -47,7 +47,6 @@ static void ctucan_platform_set_drvdata(struct device *dev,
*/ */
static int ctucan_platform_probe(struct platform_device *pdev) static int ctucan_platform_probe(struct platform_device *pdev)
{ {
struct resource *res; /* IO mem resources */
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
void __iomem *addr; void __iomem *addr;
int ret; int ret;
...@@ -55,8 +54,7 @@ static int ctucan_platform_probe(struct platform_device *pdev) ...@@ -55,8 +54,7 @@ static int ctucan_platform_probe(struct platform_device *pdev)
int irq; int irq;
/* Get the virtual base address for the device */ /* Get the virtual base address for the device */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); addr = devm_platform_ioremap_resource(pdev, 0);
addr = devm_ioremap_resource(dev, res);
if (IS_ERR(addr)) { if (IS_ERR(addr)) {
ret = PTR_ERR(addr); ret = PTR_ERR(addr);
goto err; goto err;
......
...@@ -127,7 +127,15 @@ struct rx_msg { ...@@ -127,7 +127,15 @@ struct rx_msg {
u8 dlc; u8 dlc;
__le32 ts; __le32 ts;
__le32 id; /* upper 3 bits contain flags */ __le32 id; /* upper 3 bits contain flags */
u8 data[8]; union {
u8 data[8];
struct {
u8 status; /* CAN Controller Status */
u8 ecc; /* Error Capture Register */
u8 rec; /* RX Error Counter */
u8 tec; /* TX Error Counter */
} ev_can_err_ext; /* For ESD_EV_CAN_ERROR_EXT */
};
}; };
struct tx_msg { struct tx_msg {
...@@ -229,51 +237,52 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, ...@@ -229,51 +237,52 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
u32 id = le32_to_cpu(msg->msg.rx.id) & ESD_IDMASK; u32 id = le32_to_cpu(msg->msg.rx.id) & ESD_IDMASK;
if (id == ESD_EV_CAN_ERROR_EXT) { if (id == ESD_EV_CAN_ERROR_EXT) {
u8 state = msg->msg.rx.data[0]; u8 state = msg->msg.rx.ev_can_err_ext.status;
u8 ecc = msg->msg.rx.data[1]; u8 ecc = msg->msg.rx.ev_can_err_ext.ecc;
u8 rxerr = msg->msg.rx.data[2]; u8 rxerr = msg->msg.rx.ev_can_err_ext.rec;
u8 txerr = msg->msg.rx.data[3]; u8 txerr = msg->msg.rx.ev_can_err_ext.tec;
netdev_dbg(priv->netdev, netdev_dbg(priv->netdev,
"CAN_ERR_EV_EXT: dlc=%#02x state=%02x ecc=%02x rec=%02x tec=%02x\n", "CAN_ERR_EV_EXT: dlc=%#02x state=%02x ecc=%02x rec=%02x tec=%02x\n",
msg->msg.rx.dlc, state, ecc, rxerr, txerr); msg->msg.rx.dlc, state, ecc, rxerr, txerr);
skb = alloc_can_err_skb(priv->netdev, &cf); skb = alloc_can_err_skb(priv->netdev, &cf);
if (skb == NULL) {
stats->rx_dropped++;
return;
}
if (state != priv->old_state) { if (state != priv->old_state) {
enum can_state tx_state, rx_state;
enum can_state new_state = CAN_STATE_ERROR_ACTIVE;
priv->old_state = state; priv->old_state = state;
switch (state & ESD_BUSSTATE_MASK) { switch (state & ESD_BUSSTATE_MASK) {
case ESD_BUSSTATE_BUSOFF: case ESD_BUSSTATE_BUSOFF:
priv->can.state = CAN_STATE_BUS_OFF; new_state = CAN_STATE_BUS_OFF;
cf->can_id |= CAN_ERR_BUSOFF;
priv->can.can_stats.bus_off++;
can_bus_off(priv->netdev); can_bus_off(priv->netdev);
break; break;
case ESD_BUSSTATE_WARN: case ESD_BUSSTATE_WARN:
priv->can.state = CAN_STATE_ERROR_WARNING; new_state = CAN_STATE_ERROR_WARNING;
priv->can.can_stats.error_warning++;
break; break;
case ESD_BUSSTATE_ERRPASSIVE: case ESD_BUSSTATE_ERRPASSIVE:
priv->can.state = CAN_STATE_ERROR_PASSIVE; new_state = CAN_STATE_ERROR_PASSIVE;
priv->can.can_stats.error_passive++;
break; break;
default: default:
priv->can.state = CAN_STATE_ERROR_ACTIVE; new_state = CAN_STATE_ERROR_ACTIVE;
txerr = 0; txerr = 0;
rxerr = 0; rxerr = 0;
break; break;
} }
} else {
if (new_state != priv->can.state) {
tx_state = (txerr >= rxerr) ? new_state : 0;
rx_state = (txerr <= rxerr) ? new_state : 0;
can_change_state(priv->netdev, cf,
tx_state, rx_state);
}
} else if (skb) {
priv->can.can_stats.bus_error++; priv->can.can_stats.bus_error++;
stats->rx_errors++; stats->rx_errors++;
cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR | cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
CAN_ERR_CNT;
switch (ecc & SJA1000_ECC_MASK) { switch (ecc & SJA1000_ECC_MASK) {
case SJA1000_ECC_BIT: case SJA1000_ECC_BIT:
...@@ -286,7 +295,6 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, ...@@ -286,7 +295,6 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
cf->data[2] |= CAN_ERR_PROT_STUFF; cf->data[2] |= CAN_ERR_PROT_STUFF;
break; break;
default: default:
cf->data[3] = ecc & SJA1000_ECC_SEG;
break; break;
} }
...@@ -294,20 +302,22 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv, ...@@ -294,20 +302,22 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
if (!(ecc & SJA1000_ECC_DIR)) if (!(ecc & SJA1000_ECC_DIR))
cf->data[2] |= CAN_ERR_PROT_TX; cf->data[2] |= CAN_ERR_PROT_TX;
if (priv->can.state == CAN_STATE_ERROR_WARNING || /* Bit stream position in CAN frame as the error was detected */
priv->can.state == CAN_STATE_ERROR_PASSIVE) { cf->data[3] = ecc & SJA1000_ECC_SEG;
cf->data[1] = (txerr > rxerr) ?
CAN_ERR_CRTL_TX_PASSIVE :
CAN_ERR_CRTL_RX_PASSIVE;
}
cf->data[6] = txerr;
cf->data[7] = rxerr;
} }
priv->bec.txerr = txerr; priv->bec.txerr = txerr;
priv->bec.rxerr = rxerr; priv->bec.rxerr = rxerr;
netif_rx(skb); if (skb) {
cf->can_id |= CAN_ERR_CNT;
cf->data[6] = txerr;
cf->data[7] = rxerr;
netif_rx(skb);
} else {
stats->rx_dropped++;
}
} }
} }
......
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