diff options
author | Mingkai Hu <Mingkai.hu@freescale.com> | 2010-12-21 09:27:02 +0800 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-12-24 01:53:57 -0700 |
commit | 0dd2c96f19b0cffaeb437e50fa5da195920c6e78 (patch) | |
tree | b8581f7c418ec4bbc58737b8344a398eb0b94a65 /drivers/spi | |
parent | e6289d63a6f39237a027dcee46366ba158cb8406 (diff) | |
download | kernel_samsung_smdk4412-0dd2c96f19b0cffaeb437e50fa5da195920c6e78.zip kernel_samsung_smdk4412-0dd2c96f19b0cffaeb437e50fa5da195920c6e78.tar.gz kernel_samsung_smdk4412-0dd2c96f19b0cffaeb437e50fa5da195920c6e78.tar.bz2 |
spi/fsl_espi: fix wrong setting of the address in the command buffer
Or else we can't operate on the right address when the trans length
is greater than 65535.
Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi_fsl_espi.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/spi/spi_fsl_espi.c b/drivers/spi/spi_fsl_espi.c index ae78926..a99e233 100644 --- a/drivers/spi/spi_fsl_espi.c +++ b/drivers/spi/spi_fsl_espi.c @@ -258,18 +258,18 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t) return mpc8xxx_spi->count; } -static void fsl_espi_addr2cmd(unsigned int addr, u8 *cmd) +static inline void fsl_espi_addr2cmd(unsigned int addr, u8 *cmd) { - if (cmd[1] && cmd[2] && cmd[3]) { + if (cmd) { cmd[1] = (u8)(addr >> 16); cmd[2] = (u8)(addr >> 8); cmd[3] = (u8)(addr >> 0); } } -static unsigned int fsl_espi_cmd2addr(u8 *cmd) +static inline unsigned int fsl_espi_cmd2addr(u8 *cmd) { - if (cmd[1] && cmd[2] && cmd[3]) + if (cmd) return cmd[1] << 16 | cmd[2] << 8 | cmd[3] << 0; return 0; @@ -395,9 +395,11 @@ static void fsl_espi_rw_trans(struct spi_message *m, } } - addr = fsl_espi_cmd2addr(local_buf); - addr += pos; - fsl_espi_addr2cmd(addr, local_buf); + if (pos > 0) { + addr = fsl_espi_cmd2addr(local_buf); + addr += pos; + fsl_espi_addr2cmd(addr, local_buf); + } espi_trans->n_tx = n_tx; espi_trans->n_rx = trans_len; |