net: convert print_mac to %pM
[linux-2.6.git] / drivers / net / wireless / p54 / p54pci.c
index fdfc718..194237b 100644 (file)
@@ -72,8 +72,6 @@ static int p54p_upload_firmware(struct ieee80211_hw *dev)
        P54P_WRITE(ctrl_stat, reg);
        wmb();
 
-       mdelay(50);
-
        err = request_firmware(&fw_entry, "isl3886", &priv->pdev->dev);
        if (err) {
                printk(KERN_ERR "%s (p54pci): cannot find firmware "
@@ -126,120 +124,10 @@ static int p54p_upload_firmware(struct ieee80211_hw *dev)
        wmb();
        udelay(10);
 
-       return 0;
-}
-
-static irqreturn_t p54p_simple_interrupt(int irq, void *dev_id)
-{
-       struct p54p_priv *priv = (struct p54p_priv *) dev_id;
-       __le32 reg;
-
-       reg = P54P_READ(int_ident);
-       P54P_WRITE(int_ack, reg);
-
-       if (reg & P54P_READ(int_enable))
-               complete(&priv->boot_comp);
-
-       return IRQ_HANDLED;
-}
-
-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;
-       dma_addr_t rx_mapping, tx_mapping;
-       u16 alen;
-
-       init_completion(&priv->boot_comp);
-       err = request_irq(priv->pdev->irq, &p54p_simple_interrupt,
-                         IRQF_SHARED, "p54pci", priv);
-       if (err) {
-               printk(KERN_ERR "%s (p54pci): failed to register IRQ handler\n",
-                      pci_name(priv->pdev));
-               return err;
-       }
-
-       eeprom = kmalloc(0x2010 + EEPROM_READBACK_LEN, GFP_KERNEL);
-       if (!eeprom) {
-               printk(KERN_ERR "%s (p54pci): no memory for eeprom!\n",
-                      pci_name(priv->pdev));
-               err = -ENOMEM;
-               goto out;
-       }
-
-       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);
-
-       P54P_WRITE(int_enable, cpu_to_le32(ISL38XX_INT_IDENT_INIT));
-       P54P_READ(int_enable);
-       udelay(10);
-
-       P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET));
-
-       if (!wait_for_completion_interruptible_timeout(&priv->boot_comp, HZ)) {
-               printk(KERN_ERR "%s (p54pci): Cannot boot firmware!\n",
-                      pci_name(priv->pdev));
-               err = -EINVAL;
-               goto out;
-       }
-
-       P54P_WRITE(int_enable, cpu_to_le32(ISL38XX_INT_IDENT_UPDATE));
-       P54P_READ(int_enable);
-
-       hdr = eeprom + 0x2010;
-       p54_fill_eeprom_readback(hdr);
-       hdr->req_id = cpu_to_le32(priv->common.rx_start);
-
-       rx_mapping = pci_map_single(priv->pdev, eeprom,
-                                   0x2010, PCI_DMA_FROMDEVICE);
-       tx_mapping = pci_map_single(priv->pdev, (void *)hdr,
-                                   EEPROM_READBACK_LEN, PCI_DMA_TODEVICE);
-
-       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);
-
-       ring_control->host_idx[2] = cpu_to_le32(1);
-       ring_control->host_idx[1] = cpu_to_le32(1);
-
-       wmb();
+       /* wait for the firmware to boot properly */
        mdelay(100);
-       P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_UPDATE));
-
-       wait_for_completion_interruptible_timeout(&priv->boot_comp, HZ);
-       wait_for_completion_interruptible_timeout(&priv->boot_comp, HZ);
-
-       pci_unmap_single(priv->pdev, tx_mapping,
-                        EEPROM_READBACK_LEN, PCI_DMA_TODEVICE);
-       pci_unmap_single(priv->pdev, rx_mapping,
-                        0x2010, PCI_DMA_FROMDEVICE);
-
-       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 (p54pci): Cannot read eeprom!\n",
-                      pci_name(priv->pdev));
-               err = -EINVAL;
-               goto out;
-       }
 
-       p54_parse_eeprom(dev, (u8 *)eeprom + 0x10, alen - 0x10);
-
- out:
-       kfree(eeprom);
-       P54P_WRITE(int_enable, cpu_to_le32(0));
-       P54P_READ(int_enable);
-       udelay(10);
-       free_irq(priv->pdev->irq, priv);
-       P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET));
-       return err;
+       return 0;
 }
 
 static void p54p_refill_rx_ring(struct ieee80211_hw *dev,
@@ -473,6 +361,11 @@ static int p54p_open(struct ieee80211_hw *dev)
        }
 
        memset(priv->ring_control, 0, sizeof(*priv->ring_control));
+       err = p54p_upload_firmware(dev);
+       if (err) {
+               free_irq(priv->pdev->irq, dev);
+               return err;
+       }
        priv->rx_idx_data = priv->tx_idx_data = 0;
        priv->rx_idx_mgmt = priv->tx_idx_mgmt = 0;
 
@@ -482,8 +375,6 @@ static int p54p_open(struct ieee80211_hw *dev)
        p54p_refill_rx_ring(dev, 2, priv->ring_control->rx_mgmt,
                ARRAY_SIZE(priv->ring_control->rx_mgmt), priv->rx_buf_mgmt);
 
-       p54p_upload_firmware(dev);
-
        P54P_WRITE(ring_control_base, cpu_to_le32(priv->ring_control_dma));
        P54P_READ(ring_control_base);
        wmb();
@@ -590,7 +481,6 @@ 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) {
@@ -658,16 +548,6 @@ static int __devinit p54p_probe(struct pci_dev *pdev,
                err = -ENOMEM;
                goto err_iounmap;
        }
-       memset(priv->ring_control, 0, sizeof(*priv->ring_control));
-
-       err = p54p_upload_firmware(dev);
-       if (err)
-               goto err_free_desc;
-
-       err = p54p_read_eeprom(dev);
-       if (err)
-               goto err_free_desc;
-
        priv->common.open = p54p_open;
        priv->common.stop = p54p_stop;
        priv->common.tx = p54p_tx;
@@ -675,6 +555,12 @@ static int __devinit p54p_probe(struct pci_dev *pdev,
        spin_lock_init(&priv->lock);
        tasklet_init(&priv->rx_tasklet, p54p_rx_tasklet, (unsigned long)dev);
 
+       p54p_open(dev);
+       err = p54_read_eeprom(dev);
+       p54p_stop(dev);
+       if (err)
+               goto err_free_desc;
+
        err = ieee80211_register_hw(dev);
        if (err) {
                printk(KERN_ERR "%s (p54pci): Cannot register netdevice\n",
@@ -682,11 +568,6 @@ static int __devinit p54p_probe(struct pci_dev *pdev,
                goto err_free_common;
        }
 
-       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;
 
  err_free_common:
@@ -734,7 +615,7 @@ static int p54p_suspend(struct pci_dev *pdev, pm_message_t state)
        struct ieee80211_hw *dev = pci_get_drvdata(pdev);
        struct p54p_priv *priv = dev->priv;
 
-       if (priv->common.mode != IEEE80211_IF_TYPE_INVALID) {
+       if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED) {
                ieee80211_stop_queues(dev);
                p54p_stop(dev);
        }
@@ -752,7 +633,7 @@ static int p54p_resume(struct pci_dev *pdev)
        pci_set_power_state(pdev, PCI_D0);
        pci_restore_state(pdev);
 
-       if (priv->common.mode != IEEE80211_IF_TYPE_INVALID) {
+       if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED) {
                p54p_open(dev);
                ieee80211_wake_queues(dev);
        }