diff options
Diffstat (limited to 'drivers/net/can/sja1000')
-rw-r--r-- | drivers/net/can/sja1000/sja1000.c | 19 | ||||
-rw-r--r-- | drivers/net/can/sja1000/sja1000.h | 2 |
2 files changed, 7 insertions, 14 deletions
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c index 16d2ecd2a3b7..b4ba88a31075 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c | |||
@@ -296,11 +296,9 @@ static void sja1000_rx(struct net_device *dev) | |||
296 | uint8_t dlc; | 296 | uint8_t dlc; |
297 | int i; | 297 | int i; |
298 | 298 | ||
299 | skb = dev_alloc_skb(sizeof(struct can_frame)); | 299 | skb = alloc_can_skb(dev, &cf); |
300 | if (skb == NULL) | 300 | if (skb == NULL) |
301 | return; | 301 | return; |
302 | skb->dev = dev; | ||
303 | skb->protocol = htons(ETH_P_CAN); | ||
304 | 302 | ||
305 | fi = priv->read_reg(priv, REG_FI); | 303 | fi = priv->read_reg(priv, REG_FI); |
306 | dlc = fi & 0x0F; | 304 | dlc = fi & 0x0F; |
@@ -323,8 +321,6 @@ static void sja1000_rx(struct net_device *dev) | |||
323 | if (fi & FI_RTR) | 321 | if (fi & FI_RTR) |
324 | id |= CAN_RTR_FLAG; | 322 | id |= CAN_RTR_FLAG; |
325 | 323 | ||
326 | cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame)); | ||
327 | memset(cf, 0, sizeof(struct can_frame)); | ||
328 | cf->can_id = id; | 324 | cf->can_id = id; |
329 | cf->can_dlc = dlc; | 325 | cf->can_dlc = dlc; |
330 | for (i = 0; i < dlc; i++) | 326 | for (i = 0; i < dlc; i++) |
@@ -351,15 +347,9 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) | |||
351 | enum can_state state = priv->can.state; | 347 | enum can_state state = priv->can.state; |
352 | uint8_t ecc, alc; | 348 | uint8_t ecc, alc; |
353 | 349 | ||
354 | skb = dev_alloc_skb(sizeof(struct can_frame)); | 350 | skb = alloc_can_err_skb(dev, &cf); |
355 | if (skb == NULL) | 351 | if (skb == NULL) |
356 | return -ENOMEM; | 352 | return -ENOMEM; |
357 | skb->dev = dev; | ||
358 | skb->protocol = htons(ETH_P_CAN); | ||
359 | cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame)); | ||
360 | memset(cf, 0, sizeof(struct can_frame)); | ||
361 | cf->can_id = CAN_ERR_FLAG; | ||
362 | cf->can_dlc = CAN_ERR_DLC; | ||
363 | 353 | ||
364 | if (isrc & IRQ_DOI) { | 354 | if (isrc & IRQ_DOI) { |
365 | /* data overrun interrupt */ | 355 | /* data overrun interrupt */ |
@@ -526,7 +516,7 @@ static int sja1000_open(struct net_device *dev) | |||
526 | 516 | ||
527 | /* register interrupt handler, if not done by the device driver */ | 517 | /* register interrupt handler, if not done by the device driver */ |
528 | if (!(priv->flags & SJA1000_CUSTOM_IRQ_HANDLER)) { | 518 | if (!(priv->flags & SJA1000_CUSTOM_IRQ_HANDLER)) { |
529 | err = request_irq(dev->irq, &sja1000_interrupt, priv->irq_flags, | 519 | err = request_irq(dev->irq, sja1000_interrupt, priv->irq_flags, |
530 | dev->name, (void *)dev); | 520 | dev->name, (void *)dev); |
531 | if (err) { | 521 | if (err) { |
532 | close_candev(dev); | 522 | close_candev(dev); |
@@ -565,7 +555,8 @@ struct net_device *alloc_sja1000dev(int sizeof_priv) | |||
565 | struct net_device *dev; | 555 | struct net_device *dev; |
566 | struct sja1000_priv *priv; | 556 | struct sja1000_priv *priv; |
567 | 557 | ||
568 | dev = alloc_candev(sizeof(struct sja1000_priv) + sizeof_priv); | 558 | dev = alloc_candev(sizeof(struct sja1000_priv) + sizeof_priv, |
559 | SJA1000_ECHO_SKB_MAX); | ||
569 | if (!dev) | 560 | if (!dev) |
570 | return NULL; | 561 | return NULL; |
571 | 562 | ||
diff --git a/drivers/net/can/sja1000/sja1000.h b/drivers/net/can/sja1000/sja1000.h index 302d2c763ad7..97a622b9302f 100644 --- a/drivers/net/can/sja1000/sja1000.h +++ b/drivers/net/can/sja1000/sja1000.h | |||
@@ -50,6 +50,8 @@ | |||
50 | #include <linux/can/dev.h> | 50 | #include <linux/can/dev.h> |
51 | #include <linux/can/platform/sja1000.h> | 51 | #include <linux/can/platform/sja1000.h> |
52 | 52 | ||
53 | #define SJA1000_ECHO_SKB_MAX 1 /* the SJA1000 has one TX buffer object */ | ||
54 | |||
53 | #define SJA1000_MAX_IRQ 20 /* max. number of interrupts handled in ISR */ | 55 | #define SJA1000_MAX_IRQ 20 /* max. number of interrupts handled in ISR */ |
54 | 56 | ||
55 | /* SJA1000 registers - manual section 6.4 (Pelican Mode) */ | 57 | /* SJA1000 registers - manual section 6.4 (Pelican Mode) */ |