]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/net/wireless/b43/pio.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu
[mv-sheeva.git] / drivers / net / wireless / b43 / pio.c
index 9c1397996e0a57753e97f372bce2ad1296abcbb9..c01b8e02412f80b64f13c86cfb812bb3db03051d 100644 (file)
@@ -30,6 +30,7 @@
 #include "xmit.h"
 
 #include <linux/delay.h>
+#include <linux/sched.h>
 
 
 static u16 generate_cookie(struct b43_pio_txqueue *q,
@@ -331,6 +332,7 @@ static u16 tx_write_2byte_queue(struct b43_pio_txqueue *q,
                                unsigned int data_len)
 {
        struct b43_wldev *dev = q->dev;
+       struct b43_wl *wl = dev->wl;
        const u8 *data = _data;
 
        ctl |= B43_PIO_TXCTL_WRITELO | B43_PIO_TXCTL_WRITEHI;
@@ -340,12 +342,14 @@ static u16 tx_write_2byte_queue(struct b43_pio_txqueue *q,
                        q->mmio_base + B43_PIO_TXDATA,
                        sizeof(u16));
        if (data_len & 1) {
-               u8 tail[2] = { 0, };
+               u8 *tail = wl->pio_tailspace;
+               BUILD_BUG_ON(sizeof(wl->pio_tailspace) < 2);
 
                /* Write the last byte. */
                ctl &= ~B43_PIO_TXCTL_WRITEHI;
                b43_piotx_write16(q, B43_PIO_TXCTL, ctl);
                tail[0] = data[data_len - 1];
+               tail[1] = 0;
                ssb_block_write(dev->dev, tail, 2,
                                q->mmio_base + B43_PIO_TXDATA,
                                sizeof(u16));
@@ -381,6 +385,7 @@ static u32 tx_write_4byte_queue(struct b43_pio_txqueue *q,
                                unsigned int data_len)
 {
        struct b43_wldev *dev = q->dev;
+       struct b43_wl *wl = dev->wl;
        const u8 *data = _data;
 
        ctl |= B43_PIO8_TXCTL_0_7 | B43_PIO8_TXCTL_8_15 |
@@ -391,8 +396,10 @@ static u32 tx_write_4byte_queue(struct b43_pio_txqueue *q,
                        q->mmio_base + B43_PIO8_TXDATA,
                        sizeof(u32));
        if (data_len & 3) {
-               u8 tail[4] = { 0, };
+               u8 *tail = wl->pio_tailspace;
+               BUILD_BUG_ON(sizeof(wl->pio_tailspace) < 4);
 
+               memset(tail, 0, 4);
                /* Write the last few bytes. */
                ctl &= ~(B43_PIO8_TXCTL_8_15 | B43_PIO8_TXCTL_16_23 |
                         B43_PIO8_TXCTL_24_31);
@@ -445,20 +452,24 @@ static void pio_tx_frame_4byte_queue(struct b43_pio_txpacket *pack,
 static int pio_tx_frame(struct b43_pio_txqueue *q,
                        struct sk_buff *skb)
 {
+       struct b43_wldev *dev = q->dev;
+       struct b43_wl *wl = dev->wl;
        struct b43_pio_txpacket *pack;
-       struct b43_txhdr txhdr;
        u16 cookie;
        int err;
        unsigned int hdrlen;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+       struct b43_txhdr *txhdr = (struct b43_txhdr *)wl->pio_scratchspace;
 
        B43_WARN_ON(list_empty(&q->packets_list));
        pack = list_entry(q->packets_list.next,
                          struct b43_pio_txpacket, list);
 
        cookie = generate_cookie(q, pack);
-       hdrlen = b43_txhdr_size(q->dev);
-       err = b43_generate_txhdr(q->dev, (u8 *)&txhdr, skb,
+       hdrlen = b43_txhdr_size(dev);
+       BUILD_BUG_ON(sizeof(wl->pio_scratchspace) < sizeof(struct b43_txhdr));
+       B43_WARN_ON(sizeof(wl->pio_scratchspace) < hdrlen);
+       err = b43_generate_txhdr(dev, (u8 *)txhdr, skb,
                                 info, cookie);
        if (err)
                return err;
@@ -466,15 +477,15 @@ static int pio_tx_frame(struct b43_pio_txqueue *q,
        if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) {
                /* Tell the firmware about the cookie of the last
                 * mcast frame, so it can clear the more-data bit in it. */
-               b43_shm_write16(q->dev, B43_SHM_SHARED,
+               b43_shm_write16(dev, B43_SHM_SHARED,
                                B43_SHM_SH_MCASTCOOKIE, cookie);
        }
 
        pack->skb = skb;
        if (q->rev >= 8)
-               pio_tx_frame_4byte_queue(pack, (const u8 *)&txhdr, hdrlen);
+               pio_tx_frame_4byte_queue(pack, (const u8 *)txhdr, hdrlen);
        else
-               pio_tx_frame_2byte_queue(pack, (const u8 *)&txhdr, hdrlen);
+               pio_tx_frame_2byte_queue(pack, (const u8 *)txhdr, hdrlen);
 
        /* Remove it from the list of available packet slots.
         * It will be put back when we receive the status report. */
@@ -614,14 +625,17 @@ void b43_pio_get_tx_stats(struct b43_wldev *dev,
 static bool pio_rx_frame(struct b43_pio_rxqueue *q)
 {
        struct b43_wldev *dev = q->dev;
-       struct b43_rxhdr_fw4 rxhdr;
+       struct b43_wl *wl = dev->wl;
        u16 len;
        u32 macstat;
        unsigned int i, padding;
        struct sk_buff *skb;
        const char *err_msg = NULL;
+       struct b43_rxhdr_fw4 *rxhdr =
+               (struct b43_rxhdr_fw4 *)wl->pio_scratchspace;
 
-       memset(&rxhdr, 0, sizeof(rxhdr));
+       BUILD_BUG_ON(sizeof(wl->pio_scratchspace) < sizeof(*rxhdr));
+       memset(rxhdr, 0, sizeof(*rxhdr));
 
        /* Check if we have data and wait for it to get ready. */
        if (q->rev >= 8) {
@@ -659,16 +673,16 @@ data_ready:
 
        /* Get the preamble (RX header) */
        if (q->rev >= 8) {
-               ssb_block_read(dev->dev, &rxhdr, sizeof(rxhdr),
+               ssb_block_read(dev->dev, rxhdr, sizeof(*rxhdr),
                               q->mmio_base + B43_PIO8_RXDATA,
                               sizeof(u32));
        } else {
-               ssb_block_read(dev->dev, &rxhdr, sizeof(rxhdr),
+               ssb_block_read(dev->dev, rxhdr, sizeof(*rxhdr),
                               q->mmio_base + B43_PIO_RXDATA,
                               sizeof(u16));
        }
        /* Sanity checks. */
-       len = le16_to_cpu(rxhdr.frame_len);
+       len = le16_to_cpu(rxhdr->frame_len);
        if (unlikely(len > 0x700)) {
                err_msg = "len > 0x700";
                goto rx_error;
@@ -678,7 +692,7 @@ data_ready:
                goto rx_error;
        }
 
-       macstat = le32_to_cpu(rxhdr.mac_status);
+       macstat = le32_to_cpu(rxhdr->mac_status);
        if (macstat & B43_RX_MAC_FCSERR) {
                if (!(q->dev->wl->filter_flags & FIF_FCSFAIL)) {
                        /* Drop frames with failed FCS. */
@@ -703,7 +717,8 @@ data_ready:
                               q->mmio_base + B43_PIO8_RXDATA,
                               sizeof(u32));
                if (len & 3) {
-                       u8 tail[4] = { 0, };
+                       u8 *tail = wl->pio_tailspace;
+                       BUILD_BUG_ON(sizeof(wl->pio_tailspace) < 4);
 
                        /* Read the last few bytes. */
                        ssb_block_read(dev->dev, tail, 4,
@@ -729,7 +744,8 @@ data_ready:
                               q->mmio_base + B43_PIO_RXDATA,
                               sizeof(u16));
                if (len & 1) {
-                       u8 tail[2] = { 0, };
+                       u8 *tail = wl->pio_tailspace;
+                       BUILD_BUG_ON(sizeof(wl->pio_tailspace) < 2);
 
                        /* Read the last byte. */
                        ssb_block_read(dev->dev, tail, 2,
@@ -739,14 +755,18 @@ data_ready:
                }
        }
 
-       b43_rx(q->dev, skb, &rxhdr);
+       b43_rx(q->dev, skb, rxhdr);
 
        return 1;
 
 rx_error:
        if (err_msg)
                b43dbg(q->dev->wl, "PIO RX error: %s\n", err_msg);
-       b43_piorx_write16(q, B43_PIO_RXCTL, B43_PIO_RXCTL_DATARDY);
+       if (q->rev >= 8)
+               b43_piorx_write32(q, B43_PIO8_RXCTL, B43_PIO8_RXCTL_DATARDY);
+       else
+               b43_piorx_write16(q, B43_PIO_RXCTL, B43_PIO_RXCTL_DATARDY);
+
        return 1;
 }