Skip to contentSkip to conversation

Please pull latest bcm43xx-mac80211 + ssb

PATCH Michael Buesch 1 participant 1 message Jul 27, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

The following changes since commit 78d7c152a3a8880b7daab8a1be1f24199f9d80b9:
John W. Linville:

        Merge branch 'upstream' of git://git.kernel.org/.../ivd/rt2x00

are found in the git repository at:

http://bu3sch.de/git/wireless-dev.git/ for-linville

Larry Finger:
bcm43xx-mac80211: Fix deviations from OFDM table specs

Michael Buesch:
bcm43xx-mac80211: Fix build for PCI-less systems.
bcm43xx-mac80211: Use round_jiffies() to round pwork interval.
ssb: Zero out invariants before pulling them.
ssb: Rename nr_buses variable to next_busnumber
bcm43xx-mac80211: Add optional verbose DMA debugging.
bcm43xx-mac80211: Use ieee80211_generic_frame_duration() to calculate durations.
bcm43xx-mac80211: Add sanity checks for the packet length in the RX handler.
bcm43xx-mac80211: Rewrite and simplify handling of the initialization status.
bcm43xx-mac80211: Rewrite message logging to associate logmessages to the wiphy.
bcm43xx-mac80211: Get rid of all stupid bitfields and use bool.
bcm43xx-mac80211: Fix nondebug build.
Merge branch 'master' of git://git.kernel.org/.../linville/wireless-dev
Merge branch 'master' of git://git.kernel.org/.../linville/wireless-dev
ssb: Fix typo in EXTIF_BASE define.
ssb: Address Andrew Morton's comments.
bcm43xx-mac80211: Always run promisc on old devices with broken MAC addr filter.
ssb: Remove ifdef __KERNEL__
ssb: A few fixes
ssb: Cleanup Makefile and Kconfig.
ssb: Add more comments.
Merge branch 'master' of git://git.kernel.org/.../linville/wireless-dev
bcm43xx-mac80211: Fix compilation, pass if_id to ieee80211_generic_frame_duration()

 drivers/net/wireless/bcm43xx-mac80211/bcm43xx.h    |  113 +++---
 .../wireless/bcm43xx-mac80211/bcm43xx_debugfs.c    |   83 +----
 .../wireless/bcm43xx-mac80211/bcm43xx_debugfs.h    |   43 --
 .../net/wireless/bcm43xx-mac80211/bcm43xx_dma.c    |  108 ++++--
 .../net/wireless/bcm43xx-mac80211/bcm43xx_dma.h    |    8 
 drivers/net/wireless/bcm43xx-mac80211/bcm43xx_lo.c |   27 +
 drivers/net/wireless/bcm43xx-mac80211/bcm43xx_lo.h |    4 
 .../net/wireless/bcm43xx-mac80211/bcm43xx_main.c   |  400 +++++++++++++----------
 .../net/wireless/bcm43xx-mac80211/bcm43xx_phy.c    |   64 ++--
 .../net/wireless/bcm43xx-mac80211/bcm43xx_phy.h    |    4 
 .../net/wireless/bcm43xx-mac80211/bcm43xx_pio.c    |   18 +
 .../net/wireless/bcm43xx-mac80211/bcm43xx_pio.h    |    6 
 .../net/wireless/bcm43xx-mac80211/bcm43xx_sysfs.c  |    4 
 .../net/wireless/bcm43xx-mac80211/bcm43xx_xmit.c   |   23 +
 drivers/ssb/Kconfig                                |    1 
 drivers/ssb/Makefile                               |   18 +
 drivers/ssb/driver_chipcommon.c                    |   28 +
 drivers/ssb/driver_mipscore.c                      |   38 +-
 drivers/ssb/driver_pcicore.c                       |   30 +-
 drivers/ssb/main.c                                 |   90 ++---
 drivers/ssb/pci.c                                  |    4 
 drivers/ssb/pcmcia.c                               |   11 -
 drivers/ssb/scan.c                                 |   20 +
 drivers/ssb/ssb_private.h                          |   26 -
 include/linux/ssb/ssb.h                            |   29 +
 include/linux/ssb/ssb_driver_chipcommon.h          |    2 
 include/linux/ssb/ssb_driver_extif.h               |    3 
 include/linux/ssb/ssb_driver_mips.h                |    3 
 include/linux/ssb/ssb_driver_pci.h                 |    2 
 include/linux/ssb/ssb_regs.h                       |   12 -
 30 files changed, 593 insertions(+), 629 deletions(-)
drivers/net/wireless/bcm43xx-mac80211/bcm43xx.h +51 -62
index 2802fc0..49b471a 100644
@@ -23,8 +23,6 @@ #include "bcm43xx_lo.h"
 #include "bcm43xx_phy.h"
 
 
-#define PFX				KBUILD_MODNAME ": "
-
 #define BCM43xx_IRQWAIT_MAX_RETRIES	50
 
 #define BCM43xx_IO_SIZE			8192
@@ -441,11 +439,12 @@ # undef assert
 #endif
 #ifdef CONFIG_BCM43XX_MAC80211_DEBUG
 # define assert(expr) \
