1 /* $Header: /var/lib/cvs/prism54-ng/ksrc/islpci_dev.c,v 1.68 2004/02/28 03:06:07 mcgrof Exp $
3 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/version.h>
23 #include <linux/module.h>
25 #include <linux/netdevice.h>
26 #include <linux/pci.h>
27 #include <linux/etherdevice.h>
28 #include <linux/delay.h>
29 #include <linux/if_arp.h>
34 #include "isl_ioctl.h"
35 #include "islpci_dev.h"
36 #include "islpci_mgt.h"
37 #include "islpci_eth.h"
40 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)
41 #define prism54_synchronize_irq(irq) synchronize_irq()
43 #define prism54_synchronize_irq(irq) synchronize_irq(irq)
46 #define ISL3877_IMAGE_FILE "isl3877"
47 #define ISL3890_IMAGE_FILE "isl3890"
49 /* Temporary dummy MAC address to use until firmware is loaded.
50 * The idea there is that some tools (such as nameif) may query
51 * the MAC address before the netdev is 'open'. By using a valid
52 * OUI prefix, they can process the netdev properly.
53 * Of course, this is not the final/real MAC address. It doesn't
54 * matter, as you are suppose to be able to change it anytime via
55 * ndev->set_mac_address. Jean II */
56 const unsigned char dummy_mac[6] = { 0x00, 0x30, 0xB4, 0x00, 0x00, 0x00 };
58 /******************************************************************************
59 Device Interrupt Handler
60 ******************************************************************************/
63 islpci_interrupt(int irq, void *config, struct pt_regs *regs)
66 islpci_private *priv = config;
67 struct net_device *ndev = priv->ndev;
68 void *device = priv->device_base;
69 int powerstate = ISL38XX_PSM_POWERSAVE_STATE;
71 /* received an interrupt request on a shared IRQ line
72 * first check whether the device is in sleep mode */
73 reg = readl(device + ISL38XX_CTRL_STAT_REG);
74 if (reg & ISL38XX_CTRL_STAT_SLEEPMODE)
75 /* device is in sleep mode, IRQ was generated by someone else */
77 printk(KERN_DEBUG "Assuming someone else called the IRQ\n");
81 if (islpci_get_state(priv) != PRV_STATE_SLEEP)
82 powerstate = ISL38XX_PSM_ACTIVE_STATE;
84 /* lock the interrupt handler */
85 spin_lock(&priv->slock);
87 /* check whether there is any source of interrupt on the device */
88 reg = readl(device + ISL38XX_INT_IDENT_REG);
90 /* also check the contents of the Interrupt Enable Register, because this
91 * will filter out interrupt sources from other devices on the same irq ! */
92 reg &= readl(device + ISL38XX_INT_EN_REG);
93 reg &= ISL38XX_INT_SOURCES;
96 /* reset the request bits in the Identification register */
97 isl38xx_w32_flush(device, reg, ISL38XX_INT_ACK_REG);
99 #if VERBOSE > SHOW_ERROR_MESSAGES
100 DEBUG(SHOW_FUNCTION_CALLS,
101 "IRQ: Identification register 0x%p 0x%x \n", device, reg);
104 /* check for each bit in the register separately */
105 if (reg & ISL38XX_INT_IDENT_UPDATE) {
106 #if VERBOSE > SHOW_ERROR_MESSAGES
107 /* Queue has been updated */
108 DEBUG(SHOW_TRACING, "IRQ: Update flag \n");
110 DEBUG(SHOW_QUEUE_INDEXES,
111 "CB drv Qs: [%i][%i][%i][%i][%i][%i]\n",
112 le32_to_cpu(priv->control_block->
113 driver_curr_frag[0]),
114 le32_to_cpu(priv->control_block->
115 driver_curr_frag[1]),
116 le32_to_cpu(priv->control_block->
117 driver_curr_frag[2]),
118 le32_to_cpu(priv->control_block->
119 driver_curr_frag[3]),
120 le32_to_cpu(priv->control_block->
121 driver_curr_frag[4]),
122 le32_to_cpu(priv->control_block->
126 DEBUG(SHOW_QUEUE_INDEXES,
127 "CB dev Qs: [%i][%i][%i][%i][%i][%i]\n",
128 le32_to_cpu(priv->control_block->
129 device_curr_frag[0]),
130 le32_to_cpu(priv->control_block->
131 device_curr_frag[1]),
132 le32_to_cpu(priv->control_block->
133 device_curr_frag[2]),
134 le32_to_cpu(priv->control_block->
135 device_curr_frag[3]),
136 le32_to_cpu(priv->control_block->
137 device_curr_frag[4]),
138 le32_to_cpu(priv->control_block->
143 /* cleanup the data low transmit queue */
144 islpci_eth_cleanup_transmit(priv, priv->control_block);
146 /* device is in active state, update the
147 * powerstate flag if necessary */
148 powerstate = ISL38XX_PSM_ACTIVE_STATE;
150 /* check all three queues in priority order
151 * call the PIMFOR receive function until the
153 if (isl38xx_in_queue(priv->control_block,
154 ISL38XX_CB_RX_MGMTQ) != 0) {
155 #if VERBOSE > SHOW_ERROR_MESSAGES
157 "Received frame in Management Queue\n");
159 islpci_mgt_receive(ndev);
161 islpci_mgt_cleanup_transmit(ndev);
163 /* Refill slots in receive queue */
164 islpci_mgmt_rx_fill(ndev);
166 /* no need to trigger the device, next
167 islpci_mgt_transaction does it */
170 while (isl38xx_in_queue(priv->control_block,
171 ISL38XX_CB_RX_DATA_LQ) != 0) {
172 #if VERBOSE > SHOW_ERROR_MESSAGES
174 "Received frame in Data Low Queue \n");
176 islpci_eth_receive(priv);
179 /* check whether the data transmit queues were full */
180 if (priv->data_low_tx_full) {
181 /* check whether the transmit is not full anymore */
182 if (ISL38XX_CB_TX_QSIZE -
183 isl38xx_in_queue(priv->control_block,
184 ISL38XX_CB_TX_DATA_LQ) >=
185 ISL38XX_MIN_QTHRESHOLD) {
186 /* nope, the driver is ready for more network frames */
187 netif_wake_queue(priv->ndev);
189 /* reset the full flag */
190 priv->data_low_tx_full = 0;
195 if (reg & ISL38XX_INT_IDENT_INIT) {
196 /* Device has been initialized */
197 #if VERBOSE > SHOW_ERROR_MESSAGES
199 "IRQ: Init flag, device initialized \n");
201 wake_up(&priv->reset_done);
204 if (reg & ISL38XX_INT_IDENT_SLEEP) {
205 /* Device intends to move to powersave state */
206 #if VERBOSE > SHOW_ERROR_MESSAGES
207 DEBUG(SHOW_TRACING, "IRQ: Sleep flag \n");
209 isl38xx_handle_sleep_request(priv->control_block,
214 if (reg & ISL38XX_INT_IDENT_WAKEUP) {
215 /* Device has been woken up to active state */
216 #if VERBOSE > SHOW_ERROR_MESSAGES
217 DEBUG(SHOW_TRACING, "IRQ: Wakeup flag \n");
220 isl38xx_handle_wakeup(priv->control_block,
221 &powerstate, priv->device_base);
226 if (islpci_get_state(priv) == PRV_STATE_SLEEP
227 && powerstate == ISL38XX_PSM_ACTIVE_STATE)
228 islpci_set_state(priv, PRV_STATE_READY);
230 /* !sleep -> sleep */
231 if (islpci_get_state(priv) != PRV_STATE_SLEEP
232 && powerstate == ISL38XX_PSM_POWERSAVE_STATE)
233 islpci_set_state(priv, PRV_STATE_SLEEP);
235 /* unlock the interrupt handler */
236 spin_unlock(&priv->slock);
241 /******************************************************************************
242 Network Interface Control & Statistical functions
243 ******************************************************************************/
245 islpci_open(struct net_device *ndev)
248 islpci_private *priv = netdev_priv(ndev);
250 printk(KERN_DEBUG "%s: islpci_open()\n", ndev->name);
252 /* reset data structures, upload firmware and reset device */
253 rc = islpci_reset(priv,1);
255 prism54_bring_down(priv);
256 return rc; /* Returns informative message */
259 netif_start_queue(ndev);
260 /* netif_mark_up( ndev ); */
266 islpci_close(struct net_device *ndev)
268 islpci_private *priv = netdev_priv(ndev);
270 printk(KERN_DEBUG "%s: islpci_close ()\n", ndev->name);
272 netif_stop_queue(ndev);
274 return prism54_bring_down(priv);
278 prism54_bring_down(islpci_private *priv)
280 void *device_base = priv->device_base;
282 /* we are going to shutdown the device */
283 islpci_set_state(priv, PRV_STATE_PREBOOT);
285 /* disable all device interrupts in case they weren't */
286 isl38xx_disable_interrupts(priv->device_base);
288 /* For safety reasons, we may want to ensure that no DMA transfer is
289 * currently in progress by emptying the TX and RX queues. */
291 /* wait until interrupts have finished executing on other CPUs */
292 prism54_synchronize_irq(priv->pdev->irq);
294 reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
295 reg &= ~(ISL38XX_CTRL_STAT_RESET | ISL38XX_CTRL_STAT_RAMBOOT);
296 writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
298 udelay(ISL38XX_WRITEIO_DELAY);
300 reg |= ISL38XX_CTRL_STAT_RESET;
301 writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
303 udelay(ISL38XX_WRITEIO_DELAY);
305 /* clear the Reset bit */
306 reg &= ~ISL38XX_CTRL_STAT_RESET;
307 writel(reg, device_base + ISL38XX_CTRL_STAT_REG);
310 /* wait a while for the device to reset */
311 set_current_state(TASK_UNINTERRUPTIBLE);
312 schedule_timeout(50*HZ/1000);
318 islpci_upload_fw(islpci_private *priv)
320 islpci_state_t old_state;
323 old_state = islpci_set_state(priv, PRV_STATE_BOOT);
325 printk(KERN_DEBUG "%s: uploading firmware...\n", priv->ndev->name);
327 rc = isl38xx_upload_firmware(priv->firmware,
328 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,75))
331 pci_name(priv->pdev),
334 priv->device_host_address);
336 /* error uploading the firmware */
337 printk(KERN_ERR "%s: could not upload firmware ('%s')\n",
338 priv->ndev->name, priv->firmware);
340 islpci_set_state(priv, old_state);
345 "%s: firmware uploaded done, now triggering reset...\n",
348 islpci_set_state(priv, PRV_STATE_POSTBOOT);
354 islpci_reset_if(islpci_private *priv)
360 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
361 /* This is 2.6 specific, nicer, shorter, but not in 2.4 yet */
363 prepare_to_wait(&priv->reset_done, &wait, TASK_UNINTERRUPTIBLE);
365 DECLARE_WAITQUEUE(wait, current);
366 set_current_state(TASK_UNINTERRUPTIBLE);
367 add_wait_queue(&priv->reset_done, &wait);
370 /* now the last step is to reset the interface */
371 isl38xx_interface_reset(priv->device_base, priv->device_host_address);
372 islpci_set_state(priv, PRV_STATE_PREINIT);
374 for(count = 0; count < 2 && result; count++) {
375 /* The software reset acknowledge needs about 220 msec here.
376 * Be conservative and wait for up to one second. */
378 remaining = schedule_timeout(HZ);
385 /* If we're here it's because our IRQ hasn't yet gone through.
386 * Retry a bit more...
388 printk(KERN_ERR "%s: device soft reset timed out\n",
393 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
394 /* 2.6 specific too */
395 finish_wait(&priv->reset_done, &wait);
397 remove_wait_queue(&priv->reset_done, &wait);
398 set_current_state(TASK_RUNNING);
404 islpci_set_state(priv, PRV_STATE_INIT);
406 /* Now that the device is 100% up, let's allow
407 * for the other interrupts --
408 * NOTE: this is not *yet* true since we've only allowed the
409 * INIT interrupt on the IRQ line. We can perhaps poll
410 * the IRQ line until we know for sure the reset went through */
411 isl38xx_enable_common_interrupts(priv->device_base);
413 prism54_mib_init_work(priv);
415 islpci_set_state(priv, PRV_STATE_READY);
421 islpci_reset(islpci_private *priv, int reload_firmware)
423 isl38xx_control_block *cb = /* volatile not needed */
424 (isl38xx_control_block *) priv->control_block;
429 islpci_set_state(priv, PRV_STATE_PREBOOT);
431 islpci_set_state(priv, PRV_STATE_POSTBOOT);
433 printk(KERN_DEBUG "%s: resetting device...\n", priv->ndev->name);
435 /* disable all device interrupts in case they weren't */
436 isl38xx_disable_interrupts(priv->device_base);
438 /* flush all management queues */
439 priv->index_mgmt_tx = 0;
440 priv->index_mgmt_rx = 0;
442 /* clear the indexes in the frame pointer */
443 for (counter = 0; counter < ISL38XX_CB_QCOUNT; counter++) {
444 cb->driver_curr_frag[counter] = cpu_to_le32(0);
445 cb->device_curr_frag[counter] = cpu_to_le32(0);
448 /* reset the mgmt receive queue */
449 for (counter = 0; counter < ISL38XX_CB_MGMT_QSIZE; counter++) {
450 isl38xx_fragment *frag = &cb->rx_data_mgmt[counter];
451 frag->size = MGMT_FRAME_SIZE;
453 frag->address = priv->mgmt_rx[counter].pci_addr;
456 for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) {
457 cb->rx_data_low[counter].address =
458 cpu_to_le32((u32) priv->pci_map_rx_address[counter]);
461 /* since the receive queues are filled with empty fragments, now we can
462 * set the corresponding indexes in the Control Block */
463 priv->control_block->driver_curr_frag[ISL38XX_CB_RX_DATA_LQ] =
464 cpu_to_le32(ISL38XX_CB_RX_QSIZE);
465 priv->control_block->driver_curr_frag[ISL38XX_CB_RX_MGMTQ] =
466 cpu_to_le32(ISL38XX_CB_MGMT_QSIZE);
468 /* reset the remaining real index registers and full flags */
469 priv->free_data_rx = 0;
470 priv->free_data_tx = 0;
471 priv->data_low_tx_full = 0;
473 if (reload_firmware) { /* Should we load the firmware ? */
474 /* now that the data structures are cleaned up, upload
475 * firmware and reset interface */
476 rc = islpci_upload_fw(priv);
481 /* finally reset interface */
482 rc = islpci_reset_if(priv);
483 if (!rc) /* If successful */
486 printk(KERN_DEBUG "prism54: Your card/socket may be faulty, or IRQ line too busy :(\n");
491 struct net_device_stats *
492 islpci_statistics(struct net_device *ndev)
494 islpci_private *priv = netdev_priv(ndev);
496 #if VERBOSE > SHOW_ERROR_MESSAGES
497 DEBUG(SHOW_FUNCTION_CALLS, "islpci_statistics \n");
500 return &priv->statistics;
503 /******************************************************************************
504 Network device configuration functions
505 ******************************************************************************/
507 islpci_alloc_memory(islpci_private *priv)
511 #if VERBOSE > SHOW_ERROR_MESSAGES
512 printk(KERN_DEBUG "islpci_alloc_memory\n");
515 /* remap the PCI device base address to accessable */
516 if (!(priv->device_base =
517 ioremap(pci_resource_start(priv->pdev, 0),
518 ISL38XX_PCI_MEM_SIZE))) {
519 /* error in remapping the PCI device memory address range */
520 printk(KERN_ERR "PCI memory remapping failed \n");
524 /* memory layout for consistent DMA region:
526 * Area 1: Control Block for the device interface
527 * Area 2: Power Save Mode Buffer for temporary frame storage. Be aware that
528 * the number of supported stations in the AP determines the minimal
529 * size of the buffer !
532 /* perform the allocation */
533 priv->driver_mem_address = pci_alloc_consistent(priv->pdev,
536 device_host_address);
538 if (!priv->driver_mem_address) {
539 /* error allocating the block of PCI memory */
540 printk(KERN_ERR "%s: could not allocate DMA memory, aborting!",
545 /* assign the Control Block to the first address of the allocated area */
546 priv->control_block =
547 (isl38xx_control_block *) priv->driver_mem_address;
549 /* set the Power Save Buffer pointer directly behind the CB */
550 priv->device_psm_buffer =
551 priv->device_host_address + CONTROL_BLOCK_SIZE;
553 /* make sure all buffer pointers are initialized */
554 for (counter = 0; counter < ISL38XX_CB_QCOUNT; counter++) {
555 priv->control_block->driver_curr_frag[counter] = cpu_to_le32(0);
556 priv->control_block->device_curr_frag[counter] = cpu_to_le32(0);
559 priv->index_mgmt_rx = 0;
560 memset(priv->mgmt_rx, 0, sizeof(priv->mgmt_rx));
561 memset(priv->mgmt_tx, 0, sizeof(priv->mgmt_tx));
563 /* allocate rx queue for management frames */
564 if (islpci_mgmt_rx_fill(priv->ndev) < 0)
567 /* now get the data rx skb's */
568 memset(priv->data_low_rx, 0, sizeof (priv->data_low_rx));
569 memset(priv->pci_map_rx_address, 0, sizeof (priv->pci_map_rx_address));
571 for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) {
574 /* allocate an sk_buff for received data frames storage
575 * each frame on receive size consists of 1 fragment
576 * include any required allignment operations */
577 if (!(skb = dev_alloc_skb(MAX_FRAGMENT_SIZE_RX + 2))) {
578 /* error allocating an sk_buff structure elements */
579 printk(KERN_ERR "Error allocating skb.\n");
583 /* add the new allocated sk_buff to the buffer array */
584 priv->data_low_rx[counter] = skb;
586 /* map the allocated skb data area to pci */
587 priv->pci_map_rx_address[counter] =
588 pci_map_single(priv->pdev, (void *) skb->data,
589 MAX_FRAGMENT_SIZE_RX + 2,
591 if (!priv->pci_map_rx_address[counter]) {
592 /* error mapping the buffer to device
593 accessable memory address */
594 printk(KERN_ERR "failed to map skb DMA'able\n");
599 prism54_acl_init(&priv->acl);
600 prism54_wpa_ie_init(priv);
606 islpci_free_memory(priv);
611 islpci_free_memory(islpci_private *priv)
615 if (priv->device_base)
616 iounmap(priv->device_base);
617 priv->device_base = 0;
619 /* free consistent DMA area... */
620 if (priv->driver_mem_address)
621 pci_free_consistent(priv->pdev, HOST_MEM_BLOCK,
622 priv->driver_mem_address,
623 priv->device_host_address);
625 /* clear some dangling pointers */
626 priv->driver_mem_address = 0;
627 priv->device_host_address = 0;
628 priv->device_psm_buffer = 0;
629 priv->control_block = 0;
631 /* clean up mgmt rx buffers */
632 for (counter = 0; counter < ISL38XX_CB_MGMT_QSIZE; counter++) {
633 struct islpci_membuf *buf = &priv->mgmt_rx[counter];
635 pci_unmap_single(priv->pdev, buf->pci_addr,
636 buf->size, PCI_DMA_FROMDEVICE);
644 /* clean up data rx buffers */
645 for (counter = 0; counter < ISL38XX_CB_RX_QSIZE; counter++) {
646 if (priv->pci_map_rx_address[counter])
647 pci_unmap_single(priv->pdev,
648 priv->pci_map_rx_address[counter],
649 MAX_FRAGMENT_SIZE_RX + 2,
651 priv->pci_map_rx_address[counter] = 0;
653 if (priv->data_low_rx[counter])
654 dev_kfree_skb(priv->data_low_rx[counter]);
655 priv->data_low_rx[counter] = 0;
658 /* Free the acces control list and the WPA list */
659 prism54_acl_clean(&priv->acl);
660 prism54_wpa_ie_clean(priv);
668 islpci_set_multicast_list(struct net_device *dev)
670 /* put device into promisc mode and let network layer handle it */
675 islpci_setup(struct pci_dev *pdev)
677 islpci_private *priv;
678 struct net_device *ndev = alloc_etherdev(sizeof (islpci_private));
683 SET_MODULE_OWNER(ndev);
684 pci_set_drvdata(pdev, ndev);
685 #if defined(SET_NETDEV_DEV)
686 SET_NETDEV_DEV(ndev, &pdev->dev);
689 /* setup the structure members */
690 ndev->base_addr = pci_resource_start(pdev, 0);
691 ndev->irq = pdev->irq;
693 /* initialize the function pointers */
694 ndev->open = &islpci_open;
695 ndev->stop = &islpci_close;
696 ndev->get_stats = &islpci_statistics;
697 ndev->get_wireless_stats = &prism54_get_wireless_stats;
698 ndev->do_ioctl = &prism54_ioctl;
699 ndev->wireless_handlers =
700 (struct iw_handler_def *) &prism54_handler_def;
702 ndev->hard_start_xmit = &islpci_eth_transmit;
703 /* ndev->set_multicast_list = &islpci_set_multicast_list; */
704 ndev->addr_len = ETH_ALEN;
705 ndev->set_mac_address = &prism54_set_mac_address;
706 /* Get a non-zero dummy MAC address for nameif. Jean II */
707 memcpy(ndev->dev_addr, dummy_mac, 6);
709 #ifdef HAVE_TX_TIMEOUT
710 ndev->watchdog_timeo = ISLPCI_TX_TIMEOUT;
711 ndev->tx_timeout = &islpci_eth_tx_timeout;
714 /* allocate a private device structure to the network device */
715 priv = netdev_priv(ndev);
719 priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR) ?
720 ARPHRD_IEEE80211: ARPHRD_ETHER;
722 /* save the start and end address of the PCI memory area */
723 ndev->mem_start = (unsigned long) priv->device_base;
724 ndev->mem_end = ndev->mem_start + ISL38XX_PCI_MEM_SIZE;
726 #if VERBOSE > SHOW_ERROR_MESSAGES
727 DEBUG(SHOW_TRACING, "PCI Memory remapped to 0x%p\n", priv->device_base);
730 init_waitqueue_head(&priv->reset_done);
732 /* init the queue read locks, process wait counter */
733 sema_init(&priv->mgmt_sem, 1);
734 priv->mgmt_received = NULL;
735 init_waitqueue_head(&priv->mgmt_wqueue);
736 sema_init(&priv->stats_sem, 1);
737 spin_lock_init(&priv->slock);
739 /* init state machine with off#1 state */
740 priv->state = PRV_STATE_OFF;
743 /* initialize workqueue's */
744 INIT_WORK(&priv->stats_work,
745 (void (*)(void *)) prism54_update_stats, priv);
747 priv->stats_timestamp = 0;
749 /* allocate various memory areas */
750 if (islpci_alloc_memory(priv))
753 /* select the firmware file depending on the device id */
754 switch (pdev->device) {
755 case PCIDEVICE_ISL3890:
756 case PCIDEVICE_3COM6001:
757 strcpy(priv->firmware, ISL3890_IMAGE_FILE);
759 case PCIDEVICE_ISL3877:
760 strcpy(priv->firmware, ISL3877_IMAGE_FILE);
764 strcpy(priv->firmware, ISL3890_IMAGE_FILE);
768 if (register_netdev(ndev)) {
769 DEBUG(SHOW_ERROR_MESSAGES,
770 "ERROR: register_netdev() failed \n");
771 goto do_islpci_free_memory;
776 do_islpci_free_memory:
777 islpci_free_memory(priv);
779 pci_set_drvdata(pdev, 0);
786 islpci_set_state(islpci_private *priv, islpci_state_t new_state)
788 islpci_state_t old_state;
791 old_state = priv->state;
793 /* this means either a race condition or some serious error in
799 priv->state = new_state;
802 case PRV_STATE_PREBOOT:
803 /* there are actually many off-states, enumerated by
805 if (old_state == PRV_STATE_OFF)
808 /* only if hw_unavailable is zero now it means we either
809 * were in off#1 state, or came here from
811 if (!priv->state_off)
812 priv->state = new_state;
816 printk(KERN_DEBUG "%s: state transition %d -> %d (off#%d)\n",
817 priv->ndev->name, old_state, new_state, priv->state_off);
821 BUG_ON(priv->state_off < 0);
822 BUG_ON(priv->state_off && (priv->state != PRV_STATE_OFF));
823 BUG_ON(!priv->state_off && (priv->state == PRV_STATE_OFF));