patch-2.4.21 linux-2.4.21/drivers/net/wireless/airport.c

Next file: linux-2.4.21/drivers/net/wireless/hermes.c
Previous file: linux-2.4.21/drivers/net/wireless/airo.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.20/drivers/net/wireless/airport.c linux-2.4.21/drivers/net/wireless/airport.c
@@ -1,4 +1,4 @@
-/* airport.c 0.11b
+/* airport.c 0.13b
  *
  * A driver for "Hermes" chipset based Apple Airport wireless
  * card.
@@ -25,12 +25,10 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/system.h>
-#include <linux/proc_fs.h>
 #include <linux/netdevice.h>
 #include <linux/if_arp.h>
 #include <linux/etherdevice.h>
 #include <linux/wireless.h>
-#include <linux/list.h>
 #include <linux/adb.h>
 #include <linux/pmu.h>
 
@@ -39,23 +37,15 @@
 #include <asm/pmac_feature.h>
 #include <asm/irq.h>
 
-#include "hermes.h"
 #include "orinoco.h"
 
-static char version[] __initdata = "airport.c 0.11b (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
-MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
-MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
-MODULE_LICENSE("Dual MPL/GPL");
-EXPORT_NO_SYMBOLS;
-
 #define AIRPORT_IO_LEN	(0x1000)	/* one page */
 
 struct airport {
-	struct device_node* node;
+	struct device_node *node;
 	void *vaddr;
 	int irq_requested;
 	int ndev_registered;
-	int open;
 };
 
 #ifdef CONFIG_PMAC_PBOOK
@@ -71,109 +61,99 @@
 
 static struct net_device *airport_attach(struct device_node *of_node);
 static void airport_detach(struct net_device *dev);
-static int airport_open(struct net_device *dev);
-static int airport_stop(struct net_device *dev);
-
-/*
-   A linked list of "instances" of the dummy device.  Each actual
-   PCMCIA card corresponds to one device instance, and is described
-   by one dev_link_t structure (defined in ds.h).
-
-   You may not want to use a linked list for this -- for example, the
-   memory card driver uses an array of dev_link_t pointers, where minor
-   device numbers are used to derive the corresponding array index.
-*/
 
 static struct net_device *airport_dev;
 
-static int
-airport_open(struct net_device *dev)
-{
-	struct orinoco_private *priv = dev->priv;
-	struct airport* card = (struct airport *)priv->card;
-	int rc;
-
-	TRACE_ENTER(dev->name);
-
-	netif_device_attach(dev);
-
-	rc = orinoco_reset(priv);
-	if (rc)
-		airport_stop(dev);
-	else {
-		card->open = 1;
-		netif_start_queue(dev);
-	}
-
-	TRACE_EXIT(dev->name);
-
-	return rc;
-}
-
-static int
-airport_stop(struct net_device *dev)
-{
-	struct orinoco_private *priv = dev->priv;
-	struct airport* card = (struct airport *)priv->card;
-
-	TRACE_ENTER(dev->name);
-
-	netif_stop_queue(dev);
-	orinoco_shutdown(priv);
-	card->open = 0;
-
-	TRACE_EXIT(dev->name);
-
-	return 0;
-}
-
 #ifdef CONFIG_PMAC_PBOOK
 static int
 airport_sleep_notify(struct pmu_sleep_notifier *self, int when)
 {
 	struct net_device *dev = airport_dev;
-	struct orinoco_private *priv = (struct orinoco_private *)dev->priv;
-	struct hermes *hw = &priv->hw;
-	struct airport* card = (struct airport *)priv->card;
-	int rc;
+	struct orinoco_private *priv = dev->priv;
+	struct airport *card = priv->card;
+	unsigned long flags;
+	int err;
 	
 	if (! airport_dev)
 		return PBOOK_SLEEP_OK;
 
 	switch (when) {
-	case PBOOK_SLEEP_REQUEST:
-		break;
-	case PBOOK_SLEEP_REJECT:
-		break;
 	case PBOOK_SLEEP_NOW:
-		printk(KERN_INFO "%s: Airport entering sleep mode\n", dev->name);
-		if (card->open) {
-			netif_stop_queue(dev);
-			orinoco_shutdown(priv);
-			netif_device_detach(dev);
+		printk(KERN_DEBUG "%s: Airport entering sleep mode\n", dev->name);
+
+		err = orinoco_lock(priv, &flags);
+		if (err) {
+			printk(KERN_ERR "%s: hw_unavailable on PBOOK_SLEEP_NOW\n",
+			       dev->name);
+			break;
 		}
+
+		err = __orinoco_down(dev);
+		if (err)
+			printk(KERN_WARNING "%s: PBOOK_SLEEP_NOW: Error %d downing interface\n",
+			       dev->name, err);
+
+		netif_device_detach(dev);
+
+		priv->hw_unavailable = 1;
+
+		orinoco_unlock(priv, &flags);
+
 		disable_irq(dev->irq);
 		pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
 		break;
+
 	case PBOOK_WAKE:
-		printk(KERN_INFO "%s: Airport waking up\n", dev->name);
+		printk(KERN_DEBUG "%s: Airport waking up\n", dev->name);
 		pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 1);
 		mdelay(200);
-		hermes_reset(hw);
-		rc = orinoco_reset(priv);
-		if (rc)
-			printk(KERN_ERR "airport: Error %d re-initing card !\n", rc);
-		else if (card->open)
-			netif_device_attach(dev);
+
 		enable_irq(dev->irq);
+
+		err = orinoco_reinit_firmware(dev);
+		if (err) {
+			printk(KERN_ERR "%s: Error %d re-initializing firmware on PBOOK_WAKE\n",
+			       dev->name, err);
+			break;
+		}
+
+		spin_lock_irqsave(&priv->lock, flags);
+
+		netif_device_attach(dev);
+
+		if (priv->open) {
+			err = __orinoco_up(dev);
+			if (err)
+				printk(KERN_ERR "%s: Error %d restarting card on PBOOK_WAKE\n",
+				       dev->name, err);
+		}
+
+		priv->hw_unavailable = 0;
+
+		spin_unlock_irqrestore(&priv->lock, flags);
+
 		break;
 	}
 	return PBOOK_SLEEP_OK;
 }
 #endif /* CONFIG_PMAC_PBOOK */
 
