p54: unify ieee80211 device registration
authorChristian Lamparter <chunkeey@web.de>
Thu, 5 Mar 2009 20:30:10 +0000 (21:30 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 16 Mar 2009 22:09:27 +0000 (18:09 -0400)
All three drivers (p54pci, p54usb and p54spi) are implementing the
same functionality three times. So, why not put it into the shared library?!

Signed-off-by: Christian Lamparter <chunkeey@web.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/p54/p54.h
drivers/net/wireless/p54/p54common.c
drivers/net/wireless/p54/p54pci.c
drivers/net/wireless/p54/p54spi.c
drivers/net/wireless/p54/p54usb.c

index 94c3acd1fcaf41e0058e53e79537b39c3296df5c..071cbe96537773be345a0643403aa3d639d2317a 100644 (file)
@@ -165,6 +165,7 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw);
 int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len);
 int p54_read_eeprom(struct ieee80211_hw *dev);
 struct ieee80211_hw *p54_init_common(size_t priv_data_len);
+int p54_register_common(struct ieee80211_hw *dev, struct device *pdev);
 void p54_free_common(struct ieee80211_hw *dev);
 
 #endif /* P54_H */
index 14438a642fddee9e0764c83590f50842149aa924..42d1cac609a1db5fb91879a62b9acc527aff5383 100644 (file)
@@ -2489,6 +2489,21 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
 }
 EXPORT_SYMBOL_GPL(p54_init_common);
 
+int p54_register_common(struct ieee80211_hw *dev, struct device *pdev)
+{
+       int err;
+
+       err = ieee80211_register_hw(dev);
+       if (err) {
+               dev_err(pdev, "Cannot register device (%d).\n", err);
+               return err;
+       }
+
+       dev_info(pdev, "is registered as '%s'\n", wiphy_name(dev->wiphy));
+       return 0;
+}
+EXPORT_SYMBOL_GPL(p54_register_common);
+
 void p54_free_common(struct ieee80211_hw *dev)
 {
        struct p54_common *priv = dev->priv;
index 3f9a6b04ea95f34a7f1b5e8e57be4c2ead029bfe..46626e5dcbbe7fdee7b6913bf04643542c2f60b2 100644 (file)
@@ -565,12 +565,9 @@ static int __devinit p54p_probe(struct pci_dev *pdev,
        if (err)
                goto err_free_common;
 
-       err = ieee80211_register_hw(dev);
-       if (err) {
-               printk(KERN_ERR "%s (p54pci): Cannot register netdevice\n",
-                      pci_name(pdev));
+       err = p54_register_common(dev, &pdev->dev);
+       if (err)
                goto err_free_common;
-       }
 
        return 0;
 
index 7fde243b3d5d50e2c43c0e1c941590bb23904ee4..2b222aaa6f0ad0226008e2fb04714e78ba76ad45 100644 (file)
@@ -694,15 +694,10 @@ static int __devinit p54spi_probe(struct spi_device *spi)
        if (ret)
                goto err_free_common;
 
-       ret = ieee80211_register_hw(hw);
-       if (ret) {
-               dev_err(&priv->spi->dev, "unable to register "
-                                        "mac80211 hw: %d", ret);
+       ret = p54_register_common(hw, &priv->spi->dev);
+       if (ret)
                goto err_free_common;
-       }
 
-       dev_info(&priv->spi->dev, "device is bound to %s\n",
-                wiphy_name(hw->wiphy));
        return 0;
 
 err_free_common:
index 3b5e54e6793d580fa949500fef44c5a98c0648a2..da6640afc835527a98078c617872e7b63f21f1e4 100644 (file)
@@ -976,11 +976,9 @@ static int __devinit p54u_probe(struct usb_interface *intf,
        if (err)
                goto err_free_dev;
 
-       err = ieee80211_register_hw(dev);
-       if (err) {
-               dev_err(&udev->dev, "(p54usb) Cannot register netdevice\n");
+       err = p54_register_common(dev, &udev->dev);
+       if (err)
                goto err_free_dev;
-       }
 
        return 0;