Changeset 1513 for trunk/linux_spi.c


Ignore:
Timestamp:
Mar 6, 2012, 11:17:06 PM (3 years ago)
Author:
mkarcher
Message:

Prevent submission of empty read requests in linux_spi.

The submission of zero-sized read requests in a write-only transaction
fails at least for omap2_mcspi drivers and is pointless in general.

This patch does not address the implementation of zero-sized writes (which
would need to skip the write command), as there are no flash transactions
not starting with a command.

Signed-off-by: Michael Karcher <flashrom@…>
Acked-by: Stefan Tauner <stefan.tauner@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/linux_spi.c

    r1512 r1513  
    131131                                  unsigned char *rxbuf) 
    132132{ 
     133        int iocontrol_code; 
    133134        struct spi_ioc_transfer msg[2] = { 
    134135                { 
     
    144145        if (fd == -1) 
    145146                return -1; 
     147        /* The implementation currently does not support requests that 
     148           don't start with sending a command. */ 
     149        if (writecnt == 0) 
     150                return SPI_INVALID_LENGTH; 
    146151 
    147         if (ioctl(fd, SPI_IOC_MESSAGE(2), msg) == -1) { 
     152        /* Just submit the first (write) request in case there is nothing 
     153           to read. Otherwise submit both requests. */ 
     154        if (readcnt == 0) 
     155                iocontrol_code = SPI_IOC_MESSAGE(1); 
     156        else 
     157                iocontrol_code = SPI_IOC_MESSAGE(2); 
     158 
     159        if (ioctl(fd, iocontrol_code, msg) == -1) { 
    148160                msg_cerr("%s: ioctl: %s\n", __func__, strerror(errno)); 
    149161                return -1; 
Note: See TracChangeset for help on using the changeset viewer.