/******************************************************************************* * wl_adapter_open() ******************************************************************************* * * DESCRIPTION: * * Open the device. * * PARAMETERS: * * dev - a pointer to a net_device structure representing the network * device to open. * * RETURNS: * * 0 on success * errno value otherwise * ******************************************************************************/ int wl_adapter_open(struct net_device *dev) { struct wl_private *lp = wl_priv(dev); struct pcmcia_device *link = lp->link; int result = 0; int hcf_status = HCF_SUCCESS; /*--------------------------------------------------------------------*/ DBG_FUNC("wl_adapter_open"); DBG_ENTER(DbgInfo); DBG_PRINT("%s\n", VERSION_INFO); DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev); if (!pcmcia_dev_present(link)) { DBG_LEAVE(DbgInfo); return -ENODEV; } link->open++; hcf_status = wl_open(dev); if (hcf_status != HCF_SUCCESS) { link->open--; result = -ENODEV; } DBG_LEAVE(DbgInfo); return result; } /* wl_adapter_open */
static int pcnet_open(struct net_device *dev) { int ret; pcnet_dev_t *info = PRIV(dev); struct pcmcia_device *link = info->p_dev; unsigned int nic_base = dev->base_addr; dev_dbg(&link->dev, "pcnet_open('%s')\n", dev->name); if (!pcmcia_dev_present(link)) return -ENODEV; set_misc_reg(dev); outb_p(0xFF, nic_base + EN0_ISR); /* Clear bogus intr. */ ret = request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, dev->name, dev); if (ret) return ret; link->open++; info->phy_id = info->eth_phy; info->link_status = 0x00; init_timer(&info->watchdog); info->watchdog.function = ei_watchdog; info->watchdog.data = (u_long)dev; info->watchdog.expires = jiffies + HZ; add_timer(&info->watchdog); return ei_open(dev); } /* pcnet_open */
static int prism2_pccard_card_present(local_info_t *local) { struct hostap_cs_priv *hw_priv = local->hw_priv; if (hw_priv != NULL && hw_priv->link != NULL && pcmcia_dev_present(hw_priv->link)) return 1; return 0; }
/* Call-back function to interrogate PCMCIA-specific information about the current existance of the card */ static int card_present(void *arg) { struct pcmcia_device *link = (struct pcmcia_device *)arg; if (pcmcia_dev_present(link)) return 1; return 0; }
/* * Reset the card using configuration registers COR and CCSR. * If IDLE is 1, stop the firmware, so that it can be safely rewritten. */ static int spectrum_reset(struct pcmcia_device *link, int idle) { int last_ret, last_fn; conf_reg_t reg; u_int save_cor; /* Doing it if hardware is gone is guaranteed crash */ if (!pcmcia_dev_present(link)) return -ENODEV; /* Save original COR value */ reg.Function = 0; reg.Action = CS_READ; reg.Offset = CISREG_COR; CS_CHECK(AccessConfigurationRegister, pcmcia_access_configuration_register(link, ®)); save_cor = reg.Value; /* Soft-Reset card */ reg.Action = CS_WRITE; reg.Offset = CISREG_COR; reg.Value = (save_cor | COR_SOFT_RESET); CS_CHECK(AccessConfigurationRegister, pcmcia_access_configuration_register(link, ®)); udelay(1000); /* Read CCSR */ reg.Action = CS_READ; reg.Offset = CISREG_CCSR; CS_CHECK(AccessConfigurationRegister, pcmcia_access_configuration_register(link, ®)); /* * Start or stop the firmware. Memory width bit should be * preserved from the value we've just read. */ reg.Action = CS_WRITE; reg.Offset = CISREG_CCSR; reg.Value = (idle ? HCR_IDLE : HCR_RUN) | (reg.Value & HCR_MEM16); CS_CHECK(AccessConfigurationRegister, pcmcia_access_configuration_register(link, ®)); udelay(1000); /* Restore original COR configuration index */ reg.Action = CS_WRITE; reg.Offset = CISREG_COR; reg.Value = (save_cor & ~COR_SOFT_RESET); CS_CHECK(AccessConfigurationRegister, pcmcia_access_configuration_register(link, ®)); udelay(1000); return 0; cs_failed: cs_error(link, last_fn, last_ret); return -ENODEV; }
/******************************************************************************* * wl_adapter_is_open() ******************************************************************************* * * DESCRIPTION: * * Check with Card Services to determine if this device is open. * * PARAMETERS: * * dev - a pointer to the net_device structure whose open status will be * checked * * RETURNS: * * nonzero if device is open * 0 otherwise * ******************************************************************************/ int wl_adapter_is_open(struct net_device *dev) { struct wl_private *lp = wl_priv(dev); struct pcmcia_device *link = lp->link; if (!pcmcia_dev_present(link)) return 0; return link->open; } /* wl_adapter_is_open */
static int serial_resume(struct pcmcia_device *link) { if (pcmcia_dev_present(link)) { struct serial_info *info = link->priv; int i; for (i = 0; i < info->ndev; i++) serial8250_resume_port(info->line[i]); wakeup_card(info); } return 0; }
static struct net_device_stats *el3_get_stats(struct net_device *dev) { struct el3_private *lp = netdev_priv(dev); unsigned long flags; struct pcmcia_device *link = lp->p_dev; if (pcmcia_dev_present(link)) { spin_lock_irqsave(&lp->lock, flags); update_stats(dev); spin_unlock_irqrestore(&lp->lock, flags); } return &dev->stats; }
/* * Reset the card using configuration registers COR and CCSR. * If IDLE is 1, stop the firmware, so that it can be safely rewritten. */ static int spectrum_reset(struct pcmcia_device *link, int idle) { int ret; u8 save_cor; u8 ccsr; /* Doing it if hardware is gone is guaranteed crash */ if (!pcmcia_dev_present(link)) return -ENODEV; /* Save original COR value */ ret = pcmcia_read_config_byte(link, CISREG_COR, &save_cor); if (ret) goto failed; /* Soft-Reset card */ ret = pcmcia_write_config_byte(link, CISREG_COR, (save_cor | COR_SOFT_RESET)); if (ret) goto failed; udelay(1000); /* Read CCSR */ ret = pcmcia_read_config_byte(link, CISREG_CCSR, &ccsr); if (ret) goto failed; /* * Start or stop the firmware. Memory width bit should be * preserved from the value we've just read. */ ccsr = (idle ? HCR_IDLE : HCR_RUN) | (ccsr & HCR_MEM16); ret = pcmcia_write_config_byte(link, CISREG_CCSR, ccsr); if (ret) goto failed; udelay(1000); /* Restore original COR configuration index */ ret = pcmcia_write_config_byte(link, CISREG_COR, (save_cor & ~COR_SOFT_RESET)); if (ret) goto failed; udelay(1000); return 0; failed: return -ENODEV; }
static int spectrum_reset(struct pcmcia_device *link, int idle) { int ret; u8 save_cor; u8 ccsr; /* */ if (!pcmcia_dev_present(link)) return -ENODEV; /* */ ret = pcmcia_read_config_byte(link, CISREG_COR, &save_cor); if (ret) goto failed; /* */ ret = pcmcia_write_config_byte(link, CISREG_COR, (save_cor | COR_SOFT_RESET)); if (ret) goto failed; udelay(1000); /* */ ret = pcmcia_read_config_byte(link, CISREG_CCSR, &ccsr); if (ret) goto failed; /* */ ccsr = (idle ? HCR_IDLE : HCR_RUN) | (ccsr & HCR_MEM16); ret = pcmcia_write_config_byte(link, CISREG_CCSR, ccsr); if (ret) goto failed; udelay(1000); /* */ ret = pcmcia_write_config_byte(link, CISREG_COR, (save_cor & ~COR_SOFT_RESET)); if (ret) goto failed; udelay(1000); return 0; failed: return -ENODEV; }
static int pdacf_resume(struct pcmcia_device *link) { struct snd_pdacf *chip = link->priv; snd_printdd(KERN_DEBUG "RESUME\n"); if (pcmcia_dev_present(link)) { if (chip) { snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n"); snd_pdacf_resume(chip); } } snd_printdd(KERN_DEBUG "resume done!\n"); return 0; }
static void dtl1_write_wakeup(dtl1_info_t *info) { if (!info) { BT_ERR("Unknown device"); return; } if (test_bit(XMIT_WAITING, &(info->tx_state))) { set_bit(XMIT_WAKEUP, &(info->tx_state)); return; } if (test_and_set_bit(XMIT_SENDING, &(info->tx_state))) { set_bit(XMIT_WAKEUP, &(info->tx_state)); return; } do { unsigned int iobase = info->p_dev->resource[0]->start; register struct sk_buff *skb; int len; clear_bit(XMIT_WAKEUP, &(info->tx_state)); if (!pcmcia_dev_present(info->p_dev)) return; skb = skb_dequeue(&(info->txq)); if (!skb) break; /* Send frame */ len = dtl1_write(iobase, 32, skb->data, skb->len); if (len == skb->len) { set_bit(XMIT_WAITING, &(info->tx_state)); kfree_skb(skb); } else { skb_pull(skb, len); skb_queue_head(&(info->txq), skb); } info->hdev->stat.byte_tx += len; } while (test_bit(XMIT_WAKEUP, &(info->tx_state))); clear_bit(XMIT_SENDING, &(info->tx_state)); }
static int vxp_resume(struct pcmcia_device *link) { struct vx_core *chip = link->priv; snd_printdd(KERN_DEBUG "RESUME\n"); if (pcmcia_dev_present(link)) { //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; if (chip) { snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); snd_vx_resume(chip); } } snd_printdd(KERN_DEBUG "resume done!\n"); return 0; }
static void btuart_write_wakeup(btuart_info_t *info) { if (!info) { BT_ERR("Unknown device"); return; } if (test_and_set_bit(XMIT_SENDING, &(info->tx_state))) { set_bit(XMIT_WAKEUP, &(info->tx_state)); return; } do { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) register unsigned int iobase = info->p_dev->resource[0]->start; #else register unsigned int iobase = info->p_dev->io.BasePort1; #endif register struct sk_buff *skb; register int len; clear_bit(XMIT_WAKEUP, &(info->tx_state)); if (!pcmcia_dev_present(info->p_dev)) return; if (!(skb = skb_dequeue(&(info->txq)))) break; /* Send frame */ len = btuart_write(iobase, 16, skb->data, skb->len); set_bit(XMIT_WAKEUP, &(info->tx_state)); if (len == skb->len) { kfree_skb(skb); } else { skb_pull(skb, len); skb_queue_head(&(info->txq), skb); } info->hdev->stat.byte_tx += len; } while (test_bit(XMIT_WAKEUP, &(info->tx_state))); clear_bit(XMIT_SENDING, &(info->tx_state)); }
static ssize_t cm4040_read(struct file *filp, char __user *buf, size_t count, loff_t *ppos) { struct reader_dev *dev = filp->private_data; int iobase = dev->p_dev->io.BasePort1; size_t bytes_to_read; unsigned long i; size_t min_bytes_to_read; int rc; unsigned char uc; DEBUGP(2, dev, "-> cm4040_read(%s,%d)\n", current->comm, current->pid); if (count == 0) return 0; if (count < 10) return -EFAULT; if (filp->f_flags & O_NONBLOCK) { DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n"); DEBUGP(2, dev, "<- cm4040_read (failure)\n"); return -EAGAIN; } if (!pcmcia_dev_present(dev->p_dev)) return -ENODEV; for (i = 0; i < 5; i++) { rc = wait_for_bulk_in_ready(dev); if (rc <= 0) { DEBUGP(5, dev, "wait_for_bulk_in_ready rc=%.2x\n", rc); DEBUGP(2, dev, "<- cm4040_read (failed)\n"); if (rc == -ERESTARTSYS) return rc; return -EIO; } dev->r_buf[i] = xinb(iobase + REG_OFFSET_BULK_IN); #ifdef PCMCIA_DEBUG if (pc_debug >= 6) printk(KERN_DEBUG "%lu:%2x ", i, dev->r_buf[i]); } printk("\n"); #else }
/* ---------------------------------------------------------------------------- mace_open Open device driver. ---------------------------------------------------------------------------- */ static int mace_open(struct net_device *dev) { kio_addr_t ioaddr = dev->base_addr; mace_private *lp = netdev_priv(dev); struct pcmcia_device *link = lp->p_dev; if (!pcmcia_dev_present(link)) return -ENODEV; link->open++; MACEBANK(0); netif_start_queue(dev); nmclan_reset(dev); return 0; /* Always succeed */ } /* mace_open */
static int el3_open(struct net_device *dev) { struct el3_private *lp = netdev_priv(dev); struct pcmcia_device *link = lp->p_dev; if (!pcmcia_dev_present(link)) return -ENODEV; link->open++; netif_start_queue(dev); tc589_reset(dev); setup_timer(&lp->media, media_check, (unsigned long)dev); mod_timer(&lp->media, jiffies + HZ); dev_dbg(&link->dev, "%s: opened, status %4.4x.\n", dev->name, inw(dev->base_addr + EL3_STATUS)); return 0; }
static int el3_open(struct net_device *dev) { struct el3_private *lp = netdev_priv(dev); struct pcmcia_device *link = lp->p_dev; if (!pcmcia_dev_present(link)) return -ENODEV; link->open++; netif_start_queue(dev); tc589_reset(dev); init_timer(&lp->media); lp->media.function = &media_check; lp->media.data = (unsigned long) dev; lp->media.expires = jiffies + HZ; add_timer(&lp->media); DEBUG(1, "%s: opened, status %4.4x.\n", dev->name, inw(dev->base_addr + EL3_STATUS)); return 0; }
static void bluecard_write_wakeup(struct bluecard_info *info) { if (!info) { BT_ERR("Unknown device"); return; } if (!test_bit(XMIT_SENDING_READY, &(info->tx_state))) return; if (test_and_set_bit(XMIT_SENDING, &(info->tx_state))) { set_bit(XMIT_WAKEUP, &(info->tx_state)); return; } do { unsigned int iobase = info->p_dev->resource[0]->start; unsigned int offset; unsigned char command; unsigned long ready_bit; register struct sk_buff *skb; int len; clear_bit(XMIT_WAKEUP, &(info->tx_state)); if (!pcmcia_dev_present(info->p_dev)) return; if (test_bit(XMIT_BUFFER_NUMBER, &(info->tx_state))) { if (!test_bit(XMIT_BUF_TWO_READY, &(info->tx_state))) break; offset = 0x10; command = REG_COMMAND_TX_BUF_TWO; ready_bit = XMIT_BUF_TWO_READY; } else { if (!test_bit(XMIT_BUF_ONE_READY, &(info->tx_state))) break; offset = 0x00; command = REG_COMMAND_TX_BUF_ONE; ready_bit = XMIT_BUF_ONE_READY; } skb = skb_dequeue(&(info->txq)); if (!skb) break; if (bt_cb(skb)->pkt_type & 0x80) { /* Disable RTS */ info->ctrl_reg |= REG_CONTROL_RTS; outb(info->ctrl_reg, iobase + REG_CONTROL); } /* Activate LED */ bluecard_enable_activity_led(info); /* Send frame */ len = bluecard_write(iobase, offset, skb->data, skb->len); /* Tell the FPGA to send the data */ outb_p(command, iobase + REG_COMMAND); /* Mark the buffer as dirty */ clear_bit(ready_bit, &(info->tx_state)); if (bt_cb(skb)->pkt_type & 0x80) { DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); DEFINE_WAIT(wait); unsigned char baud_reg; switch (bt_cb(skb)->pkt_type) { case PKT_BAUD_RATE_460800: baud_reg = REG_CONTROL_BAUD_RATE_460800; break; case PKT_BAUD_RATE_230400: baud_reg = REG_CONTROL_BAUD_RATE_230400; break; case PKT_BAUD_RATE_115200: baud_reg = REG_CONTROL_BAUD_RATE_115200; break; case PKT_BAUD_RATE_57600: /* Fall through... */ default: baud_reg = REG_CONTROL_BAUD_RATE_57600; break; } /* Wait until the command reaches the baseband */ prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE); schedule_timeout(HZ/10); finish_wait(&wq, &wait); /* Set baud on baseband */ info->ctrl_reg &= ~0x03; info->ctrl_reg |= baud_reg; outb(info->ctrl_reg, iobase + REG_CONTROL); /* Enable RTS */ info->ctrl_reg &= ~REG_CONTROL_RTS; outb(info->ctrl_reg, iobase + REG_CONTROL); /* Wait before the next HCI packet can be send */ prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE); schedule_timeout(HZ); finish_wait(&wq, &wait); } if (len == skb->len) { kfree_skb(skb); } else { skb_pull(skb, len); skb_queue_head(&(info->txq), skb); } info->hdev->stat.byte_tx += len; /* Change buffer */ change_bit(XMIT_BUFFER_NUMBER, &(info->tx_state)); } while (test_bit(XMIT_WAKEUP, &(info->tx_state))); clear_bit(XMIT_SENDING, &(info->tx_state)); }