Fix memory leak with caldac maxdata list.
authorDavid Schleef <ds@schleef.org>
Tue, 10 Jul 2001 21:32:04 +0000 (21:32 +0000)
committerDavid Schleef <ds@schleef.org>
Tue, 10 Jul 2001 21:32:04 +0000 (21:32 +0000)
Changed init of AI_Personal_Register to 0xa420.  Could cause problems.

comedi/drivers/ni_atmio.c
comedi/drivers/ni_mio_common.c
comedi/drivers/ni_mio_cs.c
comedi/drivers/ni_pcimio.c
comedi/drivers/ni_stc.h

index ebfca54e3cfb5f33067867229f62d6702cfd2769..42d3238841a2520fa265393944dc13fa15623ce9 100644 (file)
@@ -86,6 +86,8 @@
 static struct caldac_struct *type1[]={&caldac_mb88341,NULL,NULL};
 static struct caldac_struct *type2[]={&caldac_dac8800,&caldac_dac8043,NULL};
 
+#define MAX_N_CALDACS 12
+
 static ni_board ni_boards[]={
        {       device_id:      44,
                name:           "at-mio-16e-1",
index cade125744a00afc8953d47888ec12a70bab0230..fb969c087f7ce9291f644ac6f84f6904acd63fb1 100644 (file)
@@ -888,14 +888,7 @@ static int ni_ai_reset(comedi_device *dev,comedi_subdevice *s)
 #else
        win_out((0<<6)|0x0000,AI_Mode_3_Register); /* generate FIFO interrupts on non-empty */
 #endif
-       /* TIM 5/11/01 
-       0xA4A0 causes overrun errors at high speeds.  0xA420 fixes it,
-       but I haven't tested to see if it breaks something else. I don't think it would*/
-       #ifdef PCIDMA  
        win_out(0xA420,AI_Personal_Register); 
-       #else
-       win_out(0xa4a0,AI_Personal_Register); /* ? */
-       #endif
        win_out(0x032e,AI_Output_Control_Register);
        win_out(0x0060,AI_Trigger_Select_Register); /* trigger source */
 
@@ -1953,9 +1946,9 @@ static int ni_E_init(comedi_device *dev,comedi_devconfig *it)
        s=dev->subdevices+5;
        s->type=COMEDI_SUBD_CALIB;
        s->subdev_flags=SDF_WRITEABLE|SDF_INTERNAL;
-       caldac_setup(dev,s);
        s->insn_read=ni_calib_insn_read;
        s->insn_write=ni_calib_insn_write;
+       caldac_setup(dev,s);
        
        /* EEPROM */
        s=dev->subdevices+6;
@@ -2114,7 +2107,10 @@ static void caldac_setup(comedi_device *dev,comedi_subdevice *s)
        if(diffbits){
                int chan;
 
-               s->maxdata_list=kmalloc(sizeof(int)*n_chans,GFP_KERNEL);
+               if(n_chans>=MAX_N_CALDACS){
+                       printk("BUG! MAX_N_CALDACS too small\n");
+               }
+               s->maxdata_list=devpriv->caldac_maxdata_list;
                chan=0;
                for(i=0;i<n_dacs;i++){
                        for(j=0;j<boardtype.caldac[i]->n_chans;j++){
index e69e1e1b1f05b54b00457efb9605ec162688ed5d..3316e2bce2b16b4a36340f08acbabcdd19b346c7 100644 (file)
@@ -67,6 +67,8 @@
 static struct caldac_struct *type1[]={&caldac_mb88341,NULL,NULL};
 static struct caldac_struct *type2[]={&caldac_dac8800,&caldac_dac8043,NULL};
 
+#define MAX_N_CALDACS 12
+
 static ni_board ni_boards[]={
        {       device_id:      0x010d,
                name:           "DAQCard-ai-16xe-50",
index ea4da016e354c989b6e41820bd017eadd8cd7968..cfde55e8ef74f8a845af21318507a7a7b7e48b05 100644 (file)
@@ -89,6 +89,8 @@ static struct caldac_struct *type2[]={&caldac_dac8800,&caldac_dac8043,&caldac_ad
 static struct caldac_struct *type3[]={&caldac_mb88341,NULL,NULL};
 static struct caldac_struct *type4[]={&caldac_mb88341,&caldac_mb88341,&caldac_ad8522};
 
+#define MAX_N_CALDACS (12+12+1)
+
 
 static ni_board ni_boards[]={
        {       device_id:      0x0162, // NI also says 0x1620.  typo?
@@ -404,8 +406,6 @@ static ni_board ni_boards[]={
                ao_fifo_depth:  16384,
                caldac:         type4,          /* XXX */
        },
-
-//TIM 5/14/01
         {       device_id:      0x15b0,
                 name:           "pxi-6071e",
                 n_adchan:       64,
index 0725a0292128494945268b95dac94f13fedf4e28..1d01168dd1586ed7969230e1b515606807c356e3 100644 (file)
@@ -603,6 +603,7 @@ static ni_board ni_boards[];
        int changain_state;                                     \
        unsigned int changain_spec;                             \
                                                                \
+       unsigned int caldac_maxdata_list[MAX_N_CALDACS];        \
        unsigned short ao[2];                                   \
        unsigned short caldacs[12];                             \
                                                                \
@@ -615,7 +616,7 @@ static ni_board ni_boards[];
        unsigned short ao_trigger_select;                       \
                                                                \
        unsigned short gpct_mode[2];                            \
-       unsigned short gpct_command[2];                 \
+       unsigned short gpct_command[2];                         \
        unsigned short gpct_input_select[2];                    \
        int gpct_cur_operation[2];                              \
        unsigned short an_trig_etc_reg;                         \