]> err.no Git - linux-2.6/commitdiff
b43: Remove the PHY spinlock
authorMichael Buesch <mb@bu3sch.de>
Wed, 9 Jan 2008 18:08:49 +0000 (19:08 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 23:09:32 +0000 (15:09 -0800)
This fixes a sparse warning about weird locking.
The spinlock is not needed, so simply remove it.
This also adds some sanity checks to the PHY and radio locking
to protect against recursive locking.

Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/b43/b43.h
drivers/net/wireless/b43/debugfs.c
drivers/net/wireless/b43/main.c
drivers/net/wireless/b43/phy.c
drivers/net/wireless/b43/phy.h

index 086a9c6c2b07b85cdca626922a76f26abd0a57a5..5a1a790a105b9c4f4168e76e9e5d7b570cf0ac5e 100644 (file)
@@ -476,7 +476,6 @@ struct b43_phy {
        u16 radio_ver;          /* Radio version */
        u8 radio_rev;           /* Radio revision */
 
-       bool locked;            /* Only used in b43_phy_{un}lock() */
        bool dyn_tssi_tbl;      /* tssi2dbm is kmalloc()ed. */
 
        /* ACI (adjacent channel interference) flags. */
@@ -513,11 +512,6 @@ struct b43_phy {
        s16 lna_gain;           /* LNA */
        s16 pga_gain;           /* PGA */
 
-       /* PHY lock for core.rev < 3
-        * This lock is only used by b43_phy_{un}lock()
-        */
-       spinlock_t lock;
-
        /* Desired TX power level (in dBm).
         * This is set by the user and adjusted in b43_phy_xmitpower(). */
        u8 power_level;
@@ -528,9 +522,7 @@ struct b43_phy {
        struct b43_bbatt bbatt;
        struct b43_rfatt rfatt;
        u8 tx_control;          /* B43_TXCTL_XXX */
-#ifdef CONFIG_B43_DEBUG
-       bool manual_txpower_control;    /* Manual TX-power control enabled? */
-#endif
+
        /* Hardware Power Control enabled? */
        bool hardware_power_control;
 
@@ -571,6 +563,13 @@ struct b43_phy {
                B43_OFDMTAB_DIRECTION_READ,
                B43_OFDMTAB_DIRECTION_WRITE,
        } ofdmtab_addr_direction;
+
+#if B43_DEBUG
+       /* Manual TX-power control enabled? */
+       bool manual_txpower_control;
+       /* PHY registers locked by b43_phy_lock()? */
+       bool phy_locked;
+#endif /* B43_DEBUG */
 };
 
 /* Data structures for DMA transmission, per 80211 core. */
index 93e5030aa6c3881d484f4a9d7c593bf6b6cac335..e38ed0fe72e9c3978bdf1499d6c299c07e84854d 100644 (file)
@@ -222,8 +222,6 @@ out:
 static int txpower_g_write_file(struct b43_wldev *dev,
                                const char *buf, size_t count)
 {
-       unsigned long phy_flags;
-
        if (dev->phy.type != B43_PHYTYPE_G)
                return -ENODEV;
        if ((count >= 4) && (memcmp(buf, "auto", 4) == 0)) {
@@ -247,12 +245,12 @@ static int txpower_g_write_file(struct b43_wldev *dev,
                        dev->phy.tx_control |= B43_TXCTL_PA2DB;
                if (pa3db)
                        dev->phy.tx_control |= B43_TXCTL_PA3DB;
-               b43_phy_lock(dev, phy_flags);
+               b43_phy_lock(dev);
                b43_radio_lock(dev);
                b43_set_txpower_g(dev, &dev->phy.bbatt,
                                  &dev->phy.rfatt, dev->phy.tx_control);
                b43_radio_unlock(dev);
-               b43_phy_unlock(dev, phy_flags);
+               b43_phy_unlock(dev);
        }
 
        return 0;
index 7125af6f242a83a88bf3d7f200cc180f7235c375..ea63a9928803a88b9b0d3240c473c271d4533658 100644 (file)
@@ -3146,9 +3146,6 @@ static void setup_struct_phy_for_init(struct b43_wldev *dev,
        memset(phy->minlowsig, 0xFF, sizeof(phy->minlowsig));
        memset(phy->minlowsigpos, 0, sizeof(phy->minlowsigpos));
 
-       /* Flags */
-       phy->locked = 0;
-
        phy->aci_enable = 0;
        phy->aci_wlan_automatic = 0;
        phy->aci_hw_rssi = 0;
@@ -3175,7 +3172,6 @@ static void setup_struct_phy_for_init(struct b43_wldev *dev,
        phy->lofcal = 0xFFFF;
        phy->initval = 0xFFFF;
 
-       spin_lock_init(&phy->lock);
        phy->interfmode = B43_INTERFMODE_NONE;
        phy->channel = 0xFF;
 
index 67b8a922b337043ed37bd15ea7fc932de7cacb5a..2abf125aa2cf63698d87d3cb92de7392f608e7b9 100644 (file)
@@ -228,42 +228,30 @@ static void b43_shm_clear_tssi(struct b43_wldev *dev)
        }
 }
 
-void b43_raw_phy_lock(struct b43_wldev *dev)
+/* Lock the PHY registers against concurrent access from the microcode.
+ * This lock is nonrecursive. */
+void b43_phy_lock(struct b43_wldev *dev)
 {
-       struct b43_phy *phy = &dev->phy;
-
-       B43_WARN_ON(!irqs_disabled());
-
-       /* We had a check for MACCTL==0 here, but I think that doesn't
-        * make sense, as MACCTL is never 0 when this is called.
-        *      --mb */
-       B43_WARN_ON(b43_read32(dev, B43_MMIO_MACCTL) == 0);
+#if B43_DEBUG
+       B43_WARN_ON(dev->phy.phy_locked);
+       dev->phy.phy_locked = 1;
+#endif
+       B43_WARN_ON(dev->dev->id.revision < 3);
 
-       if (dev->dev->id.revision < 3) {
-               b43_mac_suspend(dev);
-               spin_lock(&phy->lock);
-       } else {
-               if (!b43_is_mode(dev->wl, IEEE80211_IF_TYPE_AP))
-                       b43_power_saving_ctl_bits(dev, B43_PS_AWAKE);
-       }
-       phy->locked = 1;
+       if (!b43_is_mode(dev->wl, IEEE80211_IF_TYPE_AP))
+               b43_power_saving_ctl_bits(dev, B43_PS_AWAKE);
 }
 
-void b43_raw_phy_unlock(struct b43_wldev *dev)
+void b43_phy_unlock(struct b43_wldev *dev)
 {
-       struct b43_phy *phy = &dev->phy;
+#if B43_DEBUG
+       B43_WARN_ON(!dev->phy.phy_locked);
+       dev->phy.phy_locked = 0;
+#endif
+       B43_WARN_ON(dev->dev->id.revision < 3);
 
-       B43_WARN_ON(!irqs_disabled());
-       if (dev->dev->id.revision < 3) {
-               if (phy->locked) {
-                       spin_unlock(&phy->lock);
-                       b43_mac_enable(dev);
-               }
-       } else {
-               if (!b43_is_mode(dev->wl, IEEE80211_IF_TYPE_AP))
-                       b43_power_saving_ctl_bits(dev, 0);
-       }
-       phy->locked = 0;
+       if (!b43_is_mode(dev->wl, IEEE80211_IF_TYPE_AP))
+               b43_power_saving_ctl_bits(dev, 0);
 }
 
 /* Different PHYs require different register routing flags.
@@ -1730,7 +1718,6 @@ void b43_phy_xmitpower(struct b43_wldev *dev)
                        int rfatt_delta, bbatt_delta;
                        int rfatt, bbatt;
                        u8 tx_control;
-                       unsigned long phylock_flags;
 
                        tmp = b43_shm_read16(dev, B43_SHM_SHARED, 0x0058);
                        v0 = (s8) (tmp & 0x00FF);
@@ -1861,13 +1848,13 @@ void b43_phy_xmitpower(struct b43_wldev *dev)
                        phy->bbatt.att = bbatt;
 
                        /* Adjust the hardware */
-                       b43_phy_lock(dev, phylock_flags);
+                       b43_phy_lock(dev);
                        b43_radio_lock(dev);
                        b43_set_txpower_g(dev, &phy->bbatt, &phy->rfatt,
                                          phy->tx_control);
                        b43_lo_g_ctl_mark_cur_used(dev);
                        b43_radio_unlock(dev);
-                       b43_phy_unlock(dev, phylock_flags);
+                       b43_phy_unlock(dev);
                        break;
                }
        default:
@@ -2158,6 +2145,7 @@ void b43_radio_lock(struct b43_wldev *dev)
        u32 macctl;
 
        macctl = b43_read32(dev, B43_MMIO_MACCTL);
+       B43_WARN_ON(macctl & B43_MACCTL_RADIOLOCK);
        macctl |= B43_MACCTL_RADIOLOCK;
        b43_write32(dev, B43_MMIO_MACCTL, macctl);
        /* Commit the write and wait for the device
@@ -2174,6 +2162,7 @@ void b43_radio_unlock(struct b43_wldev *dev)
        b43_read16(dev, B43_MMIO_PHY_VER);
        /* unlock */
        macctl = b43_read32(dev, B43_MMIO_MACCTL);
+       B43_WARN_ON(!(macctl & B43_MACCTL_RADIOLOCK));
        macctl &= ~B43_MACCTL_RADIOLOCK;
        b43_write32(dev, B43_MMIO_MACCTL, macctl);
 }
@@ -2355,12 +2344,11 @@ u8 b43_radio_aci_scan(struct b43_wldev * dev)
        u8 ret[13];
        unsigned int channel = phy->channel;
        unsigned int i, j, start, end;
-       unsigned long phylock_flags;
 
        if (!((phy->type == B43_PHYTYPE_G) && (phy->rev > 0)))
                return 0;
 
-       b43_phy_lock(dev, phylock_flags);
+       b43_phy_lock(dev);
        b43_radio_lock(dev);
        b43_phy_write(dev, 0x0802, b43_phy_read(dev, 0x0802) & 0xFFFC);
        b43_phy_write(dev, B43_PHY_G_CRS,
@@ -2389,7 +2377,7 @@ u8 b43_radio_aci_scan(struct b43_wldev * dev)
                        ret[j] = 1;
        }
        b43_radio_unlock(dev);
-       b43_phy_unlock(dev, phylock_flags);
+       b43_phy_unlock(dev);
 
        return ret[channel - 1];
 }
index 4ee01d534ba18cc28fc7b2227775c9c632a8d329..31bd4d87b404f4e322da5082f6a49b9113d40439 100644 (file)
@@ -199,18 +199,8 @@ enum {
 #define B43_PHYVER_TYPE_SHIFT          8
 #define B43_PHYVER_VERSION             0x00FF
 
-void b43_raw_phy_lock(struct b43_wldev *dev);
-#define b43_phy_lock(dev, flags) \
-       do {                                    \
-               local_irq_save(flags);          \
-               b43_raw_phy_lock(dev);  \
-       } while (0)
-void b43_raw_phy_unlock(struct b43_wldev *dev);
-#define b43_phy_unlock(dev, flags) \
-       do {                                    \
-               b43_raw_phy_unlock(dev);        \
-               local_irq_restore(flags);       \
-       } while (0)
+void b43_phy_lock(struct b43_wldev *dev);
+void b43_phy_unlock(struct b43_wldev *dev);
 
 u16 b43_phy_read(struct b43_wldev *dev, u16 offset);
 void b43_phy_write(struct b43_wldev *dev, u16 offset, u16 val);