diff options
Diffstat (limited to 'drivers/net/can/c_can')
-rw-r--r-- | drivers/net/can/c_can/c_can.c | 20 | ||||
-rw-r--r-- | drivers/net/can/c_can/c_can.h | 1 |
2 files changed, 12 insertions, 9 deletions
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c index 536bda072a16..86cd532c78f9 100644 --- a/drivers/net/can/c_can/c_can.c +++ b/drivers/net/can/c_can/c_can.c | |||
@@ -590,8 +590,8 @@ static void c_can_chip_config(struct net_device *dev) | |||
590 | priv->write_reg(priv, &priv->regs->control, | 590 | priv->write_reg(priv, &priv->regs->control, |
591 | CONTROL_ENABLE_AR); | 591 | CONTROL_ENABLE_AR); |
592 | 592 | ||
593 | if (priv->can.ctrlmode & (CAN_CTRLMODE_LISTENONLY & | 593 | if ((priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) && |
594 | CAN_CTRLMODE_LOOPBACK)) { | 594 | (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)) { |
595 | /* loopback + silent mode : useful for hot self-test */ | 595 | /* loopback + silent mode : useful for hot self-test */ |
596 | priv->write_reg(priv, &priv->regs->control, CONTROL_EIE | | 596 | priv->write_reg(priv, &priv->regs->control, CONTROL_EIE | |
597 | CONTROL_SIE | CONTROL_IE | CONTROL_TEST); | 597 | CONTROL_SIE | CONTROL_IE | CONTROL_TEST); |
@@ -686,7 +686,7 @@ static int c_can_get_berr_counter(const struct net_device *dev, | |||
686 | * | 686 | * |
687 | * We iterate from priv->tx_echo to priv->tx_next and check if the | 687 | * We iterate from priv->tx_echo to priv->tx_next and check if the |
688 | * packet has been transmitted, echo it back to the CAN framework. | 688 | * packet has been transmitted, echo it back to the CAN framework. |
689 | * If we discover a not yet transmitted package, stop looking for more. | 689 | * If we discover a not yet transmitted packet, stop looking for more. |
690 | */ | 690 | */ |
691 | static void c_can_do_tx(struct net_device *dev) | 691 | static void c_can_do_tx(struct net_device *dev) |
692 | { | 692 | { |
@@ -698,7 +698,7 @@ static void c_can_do_tx(struct net_device *dev) | |||
698 | for (/* nix */; (priv->tx_next - priv->tx_echo) > 0; priv->tx_echo++) { | 698 | for (/* nix */; (priv->tx_next - priv->tx_echo) > 0; priv->tx_echo++) { |
699 | msg_obj_no = get_tx_echo_msg_obj(priv); | 699 | msg_obj_no = get_tx_echo_msg_obj(priv); |
700 | val = c_can_read_reg32(priv, &priv->regs->txrqst1); | 700 | val = c_can_read_reg32(priv, &priv->regs->txrqst1); |
701 | if (!(val & (1 << msg_obj_no))) { | 701 | if (!(val & (1 << (msg_obj_no - 1)))) { |
702 | can_get_echo_skb(dev, | 702 | can_get_echo_skb(dev, |
703 | msg_obj_no - C_CAN_MSG_OBJ_TX_FIRST); | 703 | msg_obj_no - C_CAN_MSG_OBJ_TX_FIRST); |
704 | stats->tx_bytes += priv->read_reg(priv, | 704 | stats->tx_bytes += priv->read_reg(priv, |
@@ -706,6 +706,8 @@ static void c_can_do_tx(struct net_device *dev) | |||
706 | & IF_MCONT_DLC_MASK; | 706 | & IF_MCONT_DLC_MASK; |
707 | stats->tx_packets++; | 707 | stats->tx_packets++; |
708 | c_can_inval_msg_object(dev, 0, msg_obj_no); | 708 | c_can_inval_msg_object(dev, 0, msg_obj_no); |
709 | } else { | ||
710 | break; | ||
709 | } | 711 | } |
710 | } | 712 | } |
711 | 713 | ||
@@ -950,7 +952,7 @@ static int c_can_poll(struct napi_struct *napi, int quota) | |||
950 | struct net_device *dev = napi->dev; | 952 | struct net_device *dev = napi->dev; |
951 | struct c_can_priv *priv = netdev_priv(dev); | 953 | struct c_can_priv *priv = netdev_priv(dev); |
952 | 954 | ||
953 | irqstatus = priv->read_reg(priv, &priv->regs->interrupt); | 955 | irqstatus = priv->irqstatus; |
954 | if (!irqstatus) | 956 | if (!irqstatus) |
955 | goto end; | 957 | goto end; |
956 | 958 | ||
@@ -1028,12 +1030,11 @@ end: | |||
1028 | 1030 | ||
1029 | static irqreturn_t c_can_isr(int irq, void *dev_id) | 1031 | static irqreturn_t c_can_isr(int irq, void *dev_id) |
1030 | { | 1032 | { |
1031 | u16 irqstatus; | ||
1032 | struct net_device *dev = (struct net_device *)dev_id; | 1033 | struct net_device *dev = (struct net_device *)dev_id; |
1033 | struct c_can_priv *priv = netdev_priv(dev); | 1034 | struct c_can_priv *priv = netdev_priv(dev); |
1034 | 1035 | ||
1035 | irqstatus = priv->read_reg(priv, &priv->regs->interrupt); | 1036 | priv->irqstatus = priv->read_reg(priv, &priv->regs->interrupt); |
1036 | if (!irqstatus) | 1037 | if (!priv->irqstatus) |
1037 | return IRQ_NONE; | 1038 | return IRQ_NONE; |
1038 | 1039 | ||
1039 | /* disable all interrupts and schedule the NAPI */ | 1040 | /* disable all interrupts and schedule the NAPI */ |
@@ -1063,10 +1064,11 @@ static int c_can_open(struct net_device *dev) | |||
1063 | goto exit_irq_fail; | 1064 | goto exit_irq_fail; |
1064 | } | 1065 | } |
1065 | 1066 | ||
1067 | napi_enable(&priv->napi); | ||
1068 | |||
1066 | /* start the c_can controller */ | 1069 | /* start the c_can controller */ |
1067 | c_can_start(dev); | 1070 | c_can_start(dev); |
1068 | 1071 | ||
1069 | napi_enable(&priv->napi); | ||
1070 | netif_start_queue(dev); | 1072 | netif_start_queue(dev); |
1071 | 1073 | ||
1072 | return 0; | 1074 | return 0; |
diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h index 9b7fbef3d09a..5f32d34af507 100644 --- a/drivers/net/can/c_can/c_can.h +++ b/drivers/net/can/c_can/c_can.h | |||
@@ -76,6 +76,7 @@ struct c_can_priv { | |||
76 | unsigned int tx_next; | 76 | unsigned int tx_next; |
77 | unsigned int tx_echo; | 77 | unsigned int tx_echo; |
78 | void *priv; /* for board-specific data */ | 78 | void *priv; /* for board-specific data */ |
79 | u16 irqstatus; | ||
79 | }; | 80 | }; |
80 | 81 | ||
81 | struct net_device *alloc_c_can_dev(void); | 82 | struct net_device *alloc_c_can_dev(void); |