On 15/02/11 20:04, Thomas Chou wrote: > Dear Ryan, > > On 02/14/2011 10:20 AM, Ryan Mallon wrote: >> On 02/14/2011 03:10 PM, Thomas Chou wrote: >>> This patch adds a new SPI driver to support the Altera SOPC Builder >>> SPI component. It uses the bitbanging library. >>> >>> Signed-off-by: Thomas Chou<tho...@wytron.com.tw> >>> --- >> >>> +struct altera_spi { >>> + /* bitbang has to be first */ >>> + struct spi_bitbang bitbang; >> >> Is this still true? I had a quick look and can't see anything which >> relies on spi_bitbang being the first entry. Things like this should be >> using container_of so that position in the struct is irrelevant. >> >> ~Ryan >> > > Yes, sadly true. This is due to the implementation of the bitbanging > library, spi_bitbang.c, which assumes the struct spi_bitbang is the > first of drvdata. Though it could be changed in the future (beyond this > little driver), every bitbanging library user has to follow this for now.
Hmm, I see how it works now. Shouldn't the conversion be done like this: struct spi_bitbang *bitbang = spi_master_get_devdata(master); struct altera_spi *altera = container_of(bitbang, struct altera_spi, bitbang); Which doesn't require the bitbang field to be the first in the struct and makes it more clear what is actually going on. The above could be wrapped into a to_altera_spi macro. ~Ryan ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ spi-devel-general mailing list spi-devel-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spi-devel-general