orinoco: initialise independently of netdev
authorDavid Kilroy <kilroyd@googlemail.com>
Thu, 18 Jun 2009 22:21:24 +0000 (23:21 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 10 Jul 2009 19:01:44 +0000 (15:01 -0400)
Initialise the orinoco driver before registerring with netdev, which
will help when we get to cfg80211...

Signed-off-by: David Kilroy <kilroyd@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/orinoco/airport.c
drivers/net/wireless/orinoco/main.c
drivers/net/wireless/orinoco/orinoco.h
drivers/net/wireless/orinoco/orinoco_cs.c
drivers/net/wireless/orinoco/orinoco_nortel.c
drivers/net/wireless/orinoco/orinoco_pci.c
drivers/net/wireless/orinoco/orinoco_plx.c
drivers/net/wireless/orinoco/orinoco_tmd.c
drivers/net/wireless/orinoco/spectrum_cs.c

index 6559aee09e3b8cd212956c447cfa1864a23bade6..9f90337344f1d276e98d113f1a3932948f14f9fa 100644 (file)
@@ -234,6 +234,12 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
        }
        card->irq_requested = 1;
 
+       /* Initialise the main driver */
+       if (orinoco_init(priv) != 0) {
+               printk(KERN_ERR PFX "orinoco_init() failed\n");
+               goto failed;
+       }
+
        /* Tell the stack we exist */
        if (register_netdev(dev) != 0) {
                printk(KERN_ERR PFX "register_netdev() failed\n");
index 4fa8264a400f4b92d75ea96a855128bbc763ba31..ff869a25024df365c89bdbd2d507ec57915a7268 100644 (file)
@@ -80,6 +80,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/device.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
@@ -2073,9 +2074,9 @@ static void orinoco_unregister_pm_notifier(struct orinoco_private *priv)
 /* Initialization                                                   */
 /********************************************************************/
 
-static int orinoco_init(struct net_device *dev)
+int orinoco_init(struct orinoco_private *priv)
 {
-       struct orinoco_private *priv = netdev_priv(dev);
+       struct device *dev = priv->dev;
        hermes_t *hw = &priv->hw;
        int err = 0;
 
@@ -2086,15 +2087,14 @@ static int orinoco_init(struct net_device *dev)
        /* Initialize the firmware */
        err = hermes_init(hw);
        if (err != 0) {
-               printk(KERN_ERR "%s: failed to initialize firmware (err = %d)\n",
-                      dev->name, err);
+               dev_err(dev, "Failed to initialize firmware (err = %d)\n",
+                       err);
                goto out;
        }
 
        err = determine_fw_capabilities(priv);
        if (err != 0) {
-               printk(KERN_ERR "%s: Incompatible firmware, aborting\n",
-                      dev->name);
+               dev_err(dev, "Incompatible firmware, aborting\n");
                goto out;
        }
 
@@ -2110,27 +2110,23 @@ static int orinoco_init(struct net_device *dev)
                /* Check firmware version again */
                err = determine_fw_capabilities(priv);
                if (err != 0) {
-                       printk(KERN_ERR "%s: Incompatible firmware, aborting\n",
-                              dev->name);
+                       dev_err(dev, "Incompatible firmware, aborting\n");
                        goto out;
                }
        }
 
        if (priv->has_port3)
-               printk(KERN_DEBUG "%s: Ad-hoc demo mode supported\n",
-                      dev->name);
+               dev_info(dev, "Ad-hoc demo mode supported\n");
        if (priv->has_ibss)
-               printk(KERN_DEBUG "%s: IEEE standard IBSS ad-hoc mode supported\n",
-                      dev->name);
-       if (priv->has_wep) {
-               printk(KERN_DEBUG "%s: WEP supported, %s-bit key\n", dev->name,
-                      priv->has_big_wep ? "104" : "40");
-       }
+               dev_info(dev, "IEEE standard IBSS ad-hoc mode supported\n");
+       if (priv->has_wep)
+               dev_info(dev, "WEP supported, %s-bit key\n",
+                        priv->has_big_wep ? "104" : "40");
        if (priv->has_wpa) {
-               printk(KERN_DEBUG "%s: WPA-PSK supported\n", dev->name);
+               dev_info(dev, "WPA-PSK supported\n");
                if (orinoco_mic_init(priv)) {
-                       printk(KERN_ERR "%s: Failed to setup MIC crypto "
-                              "algorithm. Disabling WPA support\n", dev->name);
+                       dev_err(dev, "Failed to setup MIC crypto algorithm. "
+                               "Disabling WPA support\n");
                        priv->has_wpa = 0;
                }
        }
@@ -2141,14 +2137,14 @@ static int orinoco_init(struct net_device *dev)
                goto out;
        orinoco_bss_data_init(priv);
 
-       err = orinoco_hw_read_card_settings(priv, dev->dev_addr);
+       /* Netdev has not initialised, but we have allocated the buffer. */
+       err = orinoco_hw_read_card_settings(priv, priv->ndev->dev_addr);
        if (err)
                goto out;
 
        err = orinoco_hw_allocate_fid(priv);
        if (err) {
-               printk(KERN_ERR "%s: failed to allocate NIC buffer!\n",
-                      dev->name);
+               dev_err(dev, "Failed to allocate NIC buffer!\n");
                goto out;
        }
 
@@ -2174,14 +2170,14 @@ static int orinoco_init(struct net_device *dev)
        priv->hw_unavailable--;
        spin_unlock_irq(&priv->lock);
 
-       printk(KERN_DEBUG "%s: ready\n", dev->name);
+       dev_dbg(dev, "Ready\n");
 
  out:
        return err;
 }
