Skip to content

Commit

Permalink
pch_can: Fix incorrect return processing
Browse files Browse the repository at this point in the history
Fix incorrect return processing.

Signed-off-by: Tomoya MORINAGA <tomoya-linux@dsn.okisemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tomoya authored and David S. Miller committed Dec 13, 2010
1 parent a6f6d6b commit 3332bc5
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions drivers/net/can/pch_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,11 @@ static irqreturn_t pch_can_interrupt(int irq, void *dev_id)
struct net_device *ndev = (struct net_device *)dev_id;
struct pch_can_priv *priv = netdev_priv(ndev);

if (!pch_can_int_pending(priv))
return IRQ_NONE;

pch_can_set_int_enables(priv, PCH_CAN_NONE);
napi_schedule(&priv->napi);

return IRQ_HANDLED;
}

Expand Down Expand Up @@ -671,8 +673,10 @@ static int pch_can_rx_normal(struct net_device *ndev, u32 obj_num, int quota)
}

skb = alloc_can_skb(priv->ndev, &cf);
if (!skb)
return -ENOMEM;
if (!skb) {
netdev_err(ndev, "alloc_can_skb Failed\n");
return rcv_pkts;
}

/* Get Received data */
id2 = ioread32(&priv->regs->ifregs[0].id2);
Expand Down Expand Up @@ -733,8 +737,8 @@ static int pch_can_poll(struct napi_struct *napi, int quota)
struct net_device *ndev = napi->dev;
struct pch_can_priv *priv = netdev_priv(ndev);
u32 int_stat;
int rcv_pkts = 0;
u32 reg_stat;
int quota_save = quota;

int_stat = pch_can_int_pending(priv);
if (!int_stat)
Expand Down Expand Up @@ -763,10 +767,7 @@ static int pch_can_poll(struct napi_struct *napi, int quota)
goto end;

if ((int_stat >= PCH_RX_OBJ_START) && (int_stat <= PCH_RX_OBJ_END)) {
rcv_pkts += pch_can_rx_normal(ndev, int_stat, quota);
quota -= rcv_pkts;
if (quota < 0)
goto end;
quota -= pch_can_rx_normal(ndev, int_stat, quota);
} else if ((int_stat >= PCH_TX_OBJ_START) &&
(int_stat <= PCH_TX_OBJ_END)) {
/* Handle transmission interrupt */
Expand All @@ -777,7 +778,7 @@ static int pch_can_poll(struct napi_struct *napi, int quota)
napi_complete(napi);
pch_can_set_int_enables(priv, PCH_CAN_ALL);

return rcv_pkts;
return quota_save - quota;
}

static int pch_set_bittiming(struct net_device *ndev)
Expand Down

0 comments on commit 3332bc5

Please sign in to comment.