HOW to do BUFFER COPY in LINUX KERNEL
Hi all ,
I am working for an DMA driver on LINUX 2.6.32.
I having having the DMA data from the device in BUFFER A[using dma_alloc_coherent] such that
char *dmasrcptr =dma_alloc_coherent(NULL,GLOBAL_BUFFER_SIZE,&dmadest,0);
Now from user space i am getting an structure which has the buffer on which need to do copy this buffer.
typedef struct {
unsigned int value;
unsigned char charbuf[GLOBAL_BUFFER_SIZE];
}driver_struct;
At present i am doing an copy to user_buffer[in structure] using an for loop.
like :-
a. I am assigning an local char pointer.
b. This pointer i am initializing to BUFFER of user structure.
c. Then using FOR loop i am acessing data from DMA buffer and storing it in user buffer [in structure] using for loop.
Can any one please let me know if there is any better method or an optimized function call.{ like MEMCPY }
Thanks
Ashish Mishra
|