On Fri, Feb 10, 2012 at 02:43:43PM +0530, Laxman Dewangan wrote: Please remember to delete unnneded context from your mails, it makes it much easier to find what you're saying. > So I am going to allocate buffer for some size, initially > min(val_bytes * max_register, 128) bytes, and in bulk_write(), if > require buffer is more than 128 then re-alloc buffer which is now > (req_size + 128). > And then copy the data into this buffer, modify it and send to device. What I'd suggest doing as a first pass is just allocating the buffer each time, anything else is a performance optimisation we can worry about incrementally. Remember, this only has to be faster than I2C most of the time and I2C is really slow. For your case with 8 byte values there's an even better optimisation which is to notice that we don't need to swap at all and just use the original buffer directly.
Attachment:
signature.asc
Description: Digital signature