[PATCH] libertas: call SET_NETDEV_DEV from common code
authorDan Williams <dcbw@redhat.com>
Fri, 25 May 2007 17:13:25 +0000 (13:13 -0400)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 11 Jun 2007 18:28:40 +0000 (14:28 -0400)
Move usage of SET_NETDEV_DEV into common code since it has nothing
to do with bus-specific devices.  Also fixes a bug where the mesh
device was getting SET_NETDEV_DEV called after register_netdevice,
resulting in no 'device' link in /sys/class/net/mshX/.

Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/libertas/decl.h
drivers/net/wireless/libertas/if_usb.c
drivers/net/wireless/libertas/main.c

index d6fcb33..40f56bb 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef _WLAN_DECL_H_
 #define _WLAN_DECL_H_
 
+#include <linux/device.h>
+
 #include "defs.h"
 
 /** Function Prototype Declaration */
@@ -79,10 +81,10 @@ int libertas_init_fw(wlan_private * priv, char *fw_name);
 /* main.c */
 struct chan_freq_power *libertas_get_region_cfp_table(u8 region, u8 band,
                                                             int *cfp_no);
-wlan_private *libertas_add_card(void *card);
+wlan_private *libertas_add_card(void *card, struct device *dmdev);
 int libertas_activate_card(wlan_private *priv, char *fw_name);
 int libertas_remove_card(wlan_private *priv);
-int libertas_add_mesh(wlan_private *priv);
+int libertas_add_mesh(wlan_private *priv, struct device *dev);
 void libertas_remove_mesh(wlan_private *priv);
 
 
index d25e3b5..6433be6 100644 (file)
@@ -207,15 +207,10 @@ static int if_usb_probe(struct usb_interface *intf,
                }
        }
 
-
-       /* At this point libertas_add_card() will be called.  Don't worry
-        * about keeping pwlanpriv around since it will be set on our
-        * usb device data in -> add() -> hw_register_dev() -> if_usb_register_dev.
-        */
-       if (!(priv = libertas_add_card(cardp)))
+       if (!(priv = libertas_add_card(cardp, &udev->dev)))
                goto dealloc;
 
-       if (libertas_add_mesh(priv))
+       if (libertas_add_mesh(priv, &udev->dev))
                goto err_add_mesh;
 
        priv->hw_register_dev = if_usb_register_dev;
@@ -806,9 +801,6 @@ static int if_usb_register_dev(wlan_private * priv)
        cardp->eth_dev = priv->dev;
        priv->hotplug_device = &(cardp->udev->dev);
 
-       SET_NETDEV_DEV(cardp->eth_dev, &(cardp->udev->dev));
-       SET_NETDEV_DEV(priv->mesh_dev, &(cardp->udev->dev));
-
        lbs_deb_usbd(&cardp->udev->dev, "udev pointer is at %p\n",
                    cardp->udev);
 
index 0c39bcd..b05a6f9 100644 (file)
@@ -763,7 +763,7 @@ static int wlan_service_main_thread(void *data)
  *  @param card    A pointer to card
  *  @return       A pointer to wlan_private structure
  */
-wlan_private *libertas_add_card(void *card)
+wlan_private *libertas_add_card(void *card, struct device *dmdev)
 {
        struct net_device *dev = NULL;
        wlan_private *priv = NULL;
@@ -808,6 +808,8 @@ wlan_private *libertas_add_card(void *card)
        dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
        dev->set_multicast_list = wlan_set_multicast_list;
 
+       SET_NETDEV_DEV(dev, dmdev);
+
        INIT_LIST_HEAD(&priv->adapter->cmdfreeq);
        INIT_LIST_HEAD(&priv->adapter->cmdpendingq);
 
@@ -891,7 +893,7 @@ EXPORT_SYMBOL_GPL(libertas_activate_card);
  *  @param priv    A pointer to the wlan_private structure
  *  @return       0 if successful, -X otherwise
  */
-int libertas_add_mesh(wlan_private *priv)
+int libertas_add_mesh(wlan_private *priv, struct device *dev)
 {
        struct net_device *mesh_dev = NULL;
        int ret = 0;
@@ -918,6 +920,8 @@ int libertas_add_mesh(wlan_private *priv)
        memcpy(mesh_dev->dev_addr, priv->dev->dev_addr,
                        sizeof(priv->dev->dev_addr));
 
+       SET_NETDEV_DEV(priv->mesh_dev, dev);
+
 #ifdef WIRELESS_EXT
        mesh_dev->wireless_handlers = (struct iw_handler_def *)&libertas_handler_def;
 #endif