Only works with kernel 2.6.24 or later. Should fix #3183

Signed-off-by: Jan Willies <[EMAIL PROTECTED]>
---
 package/p54/src/p54.h       |    4 --
 package/p54/src/p54common.c |   97 ++++++++++++++++++++++++++----------------
 package/p54/src/p54common.h |   75 --------------------------------
 package/p54/src/p54pci.c    |   99 +++++++++++++++++++++++--------------------
 package/p54/src/p54pci.h    |    4 +-
 package/p54/src/p54usb.c    |   10 +++-
 6 files changed, 123 insertions(+), 166 deletions(-)

diff --git a/package/p54/src/p54.h b/package/p54/src/p54.h
index 744c866..06d2c67 100644
--- a/package/p54/src/p54.h
+++ b/package/p54/src/p54.h
@@ -64,10 +64,6 @@ struct p54_common {
        unsigned int tx_hdr_len;
        void *cached_vdcf;
        unsigned int fw_var;
-       /* FIXME: this channels/modes/rates stuff sucks */
-       struct ieee80211_channel channels[14];
-       struct ieee80211_rate rates[12];
-       struct ieee80211_hw_mode modes[2];
        struct ieee80211_tx_queue_stats tx_stats;
 };
 
diff --git a/package/p54/src/p54common.c b/package/p54/src/p54common.c
index 2c63cf0..394dc21 100644
--- a/package/p54/src/p54common.c
+++ b/package/p54/src/p54common.c
@@ -27,6 +27,46 @@ MODULE_DESCRIPTION("Softmac Prism54 common code");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("prism54common");
 
