Skip to content

Commit

Permalink
mrf24j40: Move INIT_COMPLETION() to before packet transmission
Browse files Browse the repository at this point in the history
This avoids a race condition where complete(tx_complete) could be called
before tx_complete is initialized.

Signed-off-by: Alan Ott <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
signal11 authored and davem330 committed Oct 8, 2013
1 parent 8cc27d1 commit 9757f1d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ieee802154/mrf24j40.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ static int mrf24j40_tx(struct ieee802154_dev *dev, struct sk_buff *skb)
if (ret)
goto err;

INIT_COMPLETION(devrec->tx_complete);

/* Set TXNTRIG bit of TXNCON to send packet */
ret = read_short_reg(devrec, REG_TXNCON, &val);
if (ret)
Expand All @@ -354,8 +356,6 @@ static int mrf24j40_tx(struct ieee802154_dev *dev, struct sk_buff *skb)
val |= 0x4;
write_short_reg(devrec, REG_TXNCON, val);

INIT_COMPLETION(devrec->tx_complete);

/* Wait for the device to send the TX complete interrupt. */
ret = wait_for_completion_interruptible_timeout(
&devrec->tx_complete,
Expand Down

0 comments on commit 9757f1d

Please sign in to comment.