On Fri, Aug 26, 2011 at 9:31 AM, Arnd Bergmann arnd@arndb.de wrote:
On Friday 26 August 2011, Sumit Semwal wrote:
On Aug 26, 2011 4:03 PM, "Arnd Bergmann" arnd@arndb.de wrote:
On Thursday 25 August 2011, Sumit Semwal wrote:
Hmmm... Do you mean the platform driver (device?) ptr? That's a good
idea -
I will make these changes you suggested, and re-post. I'm thinking of posting the next version to the upstream mailing lists as well.
Btw, does this mean we can 'assume' that all users/allocators of dma-buf would be platform devices?
You can pass any struct device, since the pointer is only used by the driver that set the pointer it will be able to cast it back to the derived type.
I think the idea here is for the original allocator to know that it allocated a given buffer; so the struct device here is used more as an identifier.
Wouldn't it know that implicitly because the function that it's in was called from a pointer in the buffer structure that can only be set by the driver that created that buffer?
yeah, you're right.. brain-fart on my part, I can just check 'if (buf->ops == &my_ops) ...'
I don't think there is a value in identifying the driver at all, what you need is an identification of the device. Of course when you have the device, any code can compare the dev->drv pointer to check which driver belongs to it, but I think that's not necessary.
I could go either way here, either 'if (buf->ops == &my_ops && ((struct my_priv)buf->priv)->dev == my_dev)' or 'if (buf->dev == my_dev)'.. the latter is more concise. I guess it depends on how common you expect to have multiple instances of same driver
BR, -R
Arnd