+EXPORT_SYMBOL(orinoco_init);
 
 static const struct net_device_ops orinoco_netdev_ops = {
-       .ndo_init               = orinoco_init,
        .ndo_open               = orinoco_open,
        .ndo_stop               = orinoco_stop,
        .ndo_start_xmit         = orinoco_xmit,
index b93e86cf004917ed1b9400d40f357e44774a7bc6..2e9d33fc6b18bc9741ed5f83ded7500f49b9d019 100644 (file)
@@ -187,6 +187,7 @@ extern struct orinoco_private *alloc_orinocodev(
        int (*hard_reset)(struct orinoco_private *),
        int (*stop_fw)(struct orinoco_private *, int));
 extern void free_orinocodev(struct orinoco_private *priv);
+extern int orinoco_init(struct orinoco_private *priv);
 extern int __orinoco_up(struct orinoco_private *priv);
 extern int __orinoco_down(struct orinoco_private *priv);
 extern int orinoco_reinit_firmware(struct orinoco_private *priv);
index fa8fe5be58c92800b1dc0cd8a4e2986c947084a0..20abf021c0655fe8ed6efa6d809d2a8c9b56e2af 100644 (file)
@@ -297,6 +297,12 @@ orinoco_cs_config(struct pcmcia_device *link)
        dev->irq = link->irq.AssignedIRQ;
        card->node.major = card->node.minor = 0;
 
+       /* Initialise the main driver */
+       if (orinoco_init(priv) != 0) {
+               printk(KERN_ERR PFX "orinoco_init() failed\n");
+               goto failed;
+       }
+
        SET_NETDEV_DEV(dev, &handle_to_dev(link));
        /* Tell the stack we exist */
        if (register_netdev(dev) != 0) {
index 4efd5a0d33bd0dd6197442a843a77a068916c2b0..45cef818b292287d7d75ef0967667d1903888229 100644 (file)
@@ -217,6 +217,12 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
                goto fail;
        }
 
+       err = orinoco_init(priv);
+       if (err) {
+               printk(KERN_ERR PFX "orinoco_init() failed\n");
+               goto fail;
+       }
+
        err = register_netdev(dev);
        if (err) {
                printk(KERN_ERR PFX "Cannot register network device\n");
index 12b9c6a1bbecfbb7c25ef0abb2e6ba4451675ba0..d0eb4ae9bd127aa8c99cd136795fd22e921401f4 100644 (file)
@@ -167,6 +167,12 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
                goto fail;
        }
 
+       err = orinoco_init(priv);
+       if (err) {
+               printk(KERN_ERR PFX "orinoco_init() failed\n");
+               goto fail;
+       }
+
        err = register_netdev(dev);
        if (err) {
                printk(KERN_ERR PFX "Cannot register network device\n");
index 77d5668a9e43b924cd4e2dd1cf421cf2b80f0641..8f225d064a7b26fb1a5e4111af0b1b25538a481f 100644 (file)
@@ -256,6 +256,12 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
                goto fail;
        }
 
+       err = orinoco_init(priv);
+       if (err) {
+               printk(KERN_ERR PFX "orinoco_init() failed\n");
+               goto fail;
+       }
+
        err = register_netdev(dev);
        if (err) {
                printk(KERN_ERR PFX "Cannot register network device\n");
index 5f24c0332de9227bb8e493a6e69ae4282c3af8a5..3c04faee7ae6a8958151117c2f5f213ecf9a50fb 100644 (file)
@@ -153,6 +153,12 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
                goto fail;
        }
 
+       err = orinoco_init(priv);
+       if (err) {
+               printk(KERN_ERR PFX "orinoco_init() failed\n");
+               goto fail;
+       }
+
        err = register_netdev(dev);
        if (err) {
                printk(KERN_ERR PFX "Cannot register network device\n");
index ce909e40329a611948d39cec340555e6d0ffd358..43e1aed4e4b28c33e3a6054eea55552edc49e3b4 100644 (file)
@@ -368,6 +368,12 @@ spectrum_cs_config(struct pcmcia_device *link)
        if (spectrum_cs_hard_reset(priv) != 0)
                goto failed;
 
+       /* Initialise the main driver */
+       if (orinoco_init(priv) != 0) {
+               printk(KERN_ERR PFX "orinoco_init() failed\n");
+               goto failed;
+       }
+
        SET_NETDEV_DEV(dev, &handle_to_dev(link));
        /* Tell the stack we exist */
        if (register_netdev(dev) != 0) {