[flashrom] [PATCH] Add Linux SPI support
Sven Schnelle
svens at stackframe.org
Mon Sep 5 22:09:48 CEST 2011
Uwe Hermann <uwe at hermann-uwe.de> writes:
> On Wed, Mar 02, 2011 at 11:56:43PM +0100, Carl-Daniel Hailfinger wrote:
>> > Signed-off-by: Sven Schnelle <svens at stackframe.org>
>
> Thanks, committed as r1427 with a few changes as proposed below, and
> with more changes due to forward-porting to current flashrom trunk.
Thanks! I must admit that i actually forgot about that patch (but using
it for about half a year now ;-)
>> > +int linux_spi_send_command(unsigned int writecnt, unsigned int readcnt,
>> > + const unsigned char *txbuf, unsigned char *rxbuf)
>> > +{
>> > + struct spi_ioc_transfer msg[2] = {
>> > + { .tx_buf = (unsigned long)txbuf, .len = writecnt },
>> > + { .rx_buf = (unsigned long)rxbuf, .len = readcnt }
>> >
>>
>> Really unsigned long casts for txbuf and rxbuf?
>
> Required it seems, as otherwise:
>
> linux_spi.c:111:4: error: initialization makes integer from pointer without a cast [-Werror]
> linux_spi.c:111:4: error: (near initialization for ‘msg[0].tx_buf’) [-Werror]
> etc.
>
> This is due to .tx_buf/.rx_buf being defined as __u64 in linux/spi/spidev.h:
>
> struct spi_ioc_transfer {
> __u64 tx_buf;
> __u64 rx_buf;
> ...
> }
>
> I changed "unsigned long" to "uint64_t", though.
That breaks compilation on 32bit for me (AVR32 is 32bit):
linux_spi.c:110: warning: cast from pointer to integer of different size
linux_spi.c:114: warning: cast from pointer to integer of different size
I've changed the code to:
Index: linux_spi.c
===================================================================
--- linux_spi.c (revision 1427)
+++ linux_spi.c (working copy)
@@ -107,11 +107,11 @@
{
struct spi_ioc_transfer msg[2] = {
{
- .tx_buf = (uint64_t)txbuf,
+ .tx_buf = (uint64_t)(ptrdiff_t)txbuf,
.len = writecnt,
},
{
- .rx_buf = (uint64_t)rxbuf,
+ .rx_buf = (uint64_t)(ptrdiff_t)rxbuf,
.len = readcnt,
},
};
> Sven, can you please check if trunk works for you, and/or fix it if I
> broke stuff? Also, do you plan to work on addressing the other TODOs?
> I guess I have some board where I can test this driver too, but it will
> take a while to setup etc.
I've did a short test with the patch above, and flashrom works fine on
linux-2.6.38. Will respond to the other TODOs in a seperate Mail.
Sven.
More information about the flashrom
mailing list