+static struct ieee80211_rate p54_rates[] = {
+       { .bitrate = 10, .hw_value = 0, .flags = IEEE80211_RATE_SHORT_PREAMBLE 
},
+       { .bitrate = 20, .hw_value = 1, .flags = IEEE80211_RATE_SHORT_PREAMBLE 
},
+       { .bitrate = 55, .hw_value = 2, .flags = IEEE80211_RATE_SHORT_PREAMBLE 
},
+       { .bitrate = 110, .hw_value = 3, .flags = IEEE80211_RATE_SHORT_PREAMBLE 
},
+       { .bitrate = 60, .hw_value = 4, },
+       { .bitrate = 90, .hw_value = 5, },
+       { .bitrate = 120, .hw_value = 6, },
+       { .bitrate = 180, .hw_value = 7, },
+       { .bitrate = 240, .hw_value = 8, },
+       { .bitrate = 360, .hw_value = 9, },
+       { .bitrate = 480, .hw_value = 10, },
+       { .bitrate = 540, .hw_value = 11, },
+};
+
+static struct ieee80211_channel p54_channels[] = {
+       { .center_freq = 2412, .hw_value = 1, },
+       { .center_freq = 2417, .hw_value = 2, },
+       { .center_freq = 2422, .hw_value = 3, },
+       { .center_freq = 2427, .hw_value = 4, },
+       { .center_freq = 2432, .hw_value = 5, },
+       { .center_freq = 2437, .hw_value = 6, },
+       { .center_freq = 2442, .hw_value = 7, },
+       { .center_freq = 2447, .hw_value = 8, },
+       { .center_freq = 2452, .hw_value = 9, },
+       { .center_freq = 2457, .hw_value = 10, },
+       { .center_freq = 2462, .hw_value = 11, },
+       { .center_freq = 2467, .hw_value = 12, },
+       { .center_freq = 2472, .hw_value = 13, },
+       { .center_freq = 2484, .hw_value = 14, },
+};
+
+static struct ieee80211_supported_band band_2GHz = {
+       .channels = p54_channels,
+       .n_channels = ARRAY_SIZE(p54_channels),
+       .bitrates = p54_rates,
+       .n_bitrates = ARRAY_SIZE(p54_rates),
+};
+
+
 void p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw)
 {
        struct p54_common *priv = dev->priv;
@@ -54,7 +94,7 @@ void p54_parse_firmware(struct ieee80211_hw *dev, const 
struct firmware *fw)
                u32 code = le32_to_cpu(bootrec->code);
                switch (code) {
                case BR_CODE_COMPONENT_ID:
-                       switch (be32_to_cpu(*bootrec->data)) {
+                       switch (be32_to_cpu(*(__be32 *)bootrec->data)) {
                        case FW_FMAC:
                                printk(KERN_INFO "p54: FreeMAC firmware\n");
                                break;
@@ -78,14 +118,14 @@ void p54_parse_firmware(struct ieee80211_hw *dev, const 
struct firmware *fw)
                                fw_version = (unsigned char*)bootrec->data;
                        break;
                case BR_CODE_DESCR:
-                       priv->rx_start = le32_to_cpu(bootrec->data[1]);
+                       priv->rx_start = le32_to_cpu(((__le32 
*)bootrec->data)[1]);
                        /* FIXME add sanity checking */
-                       priv->rx_end = le32_to_cpu(bootrec->data[2]) - 0x3500;
+                       priv->rx_end = le32_to_cpu(((__le32 
*)bootrec->data)[2]) - 0x3500;
                        break;
                case BR_CODE_EXPOSED_IF:
                        exp_if = (struct bootrec_exp_if *) bootrec->data;
                        for (i = 0; i < (len * sizeof(*exp_if) / 4); i++)
-                               if (exp_if[i].if_id == 0x1a)
+                               if (exp_if[i].if_id == cpu_to_le16(0x1a))
                                        priv->fw_var = 
le16_to_cpu(exp_if[i].variant);
                        break;
                case BR_CODE_DEPENDENT_IF:
@@ -308,12 +348,13 @@ static void p54_rx_data(struct ieee80211_hw *dev, struct 
sk_buff *skb)
        u16 freq = le16_to_cpu(hdr->freq);
 
        rx_status.ssi = hdr->rssi;
-       rx_status.rate = hdr->rate & 0x1f; /* report short preambles & CCK too 
*/
-       rx_status.channel = freq == 2484 ? 14 : (freq - 2407)/5;
+       /* XX correct? */
+       rx_status.rate_idx = hdr->rate & 0xf;
        rx_status.freq = freq;
-       rx_status.phymode = MODE_IEEE80211G;
+       rx_status.band = IEEE80211_BAND_2GHZ;
        rx_status.antenna = hdr->antenna;
        rx_status.mactime = le64_to_cpu(hdr->timestamp);
+       rx_status.flag |= RX_FLAG_TSFT;
 
        skb_pull(skb, sizeof(*hdr));
        skb_trim(skb, le16_to_cpu(hdr->len));
@@ -348,7 +389,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, 
struct sk_buff *skb)
        while (entry != (struct sk_buff *)&priv->tx_queue) {
                range = (struct memrecord *)&entry->cb;
                if (range->start_addr == addr) {
-                       struct ieee80211_tx_status status = {{0}};
+                       struct ieee80211_tx_status status;
                        struct p54_control_hdr *entry_hdr;
                        struct p54_tx_control_allocdata *entry_data;
                        int pad = 0;
@@ -364,6 +405,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, 
struct sk_buff *skb)
                                kfree_skb(entry);
                                break;
                        }
+                       memset(&status, 0, sizeof(status));
                        memcpy(&status.control, range->control,
                               sizeof(status.control));
                        kfree(range->control);
@@ -374,7 +416,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, 
struct sk_buff *skb)
                        if ((entry_hdr->magic1 & cpu_to_le16(0x4000)) != 0)
                                pad = entry_data->align[0];
 
-                       if (!status.control.flags & IEEE80211_TXCTL_NO_ACK) {
+                       if (!(status.control.flags & IEEE80211_TXCTL_NO_ACK)) {
                                if (!(payload->status & 0x01))
                                        status.flags |= IEEE80211_TX_STATUS_ACK;
                                else
@@ -546,7 +588,9 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff 
*skb,
        txhdr->padding2 = 0;
 
        /* TODO: add support for alternate retry TX rates */
-       rate = control->tx_rate;
+       rate = control->tx_rate->hw_value;
+       if (control->flags & IEEE80211_TXCTL_SHORT_PREAMBLE)
+               rate |= 0x10;
        if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS)
                rate |= 0x40;
        else if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)
@@ -577,7 +621,7 @@ static int p54_set_filter(struct ieee80211_hw *dev, u16 
filter_type,
        struct p54_tx_control_filter *filter;
 
        hdr = kzalloc(sizeof(*hdr) + sizeof(*filter) +
-                     priv->tx_hdr_len, GFP_KERNEL);
+                     priv->tx_hdr_len, GFP_ATOMIC);
        if (!hdr)
                return -ENOMEM;
 
@@ -721,8 +765,8 @@ do {                                                        
        \
        queue.aifs = cpu_to_le16(ai_fs);                        \
        queue.cwmin = cpu_to_le16(cw_min);                      \
        queue.cwmax = cpu_to_le16(cw_max);                      \
-       queue.txop = (burst == 0) ?                             \
-               0 : cpu_to_le16((burst * 100) / 32 + 1);        \
+       queue.txop = (burst == 0) ?                             \
+               0 : cpu_to_le16((burst * 100) / 32 + 1);        \
 } while(0)
 
 static void p54_init_vdcf(struct ieee80211_hw *dev)
@@ -848,12 +892,13 @@ static int p54_config(struct ieee80211_hw *dev, struct 
ieee80211_conf *conf)
 {
        int ret;
 
-       ret = p54_set_freq(dev, cpu_to_le16(conf->freq));
+       ret = p54_set_freq(dev, cpu_to_le16(conf->channel->center_freq));
        p54_set_vdcf(dev);
        return ret;
 }
 
-static int p54_config_interface(struct ieee80211_hw *dev, int if_id,
+static int p54_config_interface(struct ieee80211_hw *dev,
+                               struct ieee80211_vif *vif,
                                struct ieee80211_if_conf *conf)
 {
        struct p54_common *priv = dev->priv;
@@ -942,7 +987,6 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
 {
        struct ieee80211_hw *dev;
        struct p54_common *priv;
-       int i;
 
        dev = ieee80211_alloc_hw(priv_data_len, &p54_ops);
        if (!dev)
@@ -951,18 +995,7 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
        priv = dev->priv;
        priv->mode = IEEE80211_IF_TYPE_INVALID;
        skb_queue_head_init(&priv->tx_queue);
-       memcpy(priv->channels, p54_channels, sizeof(p54_channels));
-       memcpy(priv->rates, p54_rates, sizeof(p54_rates));
-       priv->modes[1].mode = MODE_IEEE80211B;
-       priv->modes[1].num_rates = 4;
-       priv->modes[1].rates = priv->rates;
-       priv->modes[1].num_channels = ARRAY_SIZE(p54_channels);
-       priv->modes[1].channels = priv->channels;
-       priv->modes[0].mode = MODE_IEEE80211G;
-       priv->modes[0].num_rates = ARRAY_SIZE(p54_rates);
-       priv->modes[0].rates = priv->rates;
-       priv->modes[0].num_channels = ARRAY_SIZE(p54_channels);
-       priv->modes[0].channels = priv->channels;
+       dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz;
        dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | /* not sure */
                    IEEE80211_HW_RX_INCLUDES_FCS;
        dev->channel_change_time = 1000;        /* TODO: find actual value */
@@ -984,14 +1017,6 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
 
        p54_init_vdcf(dev);
 
-       for (i = 0; i < 2; i++) {
-               if (ieee80211_register_hwmode(dev, &priv->modes[i])) {
-                       kfree(priv->cached_vdcf);
-                       ieee80211_free_hw(dev);
-                       return NULL;
-               }
-       }
-
        return dev;
 }
 EXPORT_SYMBOL_GPL(p54_init_common);
diff --git a/package/p54/src/p54common.h b/package/p54/src/p54common.h
index a721334..dc9f4ce 100644
--- a/package/p54/src/p54common.h
+++ b/package/p54/src/p54common.h
@@ -251,79 +251,4 @@ struct p54_tx_control_vdcf {
        __le16 frameburst;
 } __attribute__ ((packed));
 
-static const struct ieee80211_rate p54_rates[] = {
-       { .rate = 10,
-         .val = 0,
-         .val2 = 0x10,
-         .flags = IEEE80211_RATE_CCK_2 },
-       { .rate = 20,
-         .val = 1,
-         .val2 = 0x11,
-         .flags = IEEE80211_RATE_CCK_2 },
-       { .rate = 55,
-         .val = 2,
-         .val2 = 0x12,
-         .flags = IEEE80211_RATE_CCK_2 },
-       { .rate = 110,
-         .val = 3,
-         .val2 = 0x13,
-         .flags = IEEE80211_RATE_CCK_2 },
-       { .rate = 60,
-         .val = 4,
-         .flags = IEEE80211_RATE_OFDM },
-       { .rate = 90,
-         .val = 5,
-         .flags = IEEE80211_RATE_OFDM },
-       { .rate = 120,
-         .val = 6,
-         .flags = IEEE80211_RATE_OFDM },
-       { .rate = 180,
-         .val = 7,
-         .flags = IEEE80211_RATE_OFDM },
-       { .rate = 240,
-         .val = 8,
-         .flags = IEEE80211_RATE_OFDM },
-       { .rate = 360,
-         .val = 9,
-         .flags = IEEE80211_RATE_OFDM },
-       { .rate = 480,
-         .val = 10,
-         .flags = IEEE80211_RATE_OFDM },
-       { .rate = 540,
-         .val = 11,
-         .flags = IEEE80211_RATE_OFDM },
-};
-
-// TODO: just generate this..
-static const struct ieee80211_channel p54_channels[] = {
-       { .chan = 1,
-         .freq = 2412},
-       { .chan = 2,
-         .freq = 2417},
-       { .chan = 3,
-         .freq = 2422},
-       { .chan = 4,
-         .freq = 2427},
-       { .chan = 5,
-         .freq = 2432},
-       { .chan = 6,
-         .freq = 2437},
-       { .chan = 7,
-         .freq = 2442},
-       { .chan = 8,
-         .freq = 2447},
-       { .chan = 9,
-         .freq = 2452},
-       { .chan = 10,
-         .freq = 2457},
-       { .chan = 11,
-         .freq = 2462},
-       { .chan = 12,
-         .freq = 2467},
-       { .chan = 13,
-         .freq = 2472},
-       { .chan = 14,
-         .freq = 2484}
-};
-
 #endif /* PRISM54COMMON_H */
diff --git a/package/p54/src/p54pci.c b/package/p54/src/p54pci.c
index 065dac7..fa52772 100644
--- a/package/p54/src/p54pci.c
+++ b/package/p54/src/p54pci.c
@@ -48,10 +48,10 @@ static int p54p_upload_firmware(struct ieee80211_hw *dev)
        const struct firmware *fw_entry = NULL;
        __le32 reg;
        int err;
-       u32 *data;
+       __le32 *data;
        u32 remains, left, device_addr;
 
-       P54P_WRITE(int_enable, 0);
+       P54P_WRITE(int_enable, cpu_to_le32(0));
        P54P_READ(int_enable);
        udelay(10);
 
@@ -82,7 +82,7 @@ static int p54p_upload_firmware(struct ieee80211_hw *dev)
 
        p54_parse_firmware(dev, fw_entry);
 
-       data = (u32 *) fw_entry->data;
+       data = (__le32 *) fw_entry->data;
        remains = fw_entry->size;
        device_addr = ISL38XX_DEV_FIRMWARE_ADDR;
        while (remains) {
@@ -141,6 +141,7 @@ static irqreturn_t p54p_simple_interrupt(int irq, void 
*dev_id)
 static int p54p_read_eeprom(struct ieee80211_hw *dev)
 {
        struct p54p_priv *priv = dev->priv;
+       struct p54p_ring_control *ring_control = priv->ring_control;
        int err;
        struct p54_control_hdr *hdr;
        void *eeprom;
@@ -164,8 +165,8 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev)
                goto out;
        }
 
-       memset(priv->ring_control, 0, sizeof(*priv->ring_control));
-       P54P_WRITE(ring_control_base, priv->ring_control_dma);
+       memset(ring_control, 0, sizeof(*ring_control));
+       P54P_WRITE(ring_control_base, cpu_to_le32(priv->ring_control_dma));
        P54P_READ(ring_control_base);
        udelay(10);
 
@@ -194,14 +195,14 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev)
        tx_mapping = pci_map_single(priv->pdev, (void *)hdr,
                                    EEPROM_READBACK_LEN, PCI_DMA_TODEVICE);
 
-       priv->ring_control->rx_mgmt[0].host_addr = cpu_to_le32(rx_mapping);
-       priv->ring_control->rx_mgmt[0].len = cpu_to_le16(0x2010);
-       priv->ring_control->tx_data[0].host_addr = cpu_to_le32(tx_mapping);
-       priv->ring_control->tx_data[0].device_addr = hdr->req_id;
-       priv->ring_control->tx_data[0].len = cpu_to_le16(EEPROM_READBACK_LEN);
+       ring_control->rx_mgmt[0].host_addr = cpu_to_le32(rx_mapping);
+       ring_control->rx_mgmt[0].len = cpu_to_le16(0x2010);
+       ring_control->tx_data[0].host_addr = cpu_to_le32(tx_mapping);
+       ring_control->tx_data[0].device_addr = hdr->req_id;
+       ring_control->tx_data[0].len = cpu_to_le16(EEPROM_READBACK_LEN);
 
-       priv->ring_control->host_idx[2] = cpu_to_le32(1);
-       priv->ring_control->host_idx[1] = cpu_to_le32(1);
+       ring_control->host_idx[2] = cpu_to_le32(1);
+       ring_control->host_idx[1] = cpu_to_le32(1);
 
        wmb();
        mdelay(100);
@@ -215,8 +216,8 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev)
        pci_unmap_single(priv->pdev, rx_mapping,
                         0x2010, PCI_DMA_FROMDEVICE);
 
-       alen = le16_to_cpu(priv->ring_control->rx_mgmt[0].len);
-       if (le32_to_cpu(priv->ring_control->device_idx[2]) != 1 ||
+       alen = le16_to_cpu(ring_control->rx_mgmt[0].len);
+       if (le32_to_cpu(ring_control->device_idx[2]) != 1 ||
            alen < 0x10) {
                printk(KERN_ERR "%s (prism54pci): Cannot read eeprom!\n",
                       pci_name(priv->pdev));
@@ -228,7 +229,7 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev)
 
  out:
        kfree(eeprom);
-       P54P_WRITE(int_enable, 0);
+       P54P_WRITE(int_enable, cpu_to_le32(0));
        P54P_READ(int_enable);
        udelay(10);
        free_irq(priv->pdev->irq, priv);
@@ -239,16 +240,17 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev)
 static void p54p_refill_rx_ring(struct ieee80211_hw *dev)
 {
        struct p54p_priv *priv = dev->priv;
+       struct p54p_ring_control *ring_control = priv->ring_control;
        u32 limit, host_idx, idx;
 
-       host_idx = le32_to_cpu(priv->ring_control->host_idx[0]);
+       host_idx = le32_to_cpu(ring_control->host_idx[0]);
        limit = host_idx;
-       limit -= le32_to_cpu(priv->ring_control->device_idx[0]);
-       limit = ARRAY_SIZE(priv->ring_control->rx_data) - limit;
+       limit -= le32_to_cpu(ring_control->device_idx[0]);
+       limit = ARRAY_SIZE(ring_control->rx_data) - limit;
 
-       idx = host_idx % ARRAY_SIZE(priv->ring_control->rx_data);
+       idx = host_idx % ARRAY_SIZE(ring_control->rx_data);
        while (limit-- > 1) {
-               struct p54p_desc *desc = &priv->ring_control->rx_data[idx];
+               struct p54p_desc *desc = &ring_control->rx_data[idx];
 
                if (!desc->host_addr) {
                        struct sk_buff *skb;
@@ -270,22 +272,23 @@ static void p54p_refill_rx_ring(struct ieee80211_hw *dev)
 
                idx++;
                host_idx++;
-               idx %= ARRAY_SIZE(priv->ring_control->rx_data);
+               idx %= ARRAY_SIZE(ring_control->rx_data);
        }
 
        wmb();
-       priv->ring_control->host_idx[0] = cpu_to_le32(host_idx);
+       ring_control->host_idx[0] = cpu_to_le32(host_idx);
 }
 
 static irqreturn_t p54p_interrupt(int irq, void *dev_id)
 {
        struct ieee80211_hw *dev = dev_id;
        struct p54p_priv *priv = dev->priv;
+       struct p54p_ring_control *ring_control = priv->ring_control;
        __le32 reg;
 
        spin_lock(&priv->lock);
        reg = P54P_READ(int_ident);
-       if (unlikely(reg == 0xFFFFFFFF)) {
+       if (unlikely(reg == cpu_to_le32(0xFFFFFFFF))) {
                spin_unlock(&priv->lock);
                return IRQ_HANDLED;
        }
@@ -298,12 +301,12 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id)
                struct p54p_desc *desc;
                u32 idx, i;
                i = priv->tx_idx;
-               i %= ARRAY_SIZE(priv->ring_control->tx_data);
-               priv->tx_idx = idx = 
le32_to_cpu(priv->ring_control->device_idx[1]);
-               idx %= ARRAY_SIZE(priv->ring_control->tx_data);
+               i %= ARRAY_SIZE(ring_control->tx_data);
+               priv->tx_idx = idx = le32_to_cpu(ring_control->device_idx[1]);
+               idx %= ARRAY_SIZE(ring_control->tx_data);
 
                while (i != idx) {
-                       desc = &priv->ring_control->tx_data[i];
+                       desc = &ring_control->tx_data[i];
                        if (priv->tx_buf[i]) {
                                kfree(priv->tx_buf[i]);
                                priv->tx_buf[i] = NULL;
@@ -318,17 +321,17 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id)
                        desc->flags = 0;
 
                        i++;
-                       i %= ARRAY_SIZE(priv->ring_control->tx_data);
+                       i %= ARRAY_SIZE(ring_control->tx_data);
                }
 
                i = priv->rx_idx;
-               i %= ARRAY_SIZE(priv->ring_control->rx_data);
-               priv->rx_idx = idx = 
le32_to_cpu(priv->ring_control->device_idx[0]);
-               idx %= ARRAY_SIZE(priv->ring_control->rx_data);
+               i %= ARRAY_SIZE(ring_control->rx_data);
+               priv->rx_idx = idx = le32_to_cpu(ring_control->device_idx[0]);
+               idx %= ARRAY_SIZE(ring_control->rx_data);
                while (i != idx) {
                        u16 len;
                        struct sk_buff *skb;
-                       desc = &priv->ring_control->rx_data[i];
+                       desc = &ring_control->rx_data[i];
                        len = le16_to_cpu(desc->len);
                        skb = priv->rx_buf[i];
 
@@ -347,7 +350,7 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id)
                        }
 
                        i++;
-                       i %= ARRAY_SIZE(priv->ring_control->rx_data);
+                       i %= ARRAY_SIZE(ring_control->rx_data);
                }
 
                p54p_refill_rx_ring(dev);
@@ -366,6 +369,7 @@ static void p54p_tx(struct ieee80211_hw *dev, struct 
p54_control_hdr *data,
                    size_t len, int free_on_tx)
 {
        struct p54p_priv *priv = dev->priv;
+       struct p54p_ring_control *ring_control = priv->ring_control;
        unsigned long flags;
        struct p54p_desc *desc;
        dma_addr_t mapping;
@@ -373,19 +377,19 @@ static void p54p_tx(struct ieee80211_hw *dev, struct 
p54_control_hdr *data,
 
        spin_lock_irqsave(&priv->lock, flags);
 
-       device_idx = le32_to_cpu(priv->ring_control->device_idx[1]);
-       idx = le32_to_cpu(priv->ring_control->host_idx[1]);
-       i = idx % ARRAY_SIZE(priv->ring_control->tx_data);
+       device_idx = le32_to_cpu(ring_control->device_idx[1]);
+       idx = le32_to_cpu(ring_control->host_idx[1]);
+       i = idx % ARRAY_SIZE(ring_control->tx_data);
 
        mapping = pci_map_single(priv->pdev, data, len, PCI_DMA_TODEVICE);
-       desc = &priv->ring_control->tx_data[i];
+       desc = &ring_control->tx_data[i];
        desc->host_addr = cpu_to_le32(mapping);
        desc->device_addr = data->req_id;
        desc->len = cpu_to_le16(len);
        desc->flags = 0;
 
        wmb();
-       priv->ring_control->host_idx[1] = cpu_to_le32(idx + 1);
+       ring_control->host_idx[1] = cpu_to_le32(idx + 1);
 
        if (free_on_tx)
                priv->tx_buf[i] = data;
@@ -397,7 +401,7 @@ static void p54p_tx(struct ieee80211_hw *dev, struct 
p54_control_hdr *data,
 
        /* FIXME: unlikely to happen because the device usually runs out of
           memory before we fill the ring up, but we can make it impossible */
-       if (idx - device_idx > ARRAY_SIZE(priv->ring_control->tx_data) - 2)
+       if (idx - device_idx > ARRAY_SIZE(ring_control->tx_data) - 2)
                printk(KERN_INFO "%s: tx overflow.\n", wiphy_name(dev->wiphy));
 }
 
@@ -421,7 +425,7 @@ static int p54p_open(struct ieee80211_hw *dev)
 
        p54p_upload_firmware(dev);
 
-       P54P_WRITE(ring_control_base, priv->ring_control_dma);
+       P54P_WRITE(ring_control_base, cpu_to_le32(priv->ring_control_dma));
        P54P_READ(ring_control_base);
        wmb();
        udelay(10);
@@ -457,10 +461,11 @@ static int p54p_open(struct ieee80211_hw *dev)
 static void p54p_stop(struct ieee80211_hw *dev)
 {
        struct p54p_priv *priv = dev->priv;
+       struct p54p_ring_control *ring_control = priv->ring_control;
        unsigned int i;
        struct p54p_desc *desc;
 
-       P54P_WRITE(int_enable, 0);
+       P54P_WRITE(int_enable, cpu_to_le32(0));
        P54P_READ(int_enable);
        udelay(10);
 
@@ -469,7 +474,7 @@ static void p54p_stop(struct ieee80211_hw *dev)
        P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET));
 
        for (i = 0; i < ARRAY_SIZE(priv->rx_buf); i++) {
-               desc = &priv->ring_control->rx_data[i];
+               desc = &ring_control->rx_data[i];
                if (desc->host_addr)
                        pci_unmap_single(priv->pdev, 
le32_to_cpu(desc->host_addr),
                                         MAX_RX_SIZE, PCI_DMA_FROMDEVICE);
@@ -478,7 +483,7 @@ static void p54p_stop(struct ieee80211_hw *dev)
        }
 
        for (i = 0; i < ARRAY_SIZE(priv->tx_buf); i++) {
-               desc = &priv->ring_control->tx_data[i];
+               desc = &ring_control->tx_data[i];
                if (desc->host_addr)
                        pci_unmap_single(priv->pdev, 
le32_to_cpu(desc->host_addr),
                                         le16_to_cpu(desc->len), 
PCI_DMA_TODEVICE);
@@ -487,7 +492,7 @@ static void p54p_stop(struct ieee80211_hw *dev)
                priv->tx_buf[i] = NULL;
        }
 
-       memset(priv->ring_control, 0, sizeof(*priv->ring_control));
+       memset(ring_control, 0, sizeof(ring_control));
 }
 
 static int __devinit p54p_probe(struct pci_dev *pdev,
@@ -497,6 +502,7 @@ static int __devinit p54p_probe(struct pci_dev *pdev,
        struct ieee80211_hw *dev;
        unsigned long mem_addr, mem_len;
        int err;
+       DECLARE_MAC_BUF(mac);
 
        err = pci_enable_device(pdev);
        if (err) {
@@ -587,8 +593,9 @@ static int __devinit p54p_probe(struct pci_dev *pdev,
                goto err_free_common;
        }
 
-       printk(KERN_INFO "%s: hwaddr " MAC_FMT ", isl38%02x\n",
-              wiphy_name(dev->wiphy), MAC_ARG(dev->wiphy->perm_addr),
+       printk(KERN_INFO "%s: hwaddr %s, isl38%02x\n",
+              wiphy_name(dev->wiphy),
+              print_mac(mac, dev->wiphy->perm_addr),
               priv->common.version);
 
        return 0;
diff --git a/package/p54/src/p54pci.h b/package/p54/src/p54pci.h
index 52feb59..5bedd7a 100644
--- a/package/p54/src/p54pci.h
+++ b/package/p54/src/p54pci.h
@@ -85,8 +85,8 @@ struct p54p_ring_control {
        struct p54p_desc tx_mgmt[4];
 } __attribute__ ((packed));
 
-#define P54P_READ(r) __raw_readl(&priv->map->r)
-#define P54P_WRITE(r, val) __raw_writel((__force u32)(val), &priv->map->r)
+#define P54P_READ(r) (__force __le32)__raw_readl(&priv->map->r)
+#define P54P_WRITE(r, val) __raw_writel((__force u32)(__le32)(val), 
&priv->map->r)
 
 struct p54p_priv {
        struct p54_common common;
diff --git a/package/p54/src/p54usb.c b/package/p54/src/p54usb.c
index 78ec616..e7d4aee 100644
--- a/package/p54/src/p54usb.c
+++ b/package/p54/src/p54usb.c
@@ -35,6 +35,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
        {USB_DEVICE(0x0707, 0xee06)},   /* SMC 2862W-G */
        {USB_DEVICE(0x083a, 0x4501)},   /* Accton 802.11g WN4501 USB */
        {USB_DEVICE(0x083a, 0x4502)},   /* Siemens Gigaset USB Adapter */
+       {USB_DEVICE(0x083a, 0x5501)},   /* Phillips CPWUA054 */
        {USB_DEVICE(0x0846, 0x4200)},   /* Netgear WG121 */
        {USB_DEVICE(0x0846, 0x4210)},   /* Netgear WG121 the second ? */
        {USB_DEVICE(0x0846, 0x4220)},   /* Netgear WG111 */
@@ -62,6 +63,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
        {USB_DEVICE(0x0cde, 0x0008)},   /* Sagem XG703A */
        {USB_DEVICE(0x0d8e, 0x3762)},   /* DLink DWL-G120 Cohiba */
        {USB_DEVICE(0x09aa, 0x1000)},   /* Spinnaker Proto board */
+       {USB_DEVICE(0x13b1, 0x000a)},   /* Linksys WUSB54G ver 2 */
        {USB_DEVICE(0x13B1, 0x000C)},   /* Linksys WUSB54AG */
        {USB_DEVICE(0x1435, 0x0427)},   /* Inventel UR054G */
        {USB_DEVICE(0x2001, 0x3704)},   /* DLink DWL-G122 rev A2 */
@@ -308,7 +310,7 @@ static int p54u_read_eeprom(struct ieee80211_hw *dev)
 
        buf = kmalloc(0x2020, GFP_KERNEL);
        if (!buf) {
-               printk(KERN_ERR "prism54usb: cannot allocate memory for"
+               printk(KERN_ERR "prism54usb: cannot allocate memory for "
                       "eeprom readback!\n");
                return -ENOMEM;
        }
@@ -783,6 +785,7 @@ static int __devinit p54u_probe(struct usb_interface *intf,
        struct p54u_priv *priv;
        int err;
        unsigned int i, recognized_pipes;
+       DECLARE_MAC_BUF(mac);
 
        dev = p54_init_common(sizeof(*priv));
        if (!dev) {
@@ -855,8 +858,9 @@ static int __devinit p54u_probe(struct usb_interface *intf,
                goto err_free_dev;
        }
 
-       printk(KERN_INFO "%s: hwaddr " MAC_FMT ", isl38%02x\n",
-              wiphy_name(dev->wiphy), MAC_ARG(dev->wiphy->perm_addr),
+       printk(KERN_INFO "%s: hwaddr %s, isl38%02x\n",
+              wiphy_name(dev->wiphy),
+              print_mac(mac, dev->wiphy->perm_addr),
               priv->common.version);
 
        return 0;
-- 
1.5.4.2

_______________________________________________
openwrt-devel mailing list
[email protected]
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to