diff options
author | alex.bluesman.smirnov@gmail.com <alex.bluesman.smirnov@gmail.com> | 2012-07-10 17:22:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-12 10:54:45 -0400 |
commit | 5b00f2eef3a3b085f702675e8158b8eaf0fb663d (patch) | |
tree | 8a6d94da7727f29d081e9541be59e859183a1c0a /drivers/ieee802154/at86rf230.c | |
parent | 4d27de149ba17eb7643b6665ad3513d00d65b6c2 (diff) |
drivers/ieee802154/at86rf230: rework irq handler
Fix LOCKDEP bug message for the irq handler spinlock.
Make the irq processing code more explicit and stable.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/ieee802154/at86rf230.c')
-rw-r--r-- | drivers/ieee802154/at86rf230.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/drivers/ieee802154/at86rf230.c b/drivers/ieee802154/at86rf230.c index 902e38bb382f..5d309408395d 100644 --- a/drivers/ieee802154/at86rf230.c +++ b/drivers/ieee802154/at86rf230.c | |||
@@ -543,6 +543,13 @@ at86rf230_xmit(struct ieee802154_dev *dev, struct sk_buff *skb) | |||
543 | int rc; | 543 | int rc; |
544 | unsigned long flags; | 544 | unsigned long flags; |
545 | 545 | ||
546 | spin_lock(&lp->lock); | ||
547 | if (lp->irq_disabled) { | ||
548 | spin_unlock(&lp->lock); | ||
549 | return -EBUSY; | ||
550 | } | ||
551 | spin_unlock(&lp->lock); | ||
552 | |||
546 | might_sleep(); | 553 | might_sleep(); |
547 | 554 | ||
548 | rc = at86rf230_state(dev, STATE_FORCE_TX_ON); | 555 | rc = at86rf230_state(dev, STATE_FORCE_TX_ON); |
@@ -592,12 +599,8 @@ static int at86rf230_rx(struct at86rf230_local *lp) | |||
592 | if (!skb) | 599 | if (!skb) |
593 | return -ENOMEM; | 600 | return -ENOMEM; |
594 | 601 | ||
595 | if (at86rf230_write_subreg(lp, SR_RX_PDT_DIS, 1) || | 602 | if (at86rf230_read_fbuf(lp, skb_put(skb, len), &len, &lqi)) |
596 | at86rf230_read_fbuf(lp, skb_put(skb, len), &len, &lqi) || | ||
597 | at86rf230_write_subreg(lp, SR_RX_SAFE_MODE, 1) || | ||
598 | at86rf230_write_subreg(lp, SR_RX_PDT_DIS, 0)) { | ||
599 | goto err; | 603 | goto err; |
600 | } | ||
601 | 604 | ||
602 | if (len < 2) | 605 | if (len < 2) |
603 | goto err; | 606 | goto err; |
@@ -633,7 +636,6 @@ static void at86rf230_irqwork(struct work_struct *work) | |||
633 | int rc; | 636 | int rc; |
634 | unsigned long flags; | 637 | unsigned long flags; |
635 | 638 | ||
636 | spin_lock_irqsave(&lp->lock, flags); | ||
637 | rc = at86rf230_read_subreg(lp, RG_IRQ_STATUS, 0xff, 0, &val); | 639 | rc = at86rf230_read_subreg(lp, RG_IRQ_STATUS, 0xff, 0, &val); |
638 | status |= val; | 640 | status |= val; |
639 | 641 | ||
@@ -643,31 +645,33 @@ static void at86rf230_irqwork(struct work_struct *work) | |||
643 | status &= ~IRQ_TRX_UR; /* FIXME: possibly handle ???*/ | 645 | status &= ~IRQ_TRX_UR; /* FIXME: possibly handle ???*/ |
644 | 646 | ||
645 | if (status & IRQ_TRX_END) { | 647 | if (status & IRQ_TRX_END) { |
648 | spin_lock_irqsave(&lp->lock, flags); | ||
646 | status &= ~IRQ_TRX_END; | 649 | status &= ~IRQ_TRX_END; |
647 | if (lp->is_tx) { | 650 | if (lp->is_tx) { |
648 | lp->is_tx = 0; | 651 | lp->is_tx = 0; |
652 | spin_unlock_irqrestore(&lp->lock, flags); | ||
649 | complete(&lp->tx_complete); | 653 | complete(&lp->tx_complete); |
650 | } else { | 654 | } else { |
655 | spin_unlock_irqrestore(&lp->lock, flags); | ||
651 | at86rf230_rx(lp); | 656 | at86rf230_rx(lp); |
652 | } | 657 | } |
653 | } | 658 | } |
654 | 659 | ||
655 | if (lp->irq_disabled) { | 660 | spin_lock_irqsave(&lp->lock, flags); |
656 | lp->irq_disabled = 0; | 661 | lp->irq_disabled = 0; |
657 | enable_irq(lp->spi->irq); | ||
658 | } | ||
659 | spin_unlock_irqrestore(&lp->lock, flags); | 662 | spin_unlock_irqrestore(&lp->lock, flags); |
663 | |||
664 | enable_irq(lp->spi->irq); | ||
660 | } | 665 | } |
661 | 666 | ||
662 | static irqreturn_t at86rf230_isr(int irq, void *data) | 667 | static irqreturn_t at86rf230_isr(int irq, void *data) |
663 | { | 668 | { |
664 | struct at86rf230_local *lp = data; | 669 | struct at86rf230_local *lp = data; |
665 | 670 | ||
671 | disable_irq_nosync(irq); | ||
672 | |||
666 | spin_lock(&lp->lock); | 673 | spin_lock(&lp->lock); |
667 | if (!lp->irq_disabled) { | 674 | lp->irq_disabled = 1; |
668 | disable_irq_nosync(irq); | ||
669 | lp->irq_disabled = 1; | ||
670 | } | ||
671 | spin_unlock(&lp->lock); | 675 | spin_unlock(&lp->lock); |
672 | 676 | ||
673 | schedule_work(&lp->irqwork); | 677 | schedule_work(&lp->irqwork); |