Ejemplo n.º 1
0
static int pcan_dongle_probe(struct pcandev *dev) // probe for type
{
  int result = 0;
  
  DPRINTK(KERN_DEBUG "%s: pcan_dongle_probe()\n", DEVICE_NAME);
  
  result = ___request_region(dev->port.dng.dwPort, DNG_PORT_SIZE, DEVICE_NAME);

  if (!result)
  {  
    dev->wInitStep = 1;

    if (dev->wType == HW_DONGLE_SJA_EPP)
    {
      result = ___request_region(dev->port.dng.wEcr, ECR_PORT_SIZE, DEVICE_NAME);    
      if (!result)
        dev->wInitStep = 2;
    }
  }
  
  return result;
}
Ejemplo n.º 2
0
static int  pcan_isa_init(struct pcandev *dev, u32 dwPort, u16 wIrq)
{
  int err = 0;
  
  DPRINTK(KERN_DEBUG "%s: pcan_isa_init(), isa_devices = %d\n", DEVICE_NAME, isa_devices);

  // init process wait queues
  init_waitqueue_head(&dev->read_queue);
  init_waitqueue_head(&dev->write_queue);
  
  // set this before any instructions, fill struct pcandev, part 1  
  dev->wInitStep   = 0;           
  dev->readreg     = pcan_isa_readreg;
  dev->writereg    = pcan_isa_writereg;
  dev->cleanup     = pcan_isa_cleanup;
  dev->req_irq     = pcan_isa_req_irq;
  dev->free_irq    = pcan_isa_free_irq;
  dev->open        = pcan_isa_open;
  dev->release     = pcan_isa_release;
  dev->filter      = pcan_create_filter_chain();
  
  // reject illegal combination
  if ((!dwPort && wIrq) || (dwPort && !wIrq))
    return -EINVAL;

  // a default is requested
  if (!dwPort)
  {
    // there's no default available
    if (isa_devices >= ISA_DEFAULT_COUNT)
      return -ENODEV;
    
    dev->port.isa.dwPort = isa_ports[isa_devices];
    dev->port.isa.wIrq   = isa_irqs[isa_devices];    
  }
  else
  {
    dev->port.isa.dwPort = dwPort;
    dev->port.isa.wIrq   = wIrq;    
  } 
   
  dev->nMajor      = pcan_drv.nMajor;
  dev->nMinor      = PCAN_ISA_MINOR_BASE + isa_devices;
   
  // request address range reservation
  err = ___request_region(dev->port.isa.dwPort, ISA_PORT_SIZE, DEVICE_NAME);
  if (err)
    return err;

  dev->wInitStep = 1;
  
  dev->wInitStep = 2; 
  
  INIT_SAME_IRQ_LIST();
  
  isa_devices++; 
  dev->wInitStep = 3;
  
  printk(KERN_INFO "%s: isa device minor %d expected (io=0x%04x,irq=%d)\n", DEVICE_NAME, dev->nMinor, dev->port.isa.dwPort, dev->port.isa.wIrq);
    
  return 0;
}