Comedi attach

Hi, 
 
I'm currently writing a new comedi driver for a selfmade pci card with a 
plx 9052 chip and therefore using parts of existing drivers as the one for  
adl_pci9111. The problem is a segmentation fault when calling 
comedi_config with the new driver. I'll post the comedi attach and the 
kernel message below and hope anyone has any idea how to solve this.. 
 
Thanks in advance 
Lars 
 
 
Comedi attach: 
 
static int plx_attach(comedi_device *dev,comedi_devconfig *it) 
{ 
	comedi_subdevice *s; 
        int io_base,io_range,lcr_io_base,lcr_io_range; 
        struct pci_dev* pci_device; 
	int error,i; 
	plx_board_struct* board; 
	 
        printk("comedi%d: " PLX_DRIVER_NAME " driver\n",dev->minor); 
	 
	pci_for_each_dev(pci_device) 
	{ 
	  if (pci_device->vendor == PCI_VENDOR_ID_PLX) 
	  { 
	    for (i=0; i< plx_board_nbr; i++) 
	    { 
	      if (plx_boards[i].device_id == pci_device->device) 
	      { 
	      	//was a particular bus/slot requested? 
		if ((it->options[0] != 0) || (it->options[1] !=0)) 
		{ 
		  if (pci_device->bus->number != it->options[0] || 
		      PCI_SLOT(pci_device->devfn) != it->options[1]) 
		  { 
		    continue; 
		  } 
		} 
		dev->board_ptr = plx_boards + i; 
		board = (plx_board_struct *) dev->board_ptr; 
		goto found; 
	      } 
	    } 
	  } 
	} 
	 
	printk ("comedi%d: no supported board found! (req. bus/slot: 
%d%d)\n", 
		dev->minor,it->options[0],it->options[1]); 
	return -EIO; 
       
      found: 
	 
      	printk("comedi%d: found %s (b:s:f=%d:%d:%d),irq=%d\n", 
	       dev->minor, 
	       plx_boards[i].name, 
	       pci_device->bus->number, 
	       PCI_SLOT(pci_device->devfn), 
	       PCI_FUNC(pci_device->devfn), 
	       pci_device->irq); 
      	     
	switch(board->device_id) 
	{ 
	} 
	 
	lcr_io_base = pci_resource_start (pci_device,1); 
	lcr_io_range = pci_resource_end (pci_device,1) - lcr_io_base +1; 
	 
	printk ("comedi%d: local configuration registers at address 0x%4x 
[0x%4x]\n", 
		dev->minor, 
		lcr_io_base, 
		lcr_io_range); 
		 
	io_base = pci_resource_start (pci_device, 3); 
	io_range = pci_resource_end (pci_device, 3) - io_base +1; 
	 
	printk ("comedi%d: IO registers at address 0x%4x [0x%4x]\n", 
		dev->minor, 
		io_base, 
		io_range); 
	 
	// Allocate IO ressources 
	if(pci_request_regions(pci_device, PLX_DRIVER_NAME)) 
	{ 
		printk("comedi%d: I/O port conflict\n",dev->minor); 
		return -EIO; 
	} 
		        
	dev->iobase=io_base; 
	dev->board_name=board->name; 
         
	devpriv->pci_device = pci_device; 
	devpriv->io_range = io_range; 
	devpriv->is_valid=0; 
	devpriv->lcr_io_base=lcr_io_base; 
	devpriv->lcr_io_range=lcr_io_range; 
	 
/* 	 
 * If you can probe the device to determine what device in a series 
 * it is, this is the place to do it.  Otherwise, dev->board_ptr 
 * should already be initialized. 
 */ 
	//dev->board_ptr = plx_probe(dev); 
 
/* 
 * Initialize dev->board_name.  Note that we can use the "thisboard" 
 * macro now, since we just initialized it in the last line. 
 */ 
	dev->board_name = thisboard->name; 
 
/* 
 * Allocate the private structure area.  alloc_private() is a 
 * convenient macro defined in comedidev.h. 
 */ 
	if(alloc_private(dev,sizeof(plx_private_struct))<0) 
    		return -ENOMEM; 
		 
/* 
 * Allocate the subdevice structures.  alloc_subdevice() is a 
 * convenient macro defined in comedidev.h. 
 */ 
	if(alloc_subdevices(dev, 3)<0) 
		return -ENOMEM; 
	/* 
	if((error=alloc_subdevices(dev, 4))<0) 
    		return  error; 
	*/	 
		 
	s=dev->subdevices+0; 
	//dev->read_subdev=s; 
	/* analog input subdevice */ 
	s->type=COMEDI_SUBD_AI; 
	/* we support single-ended (ground) and differential */ 
	s->subdev_flags=SDF_READABLE|SDF_GROUND|SDF_DIFF; 
	s->n_chan=thisboard->ai_chans; 
	s->maxdata=(1<<thisboard->ai_bits)-1; 
	s->range_table=&range_bipolar10; 
	s->len_chanlist=16;  /* This is the maximum chanlist length that 
				the board can handle */ 
	s->insn_read = plx_ai_rinsn; 
	//s->do_cmd = plx_ai_cmd; 
	s->do_cmdtest = plx_ai_cmdtest; 
 
	s=dev->subdevices+1; 
	/* analog output subdevice */ 
	s->type=COMEDI_SUBD_AO; 
	s->subdev_flags=SDF_WRITABLE; 
	s->n_chan=1; 
	s->maxdata=0xffff; 
	s->range_table=&range_bipolar5; 
	s->insn_write = plx_ao_winsn; 
	s->insn_read = plx_ao_rinsn; 
 
	s=dev->subdevices+2; 
	/* digital i/o subdevice */ 
	if(thisboard->have_dio){ 
		s->type=COMEDI_SUBD_DIO; 
		s->subdev_flags=SDF_READABLE|SDF_WRITABLE; 
		s->n_chan=16; 
		s->maxdata=1; 
		s->range_table=&range_digital; 
		s->insn_bits = plx_dio_insn_bits; 
		s->insn_config = plx_dio_insn_config; 
	}else{ 
		s->type = COMEDI_SUBD_UNUSED; 
	} 
	 
	printk("attached\n"); 
 