-	do {									\
-		if (unlikely(!(expr))) {					\
-		printk(KERN_ERR PFX "ASSERTION FAILED (%s) at: %s:%d:%s()\n",	\
-			#expr, __FILE__, __LINE__, __FUNCTION__);		\
-		}								\
+	do {								\
+		if (unlikely(!(expr))) {				\
+		printk(KERN_ERR KBUILD_MODNAME ": "			\
+		       "ASSERTION FAILED (%s) at: %s:%d:%s()\n",	\
+			#expr, __FILE__, __LINE__, __FUNCTION__);	\
+		}							\
 	} while (0)
 # define BCM43xx_DEBUG	1
 #else
@@ -453,31 +452,6 @@ # define assert(expr)	do { /* nothing */
 # define BCM43xx_DEBUG	0
 #endif
 
-/* rate limited printk(). */
-#ifdef printkl
-# undef printkl
-#endif
-#define printkl(f, x...)  do { if (printk_ratelimit()) printk(f ,##x); } while (0)
-/* rate limited printk() for debugging */
-#ifdef dprintkl
-# undef dprintkl
-#endif
-#ifdef CONFIG_BCM43XX_MAC80211_DEBUG
-# define dprintkl		printkl
-#else
-# define dprintkl(f, x...)	do { /* nothing */ } while (0)
-#endif
-
-/* debugging printk() */
-#ifdef dprintk
-# undef dprintk
-#endif
-#ifdef CONFIG_BCM43XX_MAC80211_DEBUG
-# define dprintk(f, x...)  do { printk(f ,##x); } while (0)
-#else
-# define dprintk(f, x...)  do { /* nothing */ } while (0)
-#endif
-
 
 struct net_device;
 struct pci_dev;
@@ -499,7 +473,7 @@ struct bcm43xx_phy {
 	/* Possible PHYMODEs on this PHY */
 	u8 possible_phymodes;
 	/* GMODE bit enabled? */
-	u8 gmode;
+	bool gmode;
 	/* Possible ieee80211 subsystem hwmodes for this PHY.
 	 * Which mode is selected, depends on thr GMODE enabled bit */
 #define BCM43xx_MAX_PHYHWMODES	2
@@ -517,14 +491,14 @@ #define BCM43xx_MAX_PHYHWMODES	2
 	u16 radio_ver;		/* Radio version */
 	u8 radio_rev;		/* Radio revision */
 
-	u8 radio_on:1;		/* Radio switched on/off */
-	u8 locked:1;		/* Only used in bcm43xx_phy_{un}lock() */
-	u8 dyn_tssi_tbl:1;	/* tssi2dbm is kmalloc()ed. */
+	bool radio_on;		/* Radio switched on/off */
+	bool locked;		/* Only used in bcm43xx_phy_{un}lock() */
+	bool dyn_tssi_tbl;	/* tssi2dbm is kmalloc()ed. */
 
 	/* ACI (adjacent channel interference) flags. */
-	u8 aci_enable:1;
-	u8 aci_wlan_automatic:1;
-	u8 aci_hw_rssi:1;
+	bool aci_enable;
+	bool aci_wlan_automatic;
+	bool aci_hw_rssi;
 
 	u16 minlowsig[2];
 	u16 minlowsigpos[2];
@@ -561,7 +535,7 @@ #define BCM43xx_MAX_PHYHWMODES	2
 	struct bcm43xx_rfatt rfatt;
 	u8 tx_control; /* BCM43xx_TXCTL_XXX */
 #ifdef CONFIG_BCM43XX_MAC80211_DEBUG
-	u8 manual_txpower_control; /* Manual TX-power control enabled? */
+	bool manual_txpower_control; /* Manual TX-power control enabled? */
 #endif
 
 	/* Current Interference Mitigation mode */
@@ -614,7 +588,7 @@ struct bcm43xx_pio {
 /* Context information for a noise calculation (Link Quality). */
 struct bcm43xx_noise_calculation {
 	u8 channel_at_start;
-	u8 calculation_running:1;
+	bool calculation_running;
 	u8 nr_samples;
 	s8 samples[8][4];
 };
@@ -627,7 +601,7 @@ struct bcm43xx_stats {
 };
 
 struct bcm43xx_key {
-	u8 enabled;
+	bool enabled;
 	u8 algorithm;
 	u8 address[6];
 };
@@ -663,11 +637,11 @@ struct bcm43xx_wl {
 	/* Counter of active monitor interfaces. */
 	int monitor;
 	/* Is the card operating in AP, STA or IBSS mode? */
-	unsigned int operating:1;
+	bool operating;
 	/* Promisc mode active?
 	 * Note that (monitor != 0) implies promisc.
 	 */
-	unsigned int promisc:1;
+	bool promisc;
 	/* Stats about the wireless interface */
 	struct ieee80211_low_level_stats ieee_stats;
 
@@ -698,13 +672,13 @@ struct bcm43xx_firmware {
 
 /* Device (802.11 core) initialization status. */
 enum {
-	BCM43xx_STAT_UNINIT,		/* Uninitialized. */
-	BCM43xx_STAT_INITIALIZING,	/* bcm43xx_wireless_core_init() in progress. */
-	BCM43xx_STAT_INITIALIZED,	/* Initialized. Note that this doesn't mean it's started. */
+	BCM43xx_STAT_UNINIT		= 0, /* Uninitialized. */
+	BCM43xx_STAT_INITIALIZED	= 1, /* Initialized, but not started, yet. */
+	BCM43xx_STAT_STARTED		= 2, /* Up and running. */
 };
-#define bcm43xx_status(bcm)		atomic_read(&(bcm)->init_status)
-#define bcm43xx_set_status(bcm, stat)	do {			\
-		atomic_set(&(bcm)->init_status, (stat));	\
+#define bcm43xx_status(wldev)		atomic_read(&(wldev)->__init_status)
+#define bcm43xx_set_status(wldev, stat)	do {			\
+		atomic_set(&(wldev)->__init_status, (stat));	\
 		smp_wmb();					\
 					} while (0)
 
@@ -721,19 +695,18 @@ struct bcm43xx_wldev {
 	struct ssb_device *dev;
 	struct bcm43xx_wl *wl;
 
-	/* Driver initialization status BCM43xx_STAT_*** */
-	atomic_t init_status;
-	/* Interface started? (bcm43xx_wireless_core_start()) */
-	u8 started;
+	/* The device initialization status.
+	 * Use bcm43xx_status() to query. */
+	atomic_t __init_status;
+	/* Saved init status for handling suspend. */
+	int suspend_init_status;
 
-	u16 was_initialized:1,		/* for suspend/resume. */
-	    was_started:1,		/* for suspend/resume. */
-	    __using_pio:1,		/* Internal, use bcm43xx_using_pio(). */
-	    bad_frames_preempt:1,	/* Use "Bad Frames Preemption" (default off) */
-	    reg124_set_0x4:1,		/* Some variable to keep track of IRQ stuff. */
-	    short_preamble:1,		/* TRUE, if short preamble is enabled. */
-	    short_slot:1,		/* TRUE, if short slot timing is enabled. */
-	    radio_hw_enable:1;          /* saved state of radio hardware enabled state */
+	bool __using_pio;		/* Internal, use bcm43xx_using_pio(). */
+	bool bad_frames_preempt;	/* Use "Bad Frames Preemption" (default off) */
+	bool reg124_set_0x4;		/* Some variable to keep track of IRQ stuff. */
+	bool short_preamble;		/* TRUE, if short preamble is enabled. */
+	bool short_slot;		/* TRUE, if short slot timing is enabled. */
+	bool radio_hw_enable;		/* saved state of radio hardware enabled state */
 
 	/* PHY/Radio device. */
 	struct bcm43xx_phy phy;
@@ -863,6 +836,22 @@ void bcm43xx_write32(struct bcm43xx_wlde
 	ssb_write32(dev->dev, offset, value);
 }
 
+
+/* Message printing */
+void bcminfo(struct bcm43xx_wl *wl, const char *fmt, ...)
+		__attribute__((format(printf, 2, 3)));
+void bcmerr(struct bcm43xx_wl *wl, const char *fmt, ...)
+		__attribute__((format(printf, 2, 3)));
+void bcmwarn(struct bcm43xx_wl *wl, const char *fmt, ...)
+		__attribute__((format(printf, 2, 3)));
+#if BCM43xx_DEBUG
+void bcmdbg(struct bcm43xx_wl *wl, const char *fmt, ...)
+		__attribute__((format(printf, 2, 3)));
+#else /* DEBUG */
+# define bcmdbg(wl, fmt...) do { /* nothing */ } while (0)
+#endif /* DEBUG */
+
+
 /** Limit a value between two limits */
 #ifdef limit_value
 # undef limit_value
drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.c +14 -69

148 lines not on this page · raw message

drivers/net/wireless/bcm43xx-mac80211/bcm43xx_debugfs.h +7 -36

73 lines not on this page · raw message

drivers/net/wireless/bcm43xx-mac80211/bcm43xx_dma.c +61 -47

230 lines not on this page · raw message

drivers/net/wireless/bcm43xx-mac80211/bcm43xx_dma.h +4 -4
index 3d109b1..baabeed 100644
@@ -194,7 +194,7 @@ struct bcm43xx_dmadesc_meta {
 	/* DMA base bus-address of the descriptor buffer. */
 	dma_addr_t dmaaddr;
 	/* ieee80211 TX status. Only used once per 802.11 frag. */
-	u8 is_last_fragment;
+	bool is_last_fragment;
 	struct ieee80211_tx_status txstat;
 };
 
@@ -247,11 +247,11 @@ struct bcm43xx_dmaring {
 	/* DMA controller index number (0-5). */
 	int index;
 	/* Boolean. Is this a TX ring? */
-	u8 tx;
+	bool tx;
 	/* Boolean. 64bit DMA if true, 32bit DMA otherwise. */
-	u8 dma64;
+	bool dma64;
 	/* Boolean. Is this ring stopped at ieee80211 level? */
-	u8 stopped;
+	bool stopped;
 	/* Lock, only used for TX. */
 	spinlock_t lock;
 	struct bcm43xx_wldev *dev;
drivers/net/wireless/bcm43xx-mac80211/bcm43xx_lo.c +13 -14
index aa1a298..b405779 100644
@@ -47,8 +47,8 @@ static void bcm43xx_lo_write(struct bcm4
 	if (BCM43xx_DEBUG) {
 		if (unlikely(abs(control->i) > 16 ||
 			     abs(control->q) > 16)) {
-			printk(KERN_ERR PFX "ERROR: Invalid LO control pair "
-					    "(I: %d, Q: %d)\n",
+			bcmdbg(dev->wl, "Invalid LO control pair "
+			       "(I: %d, Q: %d)\n",
 			       control->i, control->q);
 			dump_stack();
 			return;
@@ -64,22 +64,21 @@ static void bcm43xx_lo_write(struct bcm4
 
 static inline
 int assert_rfatt_and_bbatt(const struct bcm43xx_rfatt *rfatt,
-			   const struct bcm43xx_bbatt *bbatt)
+			   const struct bcm43xx_bbatt *bbatt,
+			   struct bcm43xx_wldev *dev)
 {
 	int err = 0;
 
 	/* Check the attenuation values against the LO control array sizes. */
 #if BCM43xx_DEBUG
 	if (rfatt->att >= BCM43xx_NR_RF) {
-		dprintk(KERN_ERR PFX
-			"ERROR: rfatt(%u) >= size of LO array\n",
-			rfatt->att);
+		bcmdbg(dev->wl, "rfatt(%u) >= size of LO array\n",
+		       rfatt->att);
 		err = -EINVAL;
 	}
 	if (bbatt->att >= BCM43xx_NR_BB) {
-		dprintk(KERN_ERR PFX
-			"ERROR: bbatt(%u) >= size of LO array\n",
-			bbatt->att);
+		bcmdbg(dev->wl, "bbatt(%u) >= size of LO array\n",
+		       bbatt->att);
 		err = -EINVAL;
 	}
 	if (err)
@@ -97,7 +96,7 @@ struct bcm43xx_loctl * bcm43xx_get_lo_g_
 	struct bcm43xx_phy *phy = &dev->phy;
 	struct bcm43xx_txpower_lo_control *lo = phy->lo_control;
 
-	if (assert_rfatt_and_bbatt(rfatt, bbatt))
+	if (assert_rfatt_and_bbatt(rfatt, bbatt, dev))
 		return &(lo->no_padmix[0][0]); /* Just prevent a crash */
 	return &(lo->no_padmix[bbatt->att][rfatt->att]);
 }
@@ -109,7 +108,7 @@ struct bcm43xx_loctl * bcm43xx_get_lo_g_
 	struct bcm43xx_phy *phy = &dev->phy;
 	struct bcm43xx_txpower_lo_control *lo = phy->lo_control;
 
-	if (assert_rfatt_and_bbatt(rfatt, bbatt))
+	if (assert_rfatt_and_bbatt(rfatt, bbatt, dev))
 		return &(lo->no_padmix[0][0]); /* Just prevent a crash */
 	if (rfatt->with_padmix)
 		return &(lo->with_padmix[bbatt->att][rfatt->att]);
@@ -1013,13 +1012,13 @@ #if BCM43xx_DEBUG
 static void do_validate_loctl(struct bcm43xx_wldev *dev,
 			      struct bcm43xx_loctl *control)
 {
-	const int is_initializing = (bcm43xx_status(dev) == BCM43xx_STAT_INITIALIZING);
+	const int is_initializing = (bcm43xx_status(dev) == BCM43xx_STAT_UNINIT);
 
 	if (unlikely(abs(control->i) > 16 ||
 		     abs(control->q) > 16 ||
 		     (is_initializing && control->used))) {
-		printk(KERN_ERR PFX "ERROR: LO control pair validation failed "
-				    "(first: %d, second: %d, used %u)\n",
+		bcmdbg(dev->wl, "ERROR: LO control pair validation failed "
+		       "(first: %d, second: %d, used %u)\n",
 		       control->i, control->q, control->used);
 	}
 }
drivers/net/wireless/bcm43xx-mac80211/bcm43xx_lo.h +2 -2
index 71fbe3e..377bda4 100644
@@ -35,7 +35,7 @@ #define BCM43xx_NR_RF	16
 
 	/* Flag to indicate a complete rebuild of the two tables above
 	 * to the LO measuring code. */
-	u8 rebuild;
+	bool rebuild;
 
 	/* Lists of valid RF and BB attenuation values for this device. */
 	struct bcm43xx_rfatt_list rfatt_list;
@@ -47,7 +47,7 @@ #define BCM43xx_NR_RF	16
 	u8 tx_magn;
 
 	/* GPHY LO is measured. */
-	u8 lo_measured;
+	bool lo_measured;
 
 	/* Saved device PowerVector */
 	u64 power_vector;
drivers/net/wireless/bcm43xx-mac80211/bcm43xx_main.c +219 -181

867 lines not on this page · raw message

drivers/net/wireless/bcm43xx-mac80211/bcm43xx_phy.c +30 -34

157 lines not on this page · raw message

drivers/net/wireless/bcm43xx-mac80211/bcm43xx_phy.h +2 -2
index 75cea5a..8660103 100644
@@ -232,8 +232,8 @@ #define has_loopback_gain(phy) \
 
 /* Radio Attenuation (RF Attenuation) */
 struct bcm43xx_rfatt {
-	u8 att;		/* Attenuation value */
-	u8 with_padmix;	/* Flag, PAD Mixer enabled. */
+	u8 att;			/* Attenuation value */
+	bool with_padmix;	/* Flag, PAD Mixer enabled. */
 };
 struct bcm43xx_rfatt_list {
 	/* Attenuation values list */
drivers/net/wireless/bcm43xx-mac80211/bcm43xx_pio.c +9 -9
index 3ae5ef5..16779c2 100644
@@ -231,8 +231,8 @@ static int pio_tx_packet(struct bcm43xx_
 
 	octets = (u16)skb->len + sizeof(struct bcm43xx_txhdr_fw4);
 	if (queue->tx_devq_size < octets) {
-		printkl(KERN_WARNING PFX "PIO queue too small. "
-					 "Dropping packet.\n");
+		bcmwarn(queue->dev->wl, "PIO queue too small. "
+			"Dropping packet.\n");
 		/* Drop it silently (return success) */
 		free_txpacket(packet, 1);
 		return 0;
@@ -340,13 +340,13 @@ struct bcm43xx_pioqueue * bcm43xx_setup_
 
 	qsize = bcm43xx_read16(dev, queue->mmio_base + BCM43xx_PIO_TXQBUFSIZE);
 	if (qsize == 0) {
-		printk(KERN_ERR PFX "ERROR: This card does not support PIO "
-				    "operation mode. Please use DMA mode "
-				    "(module parameter pio=0).\n");
+		bcmerr(dev->wl, "This card does not support PIO "
+		       "operation mode. Please use DMA mode "
+		       "(module parameter pio=0).\n");
 		goto err_freequeue;
 	}
 	if (qsize <= BCM43xx_PIO_TXQADJUST) {
-		printk(KERN_ERR PFX "PIO tx device-queue too small (%u)\n",
+		bcmerr(dev->wl, "PIO tx device-queue too small (%u)\n",
 		       qsize);
 		goto err_freequeue;
 	}
@@ -432,7 +432,7 @@ int bcm43xx_pio_init(struct bcm43xx_wlde
 	if (dev->dev->id.revision < 3)
 		dev->irq_savedstate |= BCM43xx_IRQ_PIO_WORKAROUND;
 
-	dprintk(KERN_INFO PFX "PIO initialized\n");
+	bcmdbg(dev->wl, "PIO initialized\n");
 	err = 0;
 out:
 	return err;
@@ -522,7 +522,7 @@ static void pio_rx_error(struct bcm43xx_
 {
 	int i;
 
-	printkl("PIO RX error: %s\n", error);
+	bcmerr(queue->dev->wl, "PIO RX error: %s\n", error);
 	bcm43xx_pio_write(queue, BCM43xx_PIO_RXCTL,
 			  BCM43xx_PIO_RXCTL_READY);
 	if (clear_buffers) {
@@ -554,7 +554,7 @@ void bcm43xx_pio_rx(struct bcm43xx_pioqu
 			goto data_ready;
 		udelay(10);
 	}
-	dprintkl(KERN_ERR PFX "PIO RX timed out\n");
+	bcmdbg(queue->dev->wl, "PIO RX timed out\n");
 	return;
 data_ready:
 
drivers/net/wireless/bcm43xx-mac80211/bcm43xx_pio.h +3 -3
index b9d919b..9d112f0 100644
@@ -51,9 +51,9 @@ struct bcm43xx_pioqueue {
 	struct bcm43xx_wldev *dev;
 	u16 mmio_base;
 
-	u8 tx_suspended:1,
-	   tx_frozen:1,
-	   need_workarounds:1; /* Workarounds needed for core.rev < 3 */
+	bool tx_suspended;
+	bool tx_frozen;
+	bool need_workarounds; /* Workarounds needed for core.rev < 3 */
 
 	/* Adjusted size of the device internal TX buffer. */
 	u16 tx_devq_size;
drivers/net/wireless/bcm43xx-mac80211/bcm43xx_sysfs.c +2 -2
index eed688f..611f688 100644
@@ -137,8 +137,8 @@ static ssize_t bcm43xx_attr_interfmode_s
 
 	err = bcm43xx_radio_set_interference_mitigation(wldev, mode);
 	if (err) {
-		printk(KERN_ERR PFX "Interference Mitigation not "
-				    "supported by device\n");
+		bcmerr(wldev->wl, "Interference Mitigation not "
+		       "supported by device\n");
 	}
 	mmiowb();
 	spin_unlock_irqrestore(&wldev->wl->irq_lock, flags);
drivers/net/wireless/bcm43xx-mac80211/bcm43xx_xmit.c +21 -2
index 469c9e0..8ca35d2 100644
@@ -467,12 +467,19 @@ void bcm43xx_rx(struct bcm43xx_wldev *de
 
 	/* Skip PLCP and padding */
 	padding = (macstat & BCM43xx_RX_MAC_PADDING) ? 2 : 0;
+	if (unlikely(skb->len < (sizeof(struct bcm43xx_plcp_hdr6) + padding))) {
+		bcmdbg(dev->wl, "RX: Packet size underrun (1)\n");
+		goto drop;
+	}
 	plcp = (struct bcm43xx_plcp_hdr6 *)(skb->data + padding);
 	skb_pull(skb, sizeof(struct bcm43xx_plcp_hdr6) + padding);
 	/* The skb contains the Wireless Header + payload data now */
+	if (unlikely(skb->len < (2+2+6/*minimum hdr*/ + FCS_LEN))) {
+		bcmdbg(dev->wl, "RX: Packet size underrun (2)\n");
+		goto drop;
+	}
 	wlhdr = (struct ieee80211_hdr *)(skb->data);
 	fctl = le16_to_cpu(wlhdr->frame_control);
-
 	skb_trim(skb, skb->len - FCS_LEN);
 
 	if ((macstat & BCM43xx_RX_MAC_DEC) &&
@@ -497,6 +504,10 @@ void bcm43xx_rx(struct bcm43xx_wldev *de
 			wlhdr->frame_control = cpu_to_le16(fctl);
 
 			wlhdr_len = ieee80211_get_hdrlen(fctl);
+			if (unlikely(skb->len < (wlhdr_len + 3))) {
+				bcmdbg(dev->wl, "RX: Packet size underrun (3)\n");
+				goto drop;
+			}
 			if (skb->data[wlhdr_len + 3] & (1 << 5)) {
 				/* The Ext-IV Bit is set in the "KeyID"
 				 * octet of the IV.
@@ -507,7 +518,10 @@ void bcm43xx_rx(struct bcm43xx_wldev *de
 				iv_len = 4;
 				icv_len = 4;
 			}
-
+			if (unlikely(skb->len < (wlhdr_len + iv_len + icv_len))) {
+				bcmdbg(dev->wl, "RX: Packet size underrun (4)\n");
+				goto drop;
+			}
 			/* Remove the IV */
 			memmove(skb->data + iv_len, skb->data, wlhdr_len);
 			skb_pull(skb, iv_len);
@@ -554,6 +568,11 @@ void bcm43xx_rx(struct bcm43xx_wldev *de
 
 	dev->stats.last_rx = jiffies;
 	ieee80211_rx_irqsafe(dev->wl->hw, skb, &status);
+
+	return;
+drop:
+	bcmdbg(dev->wl, "RX: Packet dropped\n");
+	dev_kfree_skb_any(skb);
 }
 
 void bcm43xx_handle_txstatus(struct bcm43xx_wldev *dev,
drivers/ssb/Kconfig +0 -1
index 03c4945..34a9411 100644
@@ -58,7 +58,6 @@ config SSB_SERIAL
 config SSB_DRIVER_PCICORE
 	bool "SSB PCI core driver"
 	depends on SSB && SSB_PCIHOST
-	default y
 	help
 	  Driver for the Sonics Silicon Backplane attached
 	  Broadcom PCI core.
drivers/ssb/Makefile +10 -8
index 9a2b379..045aff0 100644
@@ -1,11 +1,13 @@
-ssb-builtin-drivers-y					+= driver_chipcommon.o
-ssb-builtin-drivers-$(CONFIG_SSB_DRIVER_MIPS)		+= driver_mipscore.o
-ssb-builtin-drivers-$(CONFIG_SSB_DRIVER_PCICORE)	+= driver_pcicore.o
+# core
+ssb-y					+= main.o scan.o
 
-ssb-hostsupport-$(CONFIG_SSB_PCIHOST)			+= pci.o pcihost_wrapper.o
-ssb-hostsupport-$(CONFIG_SSB_PCMCIAHOST)		+= pcmcia.o
+# host support
+ssb-$(CONFIG_SSB_PCIHOST)		+= pci.o pcihost_wrapper.o
+ssb-$(CONFIG_SSB_PCMCIAHOST)		+= pcmcia.o
 
-obj-$(CONFIG_SSB) += ssb.o
+# built-in drivers
+ssb-y					+= driver_chipcommon.o
+ssb-$(CONFIG_SSB_DRIVER_MIPS)		+= driver_mipscore.o
+ssb-$(CONFIG_SSB_DRIVER_PCICORE)	+= driver_pcicore.o
 
-ssb-objs	:= main.o scan.o \
-		   $(ssb-hostsupport-y) $(ssb-builtin-drivers-y)
+obj-$(CONFIG_SSB)			+= ssb.o
drivers/ssb/driver_chipcommon.c +10 -18
index a283de9..8e5491c 100644
@@ -16,7 +16,7 @@ #include "ssb_private.h"
 
 
 /* Clock sources */
-enum {
+enum ssb_clksrc {
 	/* PCI clock */
 	SSB_CHIPCO_CLKSRC_PCI,
 	/* Crystal slow clock oscillator */
@@ -85,15 +85,15 @@ void ssb_chipco_set_clockmode(struct ssb
 			ssb_pci_xtal(bus, SSB_GPIO_XTAL, 0);
 		break;
 	default:
-		assert(0);
+		SSB_WARN_ON(1);
 	}
 }
 
 /* Get the Slow Clock Source */
-static int chipco_pctl_get_slowclksrc(struct ssb_chipcommon *cc)
+static enum ssb_clksrc chipco_pctl_get_slowclksrc(struct ssb_chipcommon *cc)
 {
 	struct ssb_bus *bus = cc->dev->bus;
-	u32 tmp = 0;
+	u32 uninitialized_var(tmp);
 
 	if (cc->dev->id.revision < 6) {
 		if (bus->bustype == SSB_BUSTYPE_SSB ||
@@ -123,9 +123,9 @@ static int chipco_pctl_get_slowclksrc(st
 /* Get maximum or minimum (depending on get_max flag) slowclock frequency. */
 static int chipco_pctl_clockfreqlimit(struct ssb_chipcommon *cc, int get_max)
 {
-	int limit;
-	int clocksrc;
-	int divisor;
+	int uninitialized_var(limit);
+	enum ssb_clksrc clocksrc;
+	int divisor = 1;
 	u32 tmp;
 
 	clocksrc = chipco_pctl_get_slowclksrc(cc);
@@ -138,13 +138,11 @@ static int chipco_pctl_clockfreqlimit(st
 			divisor = 32;
 			break;
 		default:
-			assert(0);
-			divisor = 1;
+			SSB_WARN_ON(1);
 		}
 	} else if (cc->dev->id.revision < 10) {
 		switch (clocksrc) {
 		case SSB_CHIPCO_CLKSRC_LOPWROS:
-			divisor = 1;
 			break;
 		case SSB_CHIPCO_CLKSRC_XTALOS:
 		case SSB_CHIPCO_CLKSRC_PCI:
@@ -152,9 +150,6 @@ static int chipco_pctl_clockfreqlimit(st
 			divisor = (tmp >> 16) + 1;
 			divisor *= 4;
 			break;
-		default:
-			assert(0);
-			divisor = 1;
 		}
 	} else {
 		tmp = chipco_read32(cc, SSB_CHIPCO_SYSCLKCTL);
@@ -181,9 +176,6 @@ static int chipco_pctl_clockfreqlimit(st
 		else
 			limit = 25000000;
 		break;
-	default:
-		assert(0);
-		limit = 0;
 	}
 	limit /= divisor;
 
@@ -235,7 +227,7 @@ static void calc_fast_powerup_delay(stru
 	minfreq = chipco_pctl_clockfreqlimit(cc, 0);
 	pll_on_delay = chipco_read32(cc, SSB_CHIPCO_PLLONDELAY);
 	tmp = (((pll_on_delay + 2) * 1000000) + (minfreq - 1)) / minfreq;
-	assert((tmp & ~0xFFFF) == 0);
+	SSB_WARN_ON(tmp & ~0xFFFF);
 
 	cc->fast_pwrup_delay = tmp;
 }
@@ -355,7 +347,7 @@ int ssb_chipco_serial_init(struct ssb_ch
 			div = 2; /* Minimum divisor */
 			chipco_write32(cc, SSB_CHIPCO_CLKDIV,
 				       (chipco_read32(cc, SSB_CHIPCO_CLKDIV)
-				        & ~SSB_CHIPCO_CLKDIV_UART) | div);
+					& ~SSB_CHIPCO_CLKDIV_UART) | div);
 		} else {
 			/* Fixed internal backplane clock */
 			baud_base = 88000000;
drivers/ssb/driver_mipscore.c +19 -19
index 67d1017..3f09598 100644
@@ -13,7 +13,7 @@ #include <linux/ssb/ssb.h>
 #include <linux/serial.h>
 #include <linux/serial_core.h>
 #include <linux/serial_reg.h>
-#include <asm/time.h>
+#include <linux/time.h>
 
 #include "ssb_private.h"
 
@@ -224,7 +224,6 @@ #if 0
 		tmp = tmp | CEIL(120, ns);		/* W0 = 120nS */
 		W_REG(&eir->prog_waitcount, tmp);
 	}
-	else... chipcommon
 #endif
 	if (bus->chipco.dev)
 		ssb_chipco_timing_init(&bus->chipco, ns);
@@ -233,23 +232,24 @@ #endif
 	for (irq = 2, i = 0; i < bus->nr_devices; i++) {
 		dev = &(bus->devices[i]);
 		dev->irq = ssb_mips_irq(dev) + 2;
-		switch(dev->id.coreid) {
-			case SSB_DEV_USB11_HOST:
-				/* shouldn't need a separate irq line for non-4710, most of them have a proper
-				 * external usb controller on the pci */
-				if ((bus->chip_id == 0x4710) && (irq <= 4)) {
-					set_irq(dev, irq++);
-					break;
-				}
-			case SSB_DEV_PCI:
-			case SSB_DEV_ETHERNET:
-			case SSB_DEV_80211:
-			case SSB_DEV_USB20_HOST:
-				/* These devices get their own IRQ line if available, the rest goes on IRQ0 */
-				if (irq <= 4) {
-					set_irq(dev, irq++);
-					break;
-				}
+		switch (dev->id.coreid) {
+		case SSB_DEV_USB11_HOST:
+			/* shouldn't need a separate irq line for non-4710, most of them have a proper
+			 * external usb controller on the pci */
+			if ((bus->chip_id == 0x4710) && (irq <= 4)) {
+				set_irq(dev, irq++);
+				break;
+			}
+			/* fallthrough */
+		case SSB_DEV_PCI:
+		case SSB_DEV_ETHERNET:
+		case SSB_DEV_80211:
+		case SSB_DEV_USB20_HOST:
+			/* These devices get their own IRQ line if available, the rest goes on IRQ0 */
+			if (irq <= 4) {
+				set_irq(dev, irq++);
+				break;
+			}
 		}
 	}
 
drivers/ssb/driver_pcicore.c +16 -14
index 841847b..76a9a51 100644
@@ -34,8 +34,10 @@ void pcicore_write32(struct ssb_pcicore 
 #ifdef CONFIG_SSB_PCICORE_HOSTMODE
 
 #include <asm/paccess.h>
-/* Read the bus and catch bus exceptions. This is MIPS specific. */
-#define mips_busprobe(val, addr)	get_dbe((val), (addr))
+/* Probe a 32bit value on the bus and catch bus exceptions.
+ * Returns nonzero on a bus exception.
+ * This is MIPS specific */
+#define mips_busprobe32(val, addr)	get_dbe((val), ((u32 *)(addr)))
 
 /* Assume one-hot slot wiring */
 #define SSB_PCI_SLOT_MAX	16
@@ -54,7 +56,8 @@ int pcibios_plat_dev_init(struct pci_dev
 	int pos, size;
 	u32 *base;
 
-	printk("PCI: Fixing up device %s\n", pci_name(d));
+	ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
+		   pci_name(d));
 
 	/* Fix up resource bases */
 	for (pos = 0; pos < 6; pos++) {
@@ -85,7 +88,7 @@ static void __init ssb_fixup_pcibridge(s
 	if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0)
 		return;
 
-	printk("PCI: fixing up bridge\n");
+	ssb_printk(KERN_INFO "PCI: fixing up bridge\n");
 
 	/* Enable PCI bridge bus mastering and memory space */
 	pci_set_master(dev);
@@ -147,7 +150,7 @@ static int ssb_extpci_read_config(struct
 	u32 addr, val;
 	void __iomem *mmio;
 
-	assert(pc->hostmode);
+	SSB_WARN_ON(!pc->hostmode);
 	if (unlikely(len != 1 && len != 2 && len != 4))
 		goto out;
 	addr = get_cfgspace_addr(pc, bus, dev, func, off);
@@ -158,7 +161,7 @@ static int ssb_extpci_read_config(struct
 	if (!mmio)
 		goto out;
 
-	if (mips_busprobe(val, (u32 *) mmio)) {
+	if (mips_busprobe32(val, mmio)) {
 		val = 0xffffffff;
 		goto unmap;
 	}
@@ -193,7 +196,7 @@ static int ssb_extpci_write_config(struc
 	u32 addr, val = 0;
 	void __iomem *mmio;
 
-	assert(pc->hostmode);
+	SSB_WARN_ON(!pc->hostmode);
 	if (unlikely(len != 1 && len != 2 && len != 4))
 		goto out;
 	addr = get_cfgspace_addr(pc, bus, dev, func, off);
@@ -204,7 +207,7 @@ static int ssb_extpci_write_config(struc
 	if (!mmio)
 		goto out;
 
-	if (mips_busprobe(val, (u32 *) mmio)) {
+	if (mips_busprobe32(val, mmio)) {
 		val = 0xffffffff;
 		goto unmap;
 	}
@@ -291,10 +294,8 @@ static void ssb_pcicore_init_hostmode(st
 {
 	u32 val;
 
-	if (extpci_core) {
-		WARN_ON(1);
+	if (WARN_ON(extpci_core))
 		return;
-	}
 	extpci_core = pc;
 
 	ssb_dprintk(KERN_INFO PFX "PCIcore in host mode found\n");
@@ -364,7 +365,7 @@ static int pcicore_is_in_hostmode(struct
 	if (bus->chip_id == 0x5350)
 		return 0;
 
-	return !mips_busprobe(tmp, (u32 *) (bus->mmio + (pc->dev->core_index * SSB_CORE_SIZE)));
+	return !mips_busprobe32(tmp, (bus->mmio + (pc->dev->core_index * SSB_CORE_SIZE)));
 }
 #endif /* CONFIG_SSB_PCICORE_HOSTMODE */
 
@@ -458,7 +459,8 @@ static void ssb_commit_settings(struct s
 	struct ssb_device *dev;
 
 	dev = bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev;
-	assert(dev);
+	if (WARN_ON(!dev))
+		return;
 	/* This forces an update of the cached registers. */
 	ssb_broadcast_value(dev, 0xFD8, 0);
 }
@@ -531,7 +533,7 @@ int ssb_pcicore_dev_irqvecs_enable(struc
 			pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
 		}
 	} else {
-		assert(pdev->id.coreid == SSB_DEV_PCIE);
+		WARN_ON(pdev->id.coreid != SSB_DEV_PCIE);
 		//TODO: Better make defines for all these magic PCIE values.
 		if ((pdev->id.revision == 0) || (pdev->id.revision == 1)) {
 			/* TLP Workaround register. */
drivers/ssb/main.c +48 -42

247 lines not on this page · raw message

drivers/ssb/pci.c +4 -0
index f9dc28f..6767fd2 100644
@@ -23,6 +23,7 @@ #include <linux/delay.h>
 #include "ssb_private.h"
 
 
+/* Lowlevel coreswitching */
 int ssb_pci_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
 {
 	int err;
@@ -74,6 +75,7 @@ int ssb_pci_switch_core(struct ssb_bus *
 	return err;
 }
 
+/* Enable/disable the on board crystal oscillator and/or PLL. */
 int ssb_pci_xtal(struct ssb_bus *bus, u32 what, int turn_on)
 {
 	int err;
@@ -158,7 +160,9 @@ err_pci:
 	goto out;
 }
 
+/* Get the word-offset for a SSB_SPROM_XXX define. */
 #define SPOFF(offset)	(((offset) - SSB_SPROM_BASE) / sizeof(u16))
+/* Helper to extract some _offset, which is one of the SSB_SPROM_XXX defines. */
 #define SPEX(_outvar, _offset, _mask, _shift)	\
 	out->_outvar = ((in[SPOFF(_offset)] & (_mask)) >> (_shift))
 
drivers/ssb/pcmcia.c +6 -5
index b908563..f72afd8 100644
@@ -112,7 +112,7 @@ int ssb_pcmcia_switch_segment(struct ssb
 	conf_reg_t reg;
 	int res, err = 0;
 
-	assert(seg == 0 || seg == 1);
+	SSB_WARN_ON((seg != 0) && (seg != 1));
 	reg.Offset = 0x34;
 	reg.Function = 0;
 	spin_lock_irqsave(&bus->bar_lock, flags);
@@ -145,6 +145,9 @@ error:
 	goto out_unlock;
 }
 
+/* These are the main device register access functions.
+ * do_select_core is inline to have the likely hotpath inline.
+ * All unlikely codepaths are out-of-line. */
 static inline int do_select_core(struct ssb_bus *bus,
 				 struct ssb_device *dev,
 				 u16 *offset)
@@ -176,7 +179,7 @@ static u16 ssb_pcmcia_read16(struct ssb_
 	if (unlikely(do_select_core(bus, dev, &offset)))
 		return 0xFFFF;
 	x = readw(bus->mmio + offset);
-//printk("R16 0x%04X, 0x%04X\n", offset, x);
+
 	return x;
 }
 
@@ -188,7 +191,7 @@ static u32 ssb_pcmcia_read32(struct ssb_
 	if (unlikely(do_select_core(bus, dev, &offset)))
 		return 0xFFFFFFFF;
 	x = readl(bus->mmio + offset);
-//printk("R32 0x%04X, 0x%08X\n", offset, x);
+
 	return x;
 }
 
@@ -198,7 +201,6 @@ static void ssb_pcmcia_write16(struct ss
 
 	if (unlikely(do_select_core(bus, dev, &offset)))
 		return;
-//printk("W16 0x%04X, 0x%04X\n", offset, value);
 	writew(value, bus->mmio + offset);
 }
 
@@ -208,7 +210,6 @@ static void ssb_pcmcia_write32(struct ss
 
 	if (unlikely(do_select_core(bus, dev, &offset)))
 		return;
-//printk("W32 0x%04X, 0x%08X\n", offset, value);
 	readw(bus->mmio + offset);
 	writew(value >> 16, bus->mmio + offset + 2);
 	readw(bus->mmio + offset);
drivers/ssb/scan.c +13 -7
index feaf1e5..9c33425 100644
@@ -15,14 +15,12 @@
 #include <linux/ssb/ssb.h>
 #include <linux/ssb/ssb_regs.h>
 #include <linux/pci.h>
-#include <asm/io.h>
+#include <linux/io.h>
 
-#ifdef CONFIG_SSB_PCMCIAHOST
-# include <pcmcia/cs_types.h>
-# include <pcmcia/cs.h>
-# include <pcmcia/cistpl.h>
-# include <pcmcia/ds.h>
-#endif
+#include <pcmcia/cs_types.h>
+#include <pcmcia/cs.h>
+#include <pcmcia/cistpl.h>
+#include <pcmcia/ds.h>
 
 #include "ssb_private.h"
 
@@ -202,7 +200,11 @@ void ssb_iounmap(struct ssb_bus *bus)
 		iounmap(bus->mmio);
 		break;
 	case SSB_BUSTYPE_PCI:
+#ifdef CONFIG_SSB_PCIHOST
 		pci_iounmap(bus->host_pci, bus->mmio);
+#else
+		SSB_BUG_ON(1); /* Can't reach this code. */
+#endif
 		break;
 	}
 	bus->mmio = NULL;
@@ -222,7 +224,11 @@ static void __iomem * ssb_ioremap(struct
 		mmio = ioremap(baseaddr, SSB_CORE_SIZE);
 		break;
 	case SSB_BUSTYPE_PCI:
+#ifdef CONFIG_SSB_PCIHOST
 		mmio = pci_iomap(bus->host_pci, 0, ~0UL);
+#else
+		SSB_BUG_ON(1); /* Can't reach this code. */
+#endif
 		break;
 	}
 
drivers/ssb/ssb_private.h +5 -21
index d00d186..8e2e310 100644
@@ -3,7 +3,6 @@ #define LINUX_SSB_PRIVATE_H_
 
 #include <linux/ssb/ssb.h>
 #include <linux/types.h>
-#include <asm/io.h>
 
 
 #define PFX	"ssb: "
@@ -16,32 +15,19 @@ #endif /* CONFIG_SSB_SILENT */
 
 /* dprintk: Debugging printk; vanishes for non-debug compilation */
 #ifdef CONFIG_SSB_DEBUG
-# define ssb_dprintk(fmt, x...)	ssb_printk(fmt ,##x)
+# define ssb_dprintk(fmt, x...)	ssb_printk(fmt , ##x)
 #else
 # define ssb_dprintk(fmt, x...)	do { /* nothing */ } while (0)
 #endif
 
-/* printkl: Rate limited printk */
-#define ssb_printkl(fmt, x...)	do {		\
-	if (printk_ratelimit())			\
-		ssb_printk(fmt ,##x);		\
-				} while (0)
-
-/* dprintkl: Rate limited debugging printk */
 #ifdef CONFIG_SSB_DEBUG
-# define ssb_dprintkl			ssb_printkl
+# define SSB_WARN_ON(x)		WARN_ON(x)
+# define SSB_BUG_ON(x)		BUG_ON(x)
 #else
-# define ssb_dprintkl(fmt, x...)	do { /* nothing */ } while (0)
+# define SSB_WARN_ON(x)		do { /* nothing */ } while (0)
+# define SSB_BUG_ON(x)		do { /* nothing */ } while (0)
 #endif
 
-#define assert(cond)	do {						\
-	if (unlikely(!(cond))) {					\
-		ssb_dprintk(KERN_ERR PFX "BUG: Assertion failed (%s) "	\
-			    "at: %s:%d:%s()\n",				\
-			    #cond, __FILE__, __LINE__, __func__);	\
-	}								\
-		       } while (0)
-
 
 /* pci.c */
 #ifdef CONFIG_SSB_PCIHOST
@@ -128,10 +114,8 @@ extern void ssb_iounmap(struct ssb_bus *
 
 /* core.c */
 extern u32 ssb_calc_clock_rate(u32 plltype, u32 n, u32 m);
-#ifdef CONFIG_SSB_PCIHOST
 extern int ssb_devices_freeze(struct ssb_bus *bus);
 extern int ssb_devices_thaw(struct ssb_bus *bus);
 extern struct ssb_bus * ssb_pci_dev_to_bus(struct pci_dev *pdev);
-#endif /* CONFIG_SSB_PCIHOST */
 
 #endif /* LINUX_SSB_PRIVATE_H_ */
include/linux/ssb/ssb.h +19 -10
index 709e2fa..a3c63ae 100644
@@ -1,14 +1,11 @@
 #ifndef LINUX_SSB_H_
 #define LINUX_SSB_H_
-#ifdef __KERNEL__
 
 #include <linux/device.h>
 #include <linux/list.h>
 #include <linux/types.h>
 #include <linux/spinlock.h>
-#ifdef CONFIG_SSB_PCIHOST
-# include <linux/pci.h>
-#endif
+#include <linux/pci.h>
 
 #include <linux/ssb/ssb_regs.h>
 
@@ -296,6 +293,7 @@ struct ssb_bus {
 	struct pcmcia_device *host_pcmcia;
 
 #ifdef CONFIG_SSB_PCIHOST
+	/* Mutex to protect the SPROM writing. */
 	struct mutex pci_sprom_mutex;
 #endif
 
@@ -312,7 +310,7 @@ #endif
 	u8 suspend_cnt;
 
 	/* Software ID number for this bus. */
-	int busnumber;
+	unsigned int busnumber;
 
 	/* The ChipCommon device (if available). */
 	struct ssb_chipcommon chipco;
@@ -342,6 +340,9 @@ struct ssb_init_invariants {
 	struct ssb_boardinfo boardinfo;
 	struct ssb_sprom sprom;
 };
+/* Type of function to fetch the invariants. */
+typedef int (*ssb_invariants_func_t)(struct ssb_bus *bus,
+				     struct ssb_init_invariants *iv);
 
 /* Register a SSB system bus. get_invariants() is called after the
  * basic system devices are initialized.
@@ -349,8 +350,7 @@ struct ssb_init_invariants {
  * Put the invariants into the struct pointed to by iv. */
 extern int ssb_bus_ssbbus_register(struct ssb_bus *bus,
 				   unsigned long baseaddr,
-				   int (*get_invariants)(struct ssb_bus *bus,
-				   			 struct ssb_init_invariants *iv));
+				   ssb_invariants_func_t get_invariants);
 #ifdef CONFIG_SSB_PCIHOST
 extern int ssb_bus_pcibus_register(struct ssb_bus *bus,
 				   struct pci_dev *host_pci);
@@ -365,8 +365,12 @@ extern void ssb_bus_unregister(struct ss
 
 extern u32 ssb_clockspeed(struct ssb_bus *bus);
 
+/* Is the device enabled in hardware? */
 int ssb_device_is_enabled(struct ssb_device *dev);
+/* Enable a device and pass device-specific SSB_TMSLOW flags.
+ * If no device-specific flags are available, use 0. */
 void ssb_device_enable(struct ssb_device *dev, u32 core_specific_flags);
+/* Disable a device in hardware and pass SSB_TMSLOW flags (if any). */
 void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags);
 
 
@@ -408,9 +412,15 @@ static inline void ssb_pcihost_unregiste
 #endif /* CONFIG_SSB_PCIHOST */
 
 
-/* Bus-Power handling functions. */
+/* If a driver is shutdown or suspended, call this to signal
+ * that the bus may be completely powered down. SSB will decide,
+ * if it's really time to power down the bus, based on if there
+ * are other devices that want to run. */
 extern int ssb_bus_may_powerdown(struct ssb_bus *bus);
-extern int ssb_bus_powerup(struct ssb_bus *bus, int dynamic_pctl);
+/* Before initializing and enabling a device, call this to power-up the bus.
+ * If you want to allow use of dynamic-power-control, pass the flag.
+ * Otherwise static always-on powercontrol will be used. */
+extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);
 
 
 /* Various helper functions */
@@ -418,5 +428,4 @@ extern u32 ssb_admatch_base(u32 adm);
 extern u32 ssb_admatch_size(u32 adm);
 
 
-#endif /* __KERNEL__ */
 #endif /* LINUX_SSB_H_ */
include/linux/ssb/ssb_driver_chipcommon.h +0 -2
index 8856590..d58c24b 100644
@@ -12,7 +12,6 @@ #define LINUX_SSB_CHIPCO_H_
  *
  * Licensed under the GPL version 2. See COPYING for details.
  */
-#ifdef __KERNEL__
 
 /** ChipCommon core registers. **/
 
@@ -383,5 +382,4 @@ extern int ssb_chipco_serial_init(struct
 				  struct ssb_serial_port *ports);
 #endif /* CONFIG_SSB_SERIAL */
 
-#endif /* __KERNEL__ */
 #endif /* LINUX_SSB_CHIPCO_H_ */
include/linux/ssb/ssb_driver_extif.h +0 -3
index 278a637..00de749 100644
@@ -20,8 +20,6 @@
 #ifndef LINUX_SSB_EXTIFCORE_H_
 #define LINUX_SSB_EXTIFCORE_H_
 
-#ifdef __KERNEL__
-
 struct ssb_extif {
 	struct ssb_device *dev;
 };
@@ -159,5 +157,4 @@ #define	SSB_FLASH_WCNT_3_SHIFT		24
 #define SSB_EXTIF_WATCHDOG_CLK		48000000	/* Hz */
 
 
-#endif /* __KERNEL__ */
 #endif /* LINUX_SSB_EXTIFCORE_H_ */
include/linux/ssb/ssb_driver_mips.h +0 -3
index 91f2373..cdbb985 100644
@@ -1,8 +1,6 @@
 #ifndef LINUX_SSB_MIPSCORE_H_
 #define LINUX_SSB_MIPSCORE_H_
 
-#ifdef __KERNEL__
-
 #ifdef CONFIG_SSB_DRIVER_MIPS
 
 struct ssb_device;
@@ -43,5 +41,4 @@ void ssb_mipscore_init(struct ssb_mipsco
 
 #endif /* CONFIG_SSB_DRIVER_MIPS */
 
-#endif /* __KERNEL__ */
 #endif /* LINUX_SSB_MIPSCORE_H_ */
include/linux/ssb/ssb_driver_pci.h +0 -2
index 5132f26..9cfffb7 100644
@@ -1,6 +1,5 @@
 #ifndef LINUX_SSB_PCICORE_H_
 #define LINUX_SSB_PCICORE_H_
-#ifdef __KERNEL__
 
 #ifdef CONFIG_SSB_DRIVER_PCICORE
 
@@ -104,5 +103,4 @@ int ssb_pcicore_dev_irqvecs_enable(struc
 }
 
 #endif /* CONFIG_SSB_DRIVER_PCICORE */
-#endif /* __KERNEL__ */
 #endif /* LINUX_SSB_PCICORE_H_ */
include/linux/ssb/ssb_regs.h +5 -7
index 1fa4bf8..66751a6 100644
@@ -1,6 +1,5 @@
 #ifndef LINUX_SSB_REGS_H_
 #define LINUX_SSB_REGS_H_
-#ifdef __KERNEL__
 
 
 /* SiliconBackplane Address Map.
@@ -22,10 +21,10 @@ #define	SSB_FLASH1_SZ		0x00400000	/* Siz
 
 #define SSB_PCI_DMA		0x40000000	/* Client Mode sb2pcitranslation2 (1 GB) */
 #define SSB_PCI_DMA_SZ		0x40000000	/* Client Mode sb2pcitranslation2 size in bytes */
-#define SSB_PCIE_DMA_L32		0x00000000	/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), low 32 bits */
-#define SSB_PCIE_DMA_H32		0x80000000	/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */
-#define	SSB_EUART		(SB_EXTIF_BASE + 0x00800000)
-#define	SSB_LED			(SB_EXTIF_BASE + 0x00900000)
+#define SSB_PCIE_DMA_L32	0x00000000	/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), low 32 bits */
+#define SSB_PCIE_DMA_H32	0x80000000	/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */
+#define	SSB_EUART		(SSB_EXTIF_BASE + 0x00800000)
+#define	SSB_LED			(SSB_EXTIF_BASE + 0x00900000)
 
 
 /* Enumeration space constants */
@@ -268,7 +267,7 @@ enum {
 	SSB_SPROM1CCODE_NONE,
 };
 
-/* Address-Match values and masks (SSB_ADMATCH?) */
+/* Address-Match values and masks (SSB_ADMATCHxxx) */
 #define SSB_ADM_TYPE			0x00000003	/* Address type */
 #define  SSB_ADM_TYPE0			0
 #define  SSB_ADM_TYPE1			1
@@ -290,5 +289,4 @@ #define SSB_ADM_BASE2			0xFFFF0000	/* Ty
 #define SSB_ADM_BASE2_SHIFT		16
 
 
-#endif /* __KERNEL__ */
 #endif /* LINUX_SSB_REGS_H_ */
Signature · 1 line
Greetings Michael.