--- nvmain.c 2005-03-04 21:28:03.000000000 -0800 +++ newnvmain.c 2005-04-27 10:41:36.316725744 -0700 @@ -988,7 +988,7 @@ { unsigned long flags = 0; unsigned long received = 0; - unsigned long count = 0; + unsigned long count = 0, AmountToCopy = 0; int status = 0, i=0; mem_buf_t *mb = NULL; #if (ENABLE_MONO) @@ -1011,16 +1011,18 @@ spin_unlock_irqrestore(&card->lock,flags); return 0; } - + + AmountToCopy = size; while((received < size) && (!nvstream->buf[nvstream->drain_index].in_use)) { mb = (mem_buf_t *) &nvstream->buf[nvstream->drain_index]; - count = size < (nvstream->frag_size - mb->count) ? size : nvstream->frag_size - mb->count; + count = AmountToCopy < (nvstream->frag_size - mb->count) ? AmountToCopy : nvstream->frag_size - mb->count; if(nvstream->Channels > 1) { if(copy_to_user(mem,(u8*)mb->page + mb->count ,count)) { break; } mb->count += count; + AmountToCopy -= count; } #if (ENABLE_MONO) else { @@ -1040,6 +1042,7 @@ } if(status) break; + AmountToCopy = ((size - received) << 1); } #endif // once the buffer is copied add the buffer back if possible