Kernel message: 
 
Jan  6 10:00:17 wema45 kernel: comedi: version 0.7.68.1 - David Schleef 
<ds_at_schleef.org> 
Jan  6 10:00:17 wema45 kernel: rt_pend_tq: RT bottom half scheduler 
initialized OK 
Jan  6 10:00:17 wema45 kernel: comedi0: plx driver 
Jan  6 10:00:17 wema45 kernel: comedi0: found plx (b:s:f=0:16:0),irq=5 
Jan  6 10:00:17 wema45 kernel: comedi0: local configuration registers at 
address 0xd800 [0x  80] 
Jan  6 10:00:17 wema45 kernel: comedi0: IO registers at address 0xd400 [0x  
40] 
Jan  6 10:00:17 wema45 kernel: Unable to handle kernel NULL pointer 
dereference at virtual address 00000018 
Jan  6 10:00:17 wema45 kernel:  printing eip: 
Jan  6 10:00:17 wema45 kernel: d0e3223f 
Jan  6 10:00:17 wema45 kernel: *pde = 00000000 
Jan  6 10:00:17 wema45 kernel: Oops: 0002 [#1] 
Jan  6 10:00:17 wema45 kernel: PREEMPT 
Jan  6 10:00:17 wema45 kernel: Modules linked in: rtai_comedi kcomedilib 
plx comedi_fc comedi rtai_shm rtai_netrpc rtai_msg rtai_mbx rtai_sem 
rtai_fifos rta 
i_lxrt rtai_hal edd joydev sg sd_mod ide_cd cdrom nvram lp ne2k_pci 
via_agp agpgart 8390 parport_pc parport nls_utf8 nls_cp437 vfat fat 
Jan  6 10:00:17 wema45 kernel: CPU:    0 
Jan  6 10:00:17 wema45 kernel: EIP:    0060:[pg0+278295103/1068707840]    
Not tainted 
Jan  6 10:00:17 wema45 kernel: EIP:    0060:[<d0e3223f>]    Not tainted 
Jan  6 10:00:17 wema45 kernel: EFLAGS: 00210246   (2.6.7-adeos) 
Jan  6 10:00:17 wema45 kernel: EIP is at plx_attach+0x1af/0x3c0 [plx] 
Jan  6 10:00:17 wema45 kernel: eax: 00000000   ebx: 0000d400   ecx: 
caef3000   edx: 00000000 
Jan  6 10:00:17 wema45 kernel: esi: 00000000   edi: c1343000   ebp: 
0000d800   esp: cb1f9e6c 
Jan  6 10:00:17 wema45 kernel: ds: 007b   es: 007b   ss: 0068 
Jan  6 10:00:17 wema45 kernel: Process comedi_config (pid: 9126, 
threadinfo=cb1f8000 task=c94b76d0) 
Jan  6 10:00:17 wema45 kernel: Stack: c1343000 d0e32d20 0000d400 00000040 
00000010 00000000 00000005 00000000 
Jan  6 10:00:17 wema45 kernel:        00000080 00000040 d0e33500 00000001 
caef30d8 caef3000 d0e41621 caef3000 
Jan  6 10:00:17 wema45 kernel:        cb1f9ee4 cb1f8000 cb1f9ee4 c0284112 
cb1f9ee4 bffff160 bffff160 00000000 
Jan  6 10:00:17 wema45 kernel: Call Trace: 
Jan  6 10:00:17 wema45 kernel:  [pg0+278357537/1068707840] 
comedi_device_attach+0x251/0x450 [comedi] 
Jan  6 10:00:17 wema45 kernel:  [<d0e41621>] 
comedi_device_attach+0x251/0x450 [comedi] 
Jan  6 10:00:17 wema45 kernel:  [copy_from_user+66/112] 
copy_from_user+0x42/0x70 
Jan  6 10:00:17 wema45 kernel:  [<c0284112>] copy_from_user+0x42/0x70 
Jan  6 10:00:17 wema45 kernel:  [pg0+278344796/1068707840] 
do_devconfig_ioctl+0xfc/0x180 [comedi] 
Jan  6 10:00:17 wema45 kernel:  [<d0e3e45c>] do_devconfig_ioctl+0xfc/0x180 
[comedi] 
Jan  6 10:00:17 wema45 kernel:  [sys_ioctl+637/752] sys_ioctl+0x27d/0x2f0 
Jan  6 10:00:17 wema45 kernel:  [<c0179c3d>] sys_ioctl+0x27d/0x2f0 
Jan  6 10:00:17 wema45 kernel:  [syscall_call+7/20] syscall_call+0x7/0x14 
Jan  6 10:00:17 wema45 kernel:  [<c0106323>] syscall_call+0x7/0x14 
Jan  6 10:00:17 wema45 kernel: 
Jan  6 10:00:17 wema45 kernel: Code: 89 78 18 8b 41 08 8b 5c 24 24 89 58 
08 8b 41 08 bb 24 00 00 
 
 
	return 1; 
} 

-- 
+++ GMX - die erste Adresse für Mail, Message, More +++
1 GB Mailbox bereits in GMX FreeMail http://www.gmx.net/de/go/mail

Received on 2005-01-06Z09:19:59