diff options
author | Michael Buesch <mb@bu3sch.de> | 2006-06-27 15:38:40 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2006-07-10 14:19:41 -0400 |
commit | efa6a370216f1816456b49aac03295071720f7eb (patch) | |
tree | a29c205e603d96ad3b4ef34b274335a851672aac /drivers/net/wireless/bcm43xx/bcm43xx.h | |
parent | b312d799b324e895745ffe148def234fc60d5b74 (diff) |
[PATCH] bcm43xx: opencoded locking
As many people don't seem to like the locking "obfuscation"
in the bcm43xx driver, this patch removes it.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/bcm43xx/bcm43xx.h')
-rw-r--r-- | drivers/net/wireless/bcm43xx/bcm43xx.h | 64 |
1 files changed, 14 insertions, 50 deletions
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h index 17a56828e232..ee6571ed706d 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx.h +++ b/drivers/net/wireless/bcm43xx/bcm43xx.h | |||
@@ -649,6 +649,19 @@ enum { | |||
649 | #define bcm43xx_status(bcm) atomic_read(&(bcm)->init_status) | 649 | #define bcm43xx_status(bcm) atomic_read(&(bcm)->init_status) |
650 | #define bcm43xx_set_status(bcm, stat) atomic_set(&(bcm)->init_status, (stat)) | 650 | #define bcm43xx_set_status(bcm, stat) atomic_set(&(bcm)->init_status, (stat)) |
651 | 651 | ||
652 | /* *** THEORY OF LOCKING *** | ||
653 | * | ||
654 | * We have two different locks in the bcm43xx driver. | ||
655 | * => bcm->mutex: General sleeping mutex. Protects struct bcm43xx_private | ||
656 | * and the device registers. This mutex does _not_ protect | ||
657 | * against concurrency from the IRQ handler. | ||
658 | * => bcm->irq_lock: IRQ spinlock. Protects against IRQ handler concurrency. | ||
659 | * | ||
660 | * Please note that, if you only take the irq_lock, you are not protected | ||
661 | * against concurrency from the periodic work handlers. | ||
662 | * Most times you want to take _both_ locks. | ||
663 | */ | ||
664 | |||
652 | struct bcm43xx_private { | 665 | struct bcm43xx_private { |
653 | struct ieee80211_device *ieee; | 666 | struct ieee80211_device *ieee; |
654 | struct ieee80211softmac_device *softmac; | 667 | struct ieee80211softmac_device *softmac; |
@@ -659,7 +672,6 @@ struct bcm43xx_private { | |||
659 | 672 | ||
660 | void __iomem *mmio_addr; | 673 | void __iomem *mmio_addr; |
661 | 674 | ||
662 | /* Locking, see "theory of locking" text below. */ | ||
663 | spinlock_t irq_lock; | 675 | spinlock_t irq_lock; |
664 | struct mutex mutex; | 676 | struct mutex mutex; |
665 | 677 | ||
@@ -691,6 +703,7 @@ struct bcm43xx_private { | |||
691 | struct bcm43xx_sprominfo sprom; | 703 | struct bcm43xx_sprominfo sprom; |
692 | #define BCM43xx_NR_LEDS 4 | 704 | #define BCM43xx_NR_LEDS 4 |
693 | struct bcm43xx_led leds[BCM43xx_NR_LEDS]; | 705 | struct bcm43xx_led leds[BCM43xx_NR_LEDS]; |
706 | spinlock_t leds_lock; | ||
694 | 707 | ||
695 | /* The currently active core. */ | 708 | /* The currently active core. */ |
696 | struct bcm43xx_coreinfo *current_core; | 709 | struct bcm43xx_coreinfo *current_core; |
@@ -763,55 +776,6 @@ struct bcm43xx_private { | |||
763 | }; | 776 | }; |
764 | 777 | ||
765 | 778 | ||
766 | /* *** THEORY OF LOCKING *** | ||
767 | * | ||
768 | * We have two different locks in the bcm43xx driver. | ||
769 | * => bcm->mutex: General sleeping mutex. Protects struct bcm43xx_private | ||
770 | * and the device registers. | ||
771 | * => bcm->irq_lock: IRQ spinlock. Protects against IRQ handler concurrency. | ||
772 | * | ||
773 | * We have three types of helper function pairs to utilize these locks. | ||
774 | * (Always use the helper functions.) | ||
775 | * 1) bcm43xx_{un}lock_noirq(): | ||
776 | * Takes bcm->mutex. Does _not_ protect against IRQ concurrency, | ||
777 | * so it is almost always unsafe, if device IRQs are enabled. | ||
778 | * So only use this, if device IRQs are masked. | ||
779 | * Locking may sleep. | ||
780 | * You can sleep within the critical section. | ||
781 | * 2) bcm43xx_{un}lock_irqonly(): | ||
782 | * Takes bcm->irq_lock. Does _not_ protect against | ||
783 | * bcm43xx_lock_noirq() critical sections. | ||
784 | * Does only protect against the IRQ handler path and other | ||
785 | * irqonly() critical sections. | ||
786 | * Locking does not sleep. | ||
787 | * You must not sleep within the critical section. | ||
788 | * 3) bcm43xx_{un}lock_irqsafe(): | ||
789 | * This is the cummulative lock and takes both, mutex and irq_lock. | ||
790 | * Protects against noirq() and irqonly() critical sections (and | ||
791 | * the IRQ handler path). | ||
792 | * Locking may sleep. | ||
793 | * You must not sleep within the critical section. | ||
794 | */ | ||
795 | |||
796 | /* Lock type 1 */ | ||
797 | #define bcm43xx_lock_noirq(bcm) mutex_lock(&(bcm)->mutex) | ||
798 | #define bcm43xx_unlock_noirq(bcm) mutex_unlock(&(bcm)->mutex) | ||
799 | /* Lock type 2 */ | ||
800 | #define bcm43xx_lock_irqonly(bcm, flags) \ | ||
801 | spin_lock_irqsave(&(bcm)->irq_lock, flags) | ||
802 | #define bcm43xx_unlock_irqonly(bcm, flags) \ | ||
803 | spin_unlock_irqrestore(&(bcm)->irq_lock, flags) | ||
804 | /* Lock type 3 */ | ||
805 | #define bcm43xx_lock_irqsafe(bcm, flags) do { \ | ||
806 | bcm43xx_lock_noirq(bcm); \ | ||
807 | bcm43xx_lock_irqonly(bcm, flags); \ | ||
808 | } while (0) | ||
809 | #define bcm43xx_unlock_irqsafe(bcm, flags) do { \ | ||
810 | bcm43xx_unlock_irqonly(bcm, flags); \ | ||
811 | bcm43xx_unlock_noirq(bcm); \ | ||
812 | } while (0) | ||
813 | |||
814 | |||
815 | static inline | 779 | static inline |
816 | struct bcm43xx_private * bcm43xx_priv(struct net_device *dev) | 780 | struct bcm43xx_private * bcm43xx_priv(struct net_device *dev) |
817 | { | 781 | { |