}
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");
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;
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);
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;
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;
{
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;
}
}
{
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;
}
}
{
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;
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;
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;
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;
update_supcsr(DT2821_CLRDMADNE);
- if(!s->async->data){
+ if(!s->async->prealloc_buf){
printk("async->data disappeared. dang!\n");
return;
}
update_supcsr(DT2821_CLRDMADNE);
- if(!s->async->data){
+ if(!s->async->prealloc_buf){
printk("async->data disappeared. dang!\n");
return;
}
}
}else{
while(1){
- n = s->async->data_len / sizeof(sampl_t);
+ n = s->async->prealloc_bufsz / sizeof(sampl_t);
for(i=0;i<n;i++){
if(win_in(AI_Status_1_Register)&AI_FIFO_Empty_St){
return;
async->buf_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){
} 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; }
init_async_buf( async );
- async->data = cmd->data;
- async->data_len = cmd->data_len;
-
return s->do_cmd(dev,s);
}