aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/spi/spi_fsl_espi.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/spi/spi_fsl_espi.c b/drivers/spi/spi_fsl_espi.c
index ae789262c98..a99e2333b94 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)
258 return mpc8xxx_spi->count; 258 return mpc8xxx_spi->count;
259} 259}
260 260
261static void fsl_espi_addr2cmd(unsigned int addr, u8 *cmd) 261static inline void fsl_espi_addr2cmd(unsigned int addr, u8 *cmd)
262{ 262{
263 if (cmd[1] && cmd[2] && cmd[3]) { 263 if (cmd) {
264 cmd[1] = (u8)(addr >> 16); 264 cmd[1] = (u8)(addr >> 16);
265 cmd[2] = (u8)(addr >> 8); 265 cmd[2] = (u8)(addr >> 8);
266 cmd[3] = (u8)(addr >> 0); 266 cmd[3] = (u8)(addr >> 0);
267 } 267 }
268} 268}
269 269
270static unsigned int fsl_espi_cmd2addr(u8 *cmd) 270static inline unsigned int fsl_espi_cmd2addr(u8 *cmd)
271{ 271{
272 if (cmd[1] && cmd[2] && cmd[3]) 272 if (cmd)
273 return cmd[1] << 16 | cmd[2] << 8 | cmd[3] << 0; 273 return cmd[1] << 16 | cmd[2] << 8 | cmd[3] << 0;
274 274
275 return 0; 275 return 0;
@@ -395,9 +395,11 @@ static void fsl_espi_rw_trans(struct spi_message *m,
395 } 395 }
396 } 396 }
397 397
398 addr = fsl_espi_cmd2addr(local_buf); 398 if (pos > 0) {
399 addr += pos; 399 addr = fsl_espi_cmd2addr(local_buf);
400 fsl_espi_addr2cmd(addr, local_buf); 400 addr += pos;
401 fsl_espi_addr2cmd(addr, local_buf);
402 }
401 403
402 espi_trans->n_tx = n_tx; 404 espi_trans->n_tx = n_tx;
403 espi_trans->n_rx = trans_len; 405 espi_trans->n_rx = trans_len;