From dcf2db0d7a21112a2fa99beaf2e3119e20e1c673 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Thu, 25 Jul 2002 23:45:33 +0000 Subject: [PATCH] Remove async->data_len globally --- comedi/comedi_fops.c | 20 +++++------------- comedi/drivers.c | 32 ++++++++++++++--------------- comedi/drivers/adl_pci9118.c | 4 ++-- comedi/drivers/adv_pci1710.c | 4 ++-- comedi/drivers/dt282x.c | 4 ++-- comedi/drivers/ni_mio_common.c | 2 +- comedi/drivers/ni_pcidio.c | 4 ++-- comedi/drivers/pcl812.c | 4 ++-- comedi/kcomedilib/kcomedilib_main.c | 3 --- 9 files changed, 32 insertions(+), 45 deletions(-) diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index 46ba591a..020bf4fd 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -471,12 +471,12 @@ static int do_bufinfo_ioctl(comedi_device *dev,void *arg) } async->buf_read_ptr += bi.bytes_read; - if( async->buf_read_ptr >= async->data_len ) - async->buf_read_ptr %= async->data_len; + if( async->buf_read_ptr >= async->prealloc_bufsz ) + async->buf_read_ptr %= async->prealloc_bufsz; async->buf_read_count += bi.bytes_read; // check for buffer overflow - if( m > async->data_len ) + if( m > async->prealloc_bufsz ) { do_cancel(dev, dev->read_subdev); DPRINTK("buffer overflow\n"); @@ -878,18 +878,8 @@ static int do_cmd_ioctl(comedi_device *dev,void *arg,void *file) goto cleanup; } -#if 0 - /* XXX this needs to be removed when the drivers are ready */ - /* They should be ready now. */ - async->cmd.data = async->prealloc_buf; - async->cmd.data_len=async->prealloc_bufsz; -#endif - init_async_buf( async ); - async->data = async->prealloc_buf; - async->data_len=async->prealloc_bufsz; - async->cb_mask = COMEDI_CB_EOA|COMEDI_CB_BLOCK|COMEDI_CB_ERROR; if(async->cmd.flags & TRIG_WAKE_EOS){ async->cb_mask |= COMEDI_CB_EOS; @@ -1343,8 +1333,8 @@ static ssize_t comedi_write_v22(struct file *file,const char *buf,size_t nbytes, n=nbytes; m = n; - if(async->buf_write_ptr + m > async->data_len){ - m = async->data_len - async->buf_write_ptr; + if(async->buf_write_ptr + m > async->prealloc_bufsz){ + m = async->prealloc_bufsz - async->buf_write_ptr; } m = comedi_buf_write_alloc(async, m); diff --git a/comedi/drivers.c b/comedi/drivers.c index 2a8541af..d0eeea84 100644 --- a/comedi/drivers.c +++ b/comedi/drivers.c @@ -394,7 +394,7 @@ static int buf_alloc(comedi_device *dev, comedi_subdevice *s, unsigned int comedi_buf_write_alloc(comedi_async *async, unsigned int nbytes) { - unsigned int free_end = async->buf_read_count + async->data_len; + unsigned int free_end = async->buf_read_count + async->prealloc_bufsz; if((int)(async->buf_free_count + nbytes - free_end) > 0){ nbytes = free_end - async->buf_free_count; @@ -408,7 +408,7 @@ unsigned int comedi_buf_write_alloc(comedi_async *async, unsigned int nbytes) unsigned int comedi_buf_write_alloc_strict(comedi_async *async, unsigned int nbytes) { - unsigned int free_end = async->buf_read_count + async->data_len; + unsigned int free_end = async->buf_read_count + async->prealloc_bufsz; if((int)(async->buf_free_count + nbytes - free_end) > 0){ nbytes = 0; @@ -424,8 +424,8 @@ void comedi_buf_write_free(comedi_async *async, unsigned int nbytes) { async->buf_write_count += nbytes; async->buf_write_ptr += nbytes; - if(async->buf_write_ptr >= async->data_len){ - async->buf_write_ptr -= async->data_len; + if(async->buf_write_ptr >= async->prealloc_bufsz){ + async->buf_write_ptr -= async->prealloc_bufsz; async->events |= COMEDI_CB_EOBUF; } } @@ -435,8 +435,8 @@ void comedi_buf_read_free(comedi_async *async, unsigned int nbytes) { async->buf_read_count += nbytes; async->buf_read_ptr += nbytes; - if(async->buf_read_ptr >= async->data_len){ - async->buf_read_ptr -= async->data_len; + if(async->buf_read_ptr >= async->prealloc_bufsz){ + async->buf_read_ptr -= async->prealloc_bufsz; } } @@ -445,19 +445,19 @@ void comedi_buf_memcpy_to( comedi_async *async, unsigned int offset, const void { unsigned int write_ptr = async->buf_write_ptr + offset; - if( write_ptr >= async->data_len ) - write_ptr -= async->data_len; + if( write_ptr >= async->prealloc_bufsz ) + write_ptr -= async->prealloc_bufsz; while( num_bytes ) { unsigned int block_size; - if( write_ptr + num_bytes > async->data_len) - block_size = async->data_len - write_ptr; + if( write_ptr + num_bytes > async->prealloc_bufsz) + block_size = async->prealloc_bufsz - write_ptr; else block_size = num_bytes; - memcpy( async->data + write_ptr, data, block_size ); + memcpy( async->prealloc_buf + write_ptr, data, block_size ); data += block_size; num_bytes -= block_size; @@ -472,17 +472,17 @@ void comedi_buf_memcpy_from(comedi_async *async, unsigned int offset, void *src; unsigned int read_ptr = async->buf_read_ptr + offset; - if( read_ptr >= async->data_len ) - read_ptr -= async->data_len; + if( read_ptr >= async->prealloc_bufsz ) + read_ptr -= async->prealloc_bufsz; while( nbytes ) { unsigned int block_size; - src = async->data + read_ptr; + src = async->prealloc_buf + read_ptr; - if( nbytes >= async->data_len - read_ptr ) - block_size = async->data_len - read_ptr; + if( nbytes >= async->prealloc_bufsz - read_ptr ) + block_size = async->prealloc_bufsz - read_ptr; else block_size = nbytes; diff --git a/comedi/drivers/adl_pci9118.c b/comedi/drivers/adl_pci9118.c index 8c53d379..31be8001 100644 --- a/comedi/drivers/adl_pci9118.c +++ b/comedi/drivers/adl_pci9118.c @@ -1471,8 +1471,8 @@ static int pci9118_ai_cmd(comedi_device *dev,comedi_subdevice *s) devpriv->ai_n_chan=cmd->chanlist_len; devpriv->ai_n_scanlen=cmd->scan_end_arg; devpriv->ai_chanlist=cmd->chanlist; - devpriv->ai_data=s->async->data; - devpriv->ai_data_len=s->async->data_len; + devpriv->ai_data=s->async->prealloc_buf; + devpriv->ai_data_len=s->async->prealloc_bufsz; devpriv->ai_timer1=0; devpriv->ai_timer2=0; devpriv->ai_add_front=0; diff --git a/comedi/drivers/adv_pci1710.c b/comedi/drivers/adv_pci1710.c index c7f528db..91309da3 100644 --- a/comedi/drivers/adv_pci1710.c +++ b/comedi/drivers/adv_pci1710.c @@ -907,8 +907,8 @@ static int pci171x_ai_cmd(comedi_device *dev,comedi_subdevice *s) devpriv->ai_n_chan=cmd->chanlist_len; devpriv->ai_chanlist=cmd->chanlist; devpriv->ai_flags=cmd->flags; - devpriv->ai_data_len=s->async->data_len; - devpriv->ai_data=s->async->data; + devpriv->ai_data_len=s->async->prealloc_bufsz; + devpriv->ai_data=s->async->prealloc_buf; devpriv->ai_timer1=0; devpriv->ai_timer2=0; diff --git a/comedi/drivers/dt282x.c b/comedi/drivers/dt282x.c index 40145f72..f0335b41 100644 --- a/comedi/drivers/dt282x.c +++ b/comedi/drivers/dt282x.c @@ -432,7 +432,7 @@ static void dt282x_ao_dma_interrupt(comedi_device * dev) update_supcsr(DT2821_CLRDMADNE); - if(!s->async->data){ + if(!s->async->prealloc_buf){ printk("async->data disappeared. dang!\n"); return; } @@ -472,7 +472,7 @@ static void dt282x_ai_dma_interrupt(comedi_device * dev) update_supcsr(DT2821_CLRDMADNE); - if(!s->async->data){ + if(!s->async->prealloc_buf){ printk("async->data disappeared. dang!\n"); return; } diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index a37722ab..622f57a6 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -717,7 +717,7 @@ static void ni_handle_fifo_dregs(comedi_device *dev) } }else{ while(1){ - n = s->async->data_len / sizeof(sampl_t); + n = s->async->prealloc_bufsz / sizeof(sampl_t); for(i=0;ibuf_write_count += count; async->buf_write_ptr += count; - if(async->buf_write_ptr >= async->data_len){ - async->buf_write_ptr -= async->data_len; + if(async->buf_write_ptr >= async->prealloc_bufsz){ + async->buf_write_ptr -= async->prealloc_bufsz; } mite->current_link++; if(mite->current_link >= mite->n_links){ diff --git a/comedi/drivers/pcl812.c b/comedi/drivers/pcl812.c index 136d17c6..6ec62498 100644 --- a/comedi/drivers/pcl812.c +++ b/comedi/drivers/pcl812.c @@ -772,8 +772,8 @@ static int pcl812_ai_cmd(comedi_device *dev,comedi_subdevice *s) } else devpriv->ai_dma=0; devpriv->ai_flags=cmd->flags; - devpriv->ai_data_len=s->async->data_len; - devpriv->ai_data=s->async->data; + devpriv->ai_data_len=s->async->prealloc_bufsz; + devpriv->ai_data=s->async->prealloc_buf; if (cmd->stop_src==TRIG_COUNT) { devpriv->ai_scans=cmd->stop_arg; devpriv->ai_neverending=0; } else { devpriv->ai_scans=0; devpriv->ai_neverending=1; } diff --git a/comedi/kcomedilib/kcomedilib_main.c b/comedi/kcomedilib/kcomedilib_main.c index 0e4a2460..0a4fee69 100644 --- a/comedi/kcomedilib/kcomedilib_main.c +++ b/comedi/kcomedilib/kcomedilib_main.c @@ -160,9 +160,6 @@ int comedi_command(comedi_t *d,comedi_cmd *cmd) init_async_buf( async ); - async->data = cmd->data; - async->data_len = cmd->data_len; - return s->do_cmd(dev,s); } -- 2.26.2