Re: [PATCH 2/2] regmap: spi: Support asynchronous I/O for SPI

From: Mark Brown
Date: Mon Jan 28 2013 - 20:54:13 EST


On Mon, Jan 28, 2013 at 05:47:36PM -0800, Stephen Boyd wrote:
> On 01/28/13 17:39, Mark Brown wrote:

> > We could but I tend not to if the interface strictly requires that the
> > pointers be type punnable.

> What is the interface requiring strict type punning here? async_write?

Yes, the async data must always be the first member of the bus specific
struct. This is to avoid having to do an additional allocation for the
bus specific private data.

> I just hope we don't move the fields around in the regmap_async_spi
> struct and then this code silently breaks. I hope the compiler is smart
> enough to skip doing any math if we used container_of() with the current
> struct layout.

It would break anyway, like I say the interface relies on it currently.
The other option is to do a callback into the bus code and return the
contained structure but it seemed more involved and this is fairly
idiomatic.

Attachment: signature.asc
Description: Digital signature