Skip to content

Commit

Permalink
spi: dw: fix potential variable assignment error
Browse files Browse the repository at this point in the history
spi::mode is defined by framework for several SPI capabilities,
such as polarity, phase, bit-endian, wire number. Directly use this
variable for setting controller's polarity and phase causes other
bit in register being set. Since SPI framework has its definition,
fetch required bit in spi::mode and set to register.
  • Loading branch information
shaftarger authored and Arsene Chen committed Dec 4, 2018
1 parent 0072a0c commit fb402d6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/spi/spi-dw.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ static int dw_spi_transfer_one(struct spi_controller *master,
/* Default SPI mode is SCPOL = 0, SCPH = 0 */
cr0 = (transfer->bits_per_word - 1)
| (chip->type << SPI_FRF_OFFSET)
| (spi->mode << SPI_MODE_OFFSET)
| ((((spi->mode & SPI_CPOL)?1:0) << SPI_SCOL_OFFSET) |
(((spi->mode & SPI_CPHA)?1:0) << SPI_SCPH_OFFSET))
| (chip->tmode << SPI_TMOD_OFFSET);

/*
Expand Down

0 comments on commit fb402d6

Please sign in to comment.