headers: remove sched.h from interrupt.h
[safe/jmp/linux-2.6] / drivers / net / wireless / prism54 / islpci_dev.c
index 1e0603c..2505be5 100644 (file)
@@ -21,7 +21,9 @@
 #include <linux/module.h>
 
 #include <linux/netdevice.h>
+#include <linux/ethtool.h>
 #include <linux/pci.h>
+#include <linux/sched.h>
 #include <linux/etherdevice.h>
 #include <linux/delay.h>
 #include <linux/if_arp.h>
@@ -42,7 +44,6 @@
 
 static int prism54_bring_down(islpci_private *);
 static int islpci_alloc_memory(islpci_private *);
-static struct net_device_stats *islpci_statistics(struct net_device *);
 
 /* Temporary dummy MAC address to use until firmware is loaded.
  * The idea there is that some tools (such as nameif) may query
@@ -114,7 +115,7 @@ isl_upload_firmware(islpci_private *priv)
                            ISL38XX_MEMORY_WINDOW_SIZE : fw_len;
                        u32 __iomem *dev_fw_ptr = device_base + ISL38XX_DIRECT_MEM_WIN;
 
-                       /* set the cards base address for writting the data */
+                       /* set the card's base address for writing the data */
                        isl38xx_w32_flush(device_base, reg,
                                          ISL38XX_DIR_MEM_BASE_REG);
                        wmb();  /* be paranoid */
@@ -386,7 +387,16 @@ islpci_open(struct net_device *ndev)
        }
 
        netif_start_queue(ndev);
-/*      netif_mark_up( ndev ); */
+
+       /* Turn off carrier if in STA or Ad-hoc mode. It will be turned on
+        * once the firmware receives a trap of being associated
+        * (GEN_OID_LINKSTATE). In other modes (AP or WDS or monitor) we
+        * should just leave the carrier on as its expected the firmware
+        * won't send us a trigger. */
+       if (priv->iw_mode == IW_MODE_INFRA || priv->iw_mode == IW_MODE_ADHOC)
+               netif_carrier_off(ndev);
+       else
+               netif_carrier_on(ndev);
 
        return 0;
 }
@@ -604,18 +614,6 @@ islpci_reset(islpci_private *priv, int reload_firmware)
        return rc;
 }
 
-static struct net_device_stats *
-islpci_statistics(struct net_device *ndev)
-{
-       islpci_private *priv = netdev_priv(ndev);
-
-#if VERBOSE > SHOW_ERROR_MESSAGES
-       DEBUG(SHOW_FUNCTION_CALLS, "islpci_statistics\n");
-#endif
-
-       return &priv->statistics;
-}
-
 /******************************************************************************
     Network device configuration functions
 ******************************************************************************/
@@ -787,6 +785,28 @@ islpci_set_multicast_list(struct net_device *dev)
 }
 #endif
 
+static void islpci_ethtool_get_drvinfo(struct net_device *dev,
+                                       struct ethtool_drvinfo *info)
+{
+       strcpy(info->driver, DRV_NAME);
+       strcpy(info->version, DRV_VERSION);
+}
+
+static const struct ethtool_ops islpci_ethtool_ops = {
+       .get_drvinfo = islpci_ethtool_get_drvinfo,
+};
+
+static const struct net_device_ops islpci_netdev_ops = {
+       .ndo_open               = islpci_open,
+       .ndo_stop               = islpci_close,
+       .ndo_do_ioctl           = prism54_ioctl,
+       .ndo_start_xmit         = islpci_eth_transmit,
+       .ndo_tx_timeout         = islpci_eth_tx_timeout,
+       .ndo_set_mac_address    = prism54_set_mac_address,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 struct net_device *
 islpci_setup(struct pci_dev *pdev)
 {
@@ -796,7 +816,6 @@ islpci_setup(struct pci_dev *pdev)
        if (!ndev)
                return ndev;
 
-       SET_MODULE_OWNER(ndev);
        pci_set_drvdata(pdev, ndev);
 #if defined(SET_NETDEV_DEV)
        SET_NETDEV_DEV(ndev, &pdev->dev);
@@ -807,24 +826,16 @@ islpci_setup(struct pci_dev *pdev)
        ndev->irq = pdev->irq;
 
        /* initialize the function pointers */
-       ndev->open = &islpci_open;
-       ndev->stop = &islpci_close;
-       ndev->get_stats = &islpci_statistics;
-       ndev->do_ioctl = &prism54_ioctl;
-       ndev->wireless_handlers =
-           (struct iw_handler_def *) &prism54_handler_def;
-
-       ndev->hard_start_xmit = &islpci_eth_transmit;
+       ndev->netdev_ops = &islpci_netdev_ops;
+       ndev->wireless_handlers = &prism54_handler_def;
+       ndev->ethtool_ops = &islpci_ethtool_ops;
+
        /* ndev->set_multicast_list = &islpci_set_multicast_list; */
        ndev->addr_len = ETH_ALEN;
-       ndev->set_mac_address = &prism54_set_mac_address;
        /* Get a non-zero dummy MAC address for nameif. Jean II */
        memcpy(ndev->dev_addr, dummy_mac, 6);
 
-#ifdef HAVE_TX_TIMEOUT
        ndev->watchdog_timeo = ISLPCI_TX_TIMEOUT;
-       ndev->tx_timeout = &islpci_eth_tx_timeout;
-#endif
 
        /* allocate a private device structure to the network device  */
        priv = netdev_priv(ndev);
@@ -849,10 +860,10 @@ islpci_setup(struct pci_dev *pdev)
        init_waitqueue_head(&priv->reset_done);
 
        /* init the queue read locks, process wait counter */
-       sema_init(&priv->mgmt_sem, 1);
+       mutex_init(&priv->mgmt_lock);
        priv->mgmt_received = NULL;
        init_waitqueue_head(&priv->mgmt_wqueue);
-       sema_init(&priv->stats_sem, 1);
+       mutex_init(&priv->stats_lock);
        spin_lock_init(&priv->slock);
 
        /* init state machine with off#1 state */
@@ -860,11 +871,10 @@ islpci_setup(struct pci_dev *pdev)
        priv->state_off = 1;
 
        /* initialize workqueue's */
-       INIT_WORK(&priv->stats_work,
-                 (void (*)(void *)) prism54_update_stats, priv);
+       INIT_WORK(&priv->stats_work, prism54_update_stats);
        priv->stats_timestamp = 0;
 
-       INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake, priv);
+       INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake);
        priv->reset_task_pending = 0;
 
        /* allocate various memory areas */