From 637e4aebf6baea3c19ed4a1033caff96964466bb Mon Sep 17 00:00:00 2001 From: David Schleef Date: Tue, 10 Jul 2001 21:32:04 +0000 Subject: [PATCH] Fix memory leak with caldac maxdata list. Changed init of AI_Personal_Register to 0xa420. Could cause problems. --- comedi/drivers/ni_atmio.c | 2 ++ comedi/drivers/ni_mio_common.c | 14 +++++--------- comedi/drivers/ni_mio_cs.c | 2 ++ comedi/drivers/ni_pcimio.c | 4 ++-- comedi/drivers/ni_stc.h | 3 ++- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/comedi/drivers/ni_atmio.c b/comedi/drivers/ni_atmio.c index ebfca54e..42d32388 100644 --- a/comedi/drivers/ni_atmio.c +++ b/comedi/drivers/ni_atmio.c @@ -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", diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index cade1257..fb969c08 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -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;in_chans;j++){ diff --git a/comedi/drivers/ni_mio_cs.c b/comedi/drivers/ni_mio_cs.c index e69e1e1b..3316e2bc 100644 --- a/comedi/drivers/ni_mio_cs.c +++ b/comedi/drivers/ni_mio_cs.c @@ -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", diff --git a/comedi/drivers/ni_pcimio.c b/comedi/drivers/ni_pcimio.c index ea4da016..cfde55e8 100644 --- a/comedi/drivers/ni_pcimio.c +++ b/comedi/drivers/ni_pcimio.c @@ -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, diff --git a/comedi/drivers/ni_stc.h b/comedi/drivers/ni_stc.h index 0725a029..1d01168d 100644 --- a/comedi/drivers/ni_stc.h +++ b/comedi/drivers/ni_stc.h @@ -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; \ -- 2.26.2