diff options
Diffstat (limited to 'drivers/net/can/at91_can.c')
-rw-r--r-- | drivers/net/can/at91_can.c | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c index f67ae285a35a..a2f29a38798a 100644 --- a/drivers/net/can/at91_can.c +++ b/drivers/net/can/at91_can.c | |||
@@ -221,38 +221,6 @@ static inline void set_mb_mode(const struct at91_priv *priv, unsigned int mb, | |||
221 | set_mb_mode_prio(priv, mb, mode, 0); | 221 | set_mb_mode_prio(priv, mb, mode, 0); |
222 | } | 222 | } |
223 | 223 | ||
224 | static struct sk_buff *alloc_can_skb(struct net_device *dev, | ||
225 | struct can_frame **cf) | ||
226 | { | ||
227 | struct sk_buff *skb; | ||
228 | |||
229 | skb = netdev_alloc_skb(dev, sizeof(struct can_frame)); | ||
230 | if (unlikely(!skb)) | ||
231 | return NULL; | ||
232 | |||
233 | skb->protocol = htons(ETH_P_CAN); | ||
234 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
235 | *cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame)); | ||
236 | |||
237 | return skb; | ||
238 | } | ||
239 | |||
240 | static struct sk_buff *alloc_can_err_skb(struct net_device *dev, | ||
241 | struct can_frame **cf) | ||
242 | { | ||
243 | struct sk_buff *skb; | ||
244 | |||
245 | skb = alloc_can_skb(dev, cf); | ||
246 | if (unlikely(!skb)) | ||
247 | return NULL; | ||
248 | |||
249 | memset(*cf, 0, sizeof(struct can_frame)); | ||
250 | (*cf)->can_id = CAN_ERR_FLAG; | ||
251 | (*cf)->can_dlc = CAN_ERR_DLC; | ||
252 | |||
253 | return skb; | ||
254 | } | ||
255 | |||
256 | /* | 224 | /* |
257 | * Swtich transceiver on or off | 225 | * Swtich transceiver on or off |
258 | */ | 226 | */ |
@@ -374,6 +342,9 @@ static netdev_tx_t at91_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
374 | unsigned int mb, prio; | 342 | unsigned int mb, prio; |
375 | u32 reg_mid, reg_mcr; | 343 | u32 reg_mid, reg_mcr; |
376 | 344 | ||
345 | if (can_dropped_invalid_skb(dev, skb)) | ||
346 | return NETDEV_TX_OK; | ||
347 | |||
377 | mb = get_tx_next_mb(priv); | 348 | mb = get_tx_next_mb(priv); |
378 | prio = get_tx_next_prio(priv); | 349 | prio = get_tx_next_prio(priv); |
379 | 350 | ||
@@ -506,7 +477,7 @@ static void at91_read_mb(struct net_device *dev, unsigned int mb, | |||
506 | reg_msr = at91_read(priv, AT91_MSR(mb)); | 477 | reg_msr = at91_read(priv, AT91_MSR(mb)); |
507 | if (reg_msr & AT91_MSR_MRTR) | 478 | if (reg_msr & AT91_MSR_MRTR) |
508 | cf->can_id |= CAN_RTR_FLAG; | 479 | cf->can_id |= CAN_RTR_FLAG; |
509 | cf->can_dlc = min_t(__u8, (reg_msr >> 16) & 0xf, 8); | 480 | cf->can_dlc = get_can_dlc((reg_msr >> 16) & 0xf); |
510 | 481 | ||
511 | *(u32 *)(cf->data + 0) = at91_read(priv, AT91_MDL(mb)); | 482 | *(u32 *)(cf->data + 0) = at91_read(priv, AT91_MDL(mb)); |
512 | *(u32 *)(cf->data + 4) = at91_read(priv, AT91_MDH(mb)); | 483 | *(u32 *)(cf->data + 4) = at91_read(priv, AT91_MDH(mb)); |
@@ -1069,7 +1040,7 @@ static int __init at91_can_probe(struct platform_device *pdev) | |||
1069 | 1040 | ||
1070 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1041 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1071 | irq = platform_get_irq(pdev, 0); | 1042 | irq = platform_get_irq(pdev, 0); |
1072 | if (!res || !irq) { | 1043 | if (!res || irq <= 0) { |
1073 | err = -ENODEV; | 1044 | err = -ENODEV; |
1074 | goto exit_put; | 1045 | goto exit_put; |
1075 | } | 1046 | } |
@@ -1087,7 +1058,7 @@ static int __init at91_can_probe(struct platform_device *pdev) | |||
1087 | goto exit_release; | 1058 | goto exit_release; |
1088 | } | 1059 | } |
1089 | 1060 | ||
1090 | dev = alloc_candev(sizeof(struct at91_priv)); | 1061 | dev = alloc_candev(sizeof(struct at91_priv), AT91_MB_TX_NUM); |
1091 | if (!dev) { | 1062 | if (!dev) { |
1092 | err = -ENOMEM; | 1063 | err = -ENOMEM; |
1093 | goto exit_iounmap; | 1064 | goto exit_iounmap; |
@@ -1102,6 +1073,7 @@ static int __init at91_can_probe(struct platform_device *pdev) | |||
1102 | priv->can.bittiming_const = &at91_bittiming_const; | 1073 | priv->can.bittiming_const = &at91_bittiming_const; |
1103 | priv->can.do_set_bittiming = at91_set_bittiming; | 1074 | priv->can.do_set_bittiming = at91_set_bittiming; |
1104 | priv->can.do_set_mode = at91_set_mode; | 1075 | priv->can.do_set_mode = at91_set_mode; |
1076 | priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; | ||
1105 | priv->reg_base = addr; | 1077 | priv->reg_base = addr; |
1106 | priv->dev = dev; | 1078 | priv->dev = dev; |
1107 | priv->clk = clk; | 1079 | priv->clk = clk; |