Skip to content

Commit

Permalink
Merge tag 'linux-can-fixes-for-3.19-20150127' of git://git.kernel.org…
Browse files Browse the repository at this point in the history
…/pub/scm/linux/kernel/git/mkl/linux-can

Marc Kleine-Budde says:

====================
pull-request: can 2015-01-27

this is another pull request for net/master which consists of 4 patches.

All 4 patches are contributed by Ahmed S. Darwish, he fixes more problems in
the kvaser_usb driver.

David, please merge net/master to net-next/master, as we have more kvaser_usb
patches in the queue, that target net-next.
====================

Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
davem330 committed Jan 27, 2015
2 parents fc752f1 + e638642 commit 8d8d67f
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions drivers/net/can/usb/kvaser_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ static int kvaser_usb_simple_msg_async(struct kvaser_usb_net_priv *priv,
usb_sndbulkpipe(dev->udev,
dev->bulk_out->bEndpointAddress),
buf, msg->len,
kvaser_usb_simple_msg_callback, priv);
kvaser_usb_simple_msg_callback, netdev);
usb_anchor_urb(urb, &priv->tx_submitted);

err = usb_submit_urb(urb, GFP_ATOMIC);
Expand Down Expand Up @@ -662,11 +662,6 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev,
priv = dev->nets[channel];
stats = &priv->netdev->stats;

if (status & M16C_STATE_BUS_RESET) {
kvaser_usb_unlink_tx_urbs(priv);
return;
}

skb = alloc_can_err_skb(priv->netdev, &cf);
if (!skb) {
stats->rx_dropped++;
Expand All @@ -677,7 +672,7 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev,

netdev_dbg(priv->netdev, "Error status: 0x%02x\n", status);

if (status & M16C_STATE_BUS_OFF) {
if (status & (M16C_STATE_BUS_OFF | M16C_STATE_BUS_RESET)) {
cf->can_id |= CAN_ERR_BUSOFF;

priv->can.can_stats.bus_off++;
Expand All @@ -703,9 +698,7 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev,
}

new_state = CAN_STATE_ERROR_PASSIVE;
}

if (status == M16C_STATE_BUS_ERROR) {
} else if (status & M16C_STATE_BUS_ERROR) {
if ((priv->can.state < CAN_STATE_ERROR_WARNING) &&
((txerr >= 96) || (rxerr >= 96))) {
cf->can_id |= CAN_ERR_CRTL;
Expand All @@ -715,7 +708,8 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev,

priv->can.can_stats.error_warning++;
new_state = CAN_STATE_ERROR_WARNING;
} else if (priv->can.state > CAN_STATE_ERROR_ACTIVE) {
} else if ((priv->can.state > CAN_STATE_ERROR_ACTIVE) &&
((txerr < 96) && (rxerr < 96))) {
cf->can_id |= CAN_ERR_PROT;
cf->data[2] = CAN_ERR_PROT_ACTIVE;

Expand Down Expand Up @@ -1590,7 +1584,7 @@ static int kvaser_usb_probe(struct usb_interface *intf,
{
struct kvaser_usb *dev;
int err = -ENOMEM;
int i;
int i, retry = 3;

dev = devm_kzalloc(&intf->dev, sizeof(*dev), GFP_KERNEL);
if (!dev)
Expand All @@ -1608,7 +1602,15 @@ static int kvaser_usb_probe(struct usb_interface *intf,

usb_set_intfdata(intf, dev);

err = kvaser_usb_get_software_info(dev);
/* On some x86 laptops, plugging a Kvaser device again after
* an unplug makes the firmware always ignore the very first
* command. For such a case, provide some room for retries
* instead of completely exiting the driver.
*/
do {
err = kvaser_usb_get_software_info(dev);
} while (--retry && err == -ETIMEDOUT);

if (err) {
dev_err(&intf->dev,
"Cannot get software infos, error %d\n", err);
Expand Down

0 comments on commit 8d8d67f

Please sign in to comment.