+static int airport_hard_reset(struct orinoco_private *priv)
+{
+	struct airport *card = priv->card;
+
+	pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
+	current->state = TASK_UNINTERRUPTIBLE;
+	schedule_timeout(HZ);
+	pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 1);
+	current->state = TASK_UNINTERRUPTIBLE;
+	schedule_timeout(HZ);
+
+	return 0;
+}
+
 static struct net_device *
-airport_attach(struct device_node* of_node)
+airport_attach(struct device_node *of_node)
 {
 	struct orinoco_private *priv;
 	struct net_device *dev;
@@ -181,15 +161,13 @@
 	unsigned long phys_addr;
 	hermes_t *hw;
 
-	TRACE_ENTER("orinoco");
-
 	if (of_node->n_addrs < 1 || of_node->n_intrs < 1) {
 		printk(KERN_ERR "airport: wrong interrupt/addresses in OF tree\n");
 		return NULL;
 	}
 
 	/* Allocate space for private device-specific data */
-	dev = alloc_orinocodev(sizeof(*card));
+	dev = alloc_orinocodev(sizeof(*card), airport_hard_reset);
 	if (! dev) {
 		printk(KERN_ERR "airport: can't allocate device datas\n");
 		return NULL;
@@ -205,17 +183,14 @@
 		kfree(dev);
 		return NULL;
 	}
-	
+
 	dev->name[0] = '\0';	/* register_netdev will give us an ethX name */
 	SET_MODULE_OWNER(dev);
 
-	/* Overrides */
-	dev->open = airport_open;
-	dev->stop = airport_stop;
-
 	/* Setup interrupts & base address */
 	dev->irq = of_node->intrs[0].line;
-	phys_addr = of_node->addrs[0].address; /* Physical address */
+	phys_addr = of_node->addrs[0].address;  /* Physical address */
+	printk(KERN_DEBUG "Airport at physical address %lx\n", phys_addr);
 	dev->base_addr = phys_addr;
 	card->vaddr = ioremap(phys_addr, AIRPORT_IO_LEN);
 	if (! card->vaddr) {
@@ -232,14 +207,14 @@
 	schedule_timeout(HZ);
 
 	/* Reset it before we get the interrupt */
-	hermes_reset(hw);
+	hermes_init(hw);
 
 	if (request_irq(dev->irq, orinoco_interrupt, 0, "Airport", (void *)priv)) {
 		printk(KERN_ERR "airport: Couldn't get IRQ %d\n", dev->irq);
 		goto failed;
 	}
 	card->irq_requested = 1;
-	
+
 	/* Tell the stack we exist */
 	if (register_netdev(dev) != 0) {
 		printk(KERN_ERR "airport: register_netdev() failed\n");
@@ -248,17 +223,12 @@
 	printk(KERN_DEBUG "airport: card registered for interface %s\n", dev->name);
 	card->ndev_registered = 1;
 
-	/* And give us the proc nodes for debugging */
-	if (orinoco_proc_dev_init(priv) != 0)
-		printk(KERN_ERR "airport: Failed to create /proc node for %s\n",
-		       dev->name);
-
 #ifdef CONFIG_PMAC_PBOOK
 	pmu_register_sleep_notifier(&airport_sleep_notifier);
 #endif
 	return dev;
 	
-failed:
+ failed:
 	airport_detach(dev);
 	return NULL;
 }				/* airport_attach */
@@ -273,16 +243,13 @@
 	struct orinoco_private *priv = dev->priv;
 	struct airport *card = priv->card;
 
-	/* Unregister proc entry */
-	orinoco_proc_dev_cleanup(priv);
-
 #ifdef CONFIG_PMAC_PBOOK
 	pmu_unregister_sleep_notifier(&airport_sleep_notifier);
 #endif
 	if (card->ndev_registered)
 		unregister_netdev(dev);
 	card->ndev_registered = 0;
-	
+
 	if (card->irq_requested)
 		free_irq(dev->irq, priv);
 	card->irq_requested = 0;
@@ -290,22 +257,28 @@
 	if (card->vaddr)
 		iounmap(card->vaddr);
 	card->vaddr = 0;
-	
+
 	dev->base_addr = 0;
 
 	release_OF_resource(card->node, 0);
-	
+
 	pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, card->node, 0, 0);
 	current->state = TASK_UNINTERRUPTIBLE;
 	schedule_timeout(HZ);
-	
+
 	kfree(dev);
 }				/* airport_detach */
 
+static char version[] __initdata = "airport.c 0.13b (Benjamin Herrenschmidt <benh@kernel.crashing.org>)";
+MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
+MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
+MODULE_LICENSE("Dual MPL/GPL");
+EXPORT_NO_SYMBOLS;
+
 static int __init
 init_airport(void)
 {
-	struct device_node* airport_node;
+	struct device_node *airport_node;
 
 	printk(KERN_DEBUG "%s\n", version);
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)