static int do_devconfig_ioctl(comedi_device *dev,comedi_devconfig *arg,kdev_t minor)
{
comedi_devconfig it;
+ int ret;
+ unsigned char *aux_data = NULL;
+ int aux_len;
if(!suser())
return -EPERM;
it.board_name[COMEDI_NAMELEN-1]=0;
- return comedi_device_attach(dev,&it);
+ if(it.options[COMEDI_DEVCONF_AUX_DATA] &&
+ it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH]){
+ aux_len = it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
+ if(aux_len<0)return -EFAULT;
+
+ aux_data = kmalloc(aux_len, GFP_KERNEL);
+ if(!aux_data)return -EFAULT;
+
+ if(copy_from_user(aux_data,
+ (void *)it.options[COMEDI_DEVCONF_AUX_DATA], aux_len)){
+ kfree(aux_data);
+ return -EFAULT;
+ }
+
+ it.options[COMEDI_DEVCONF_AUX_DATA] = (unsigned long)aux_data;
+ }
+
+ ret = comedi_device_attach(dev,&it);
+
+ if(aux_data) kfree(aux_data);
+
+ return ret;
}
/*
int result = 0;
comedi_subdevice *s;
struct pci_dev *card = NULL;
+ void *aux_data;
+ unsigned int aux_len;
printk("comedi%d: daqboard2000:", dev->minor);
pci_read_config_byte(card, PCI_INTERRUPT_LINE, &interrupt);
printk("Interrupt before is: %x\n", interrupt);
*/
- if(it->options[0] && it->options[1]){
- void *ptr;
- unsigned int size = it->options[1];
-
- /* Note: using copy_from_user here is a hack. I would prefer
- * to have a generic solution for copying extended data at
- * device configuration, but that will require changes to the
- * devconfig interface. Wait until devconfig gets a little
- * more crufty (than it already is?!?), and then fix it. -ds */
- ptr = kmalloc(size,GFP_KERNEL);
- if(!ptr){
- result=-ENOMEM;
- goto out;
- }
- if(copy_from_user(ptr,(void *)it->options[0],size)){
- result=-EFAULT;
- goto out;
- }
- result = initialize_daqboard2000(dev,ptr,size);
- kfree(ptr);
+
+ aux_data = (void *)it->options[COMEDI_DEVCONF_AUX_DATA];
+ aux_len = it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
+
+ if(aux_data && aux_len){
+ result = initialize_daqboard2000(dev, aux_data, aux_len);
}else{
-#ifdef CONFIG_COMEDI_DAQBOARD2000_FPGA
- result = initialize_daqboard2000(dev,bTopBitArray,bTopBitSize);
-#else
printk("no FPGA initialization code, aborting\n");
result=-EIO;
-#endif
}
if(result<0)goto out;
daqboard2000_initializeAdc(dev);
#include <linux/pci.h>
-#include "me2600_fw.h"
+//#include "me2600_fw.h"
#define ME_DRIVER_NAME "me_daq"
// Xilinx firmware download for card: ME-2600i
//
-static int me2600_xilinx_download(comedi_device *dev)
+static int me2600_xilinx_download(comedi_device *dev, unsigned char
+ *me2600_firmware, unsigned int length)
{
unsigned int value;
unsigned int file_length;
* Byte 8-11: date
* Byte 12-15: reserved
*/
+ if(length<16)return -EINVAL;
file_length =
(((unsigned int)me2600_firmware[0] & 0xff)<<24) +
(((unsigned int)me2600_firmware[1] & 0xff)<<16) +
// Download firmware and reset card
if(board->device_id == ME2600_DEVICE_ID)
{
- me2600_xilinx_download(dev);
+ unsigned char *aux_data;
+ int aux_len;
+
+ aux_data = (unsigned char *)it->options[COMEDI_DEVCONF_AUX_DATA];
+ aux_len = it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
+
+ if(!aux_data || aux_len)return -EINVAL;
+
+ me2600_xilinx_download(dev, aux_data, aux_len);
}
me_reset(dev);
/* number of config options in the config structure */
#define COMEDI_NDEVCONFOPTS 32
+#define COMEDI_DEVCONF_AUX_DATA 30
+#define COMEDI_DEVCONF_AUX_DATA_LENGTH 31
/* max length of device and driver names */
#define COMEDI_NAMELEN 20