Skip to contentSkip to conversation

spi: spi-xcomm: Fix wrong setting for SPI_XCOMM_SETTINGS_CPHA

PATCH In review Axel Lin 2 participants 2 messages Dec 4, 2012 – Dec 5, 2012 SPI

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 spi: spi-xcomm: Fix wrong setting for SPI_XCOMM_SETTINGS_CPHA

The logic of setting SPI_XCOMM_SETTINGS_CPHA bit is reversed.

---
Hi Lars,
The logic of setting SPI_XCOMM_SETTINGS_CPHA bit looks wrong to me. Can you check if this patch works?

Thanks,
Axel

 drivers/spi/spi-xcomm.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-xcomm.c +2 -2
index 266a847..c2a3e8f 100644
@@ -99,9 +99,9 @@ static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm,
 		*settings &= ~SPI_XCOMM_SETTINGS_CPOL;
 
 	if (spi->mode & SPI_CPHA)
-		*settings &= ~SPI_XCOMM_SETTINGS_CPHA;
-	else
 		*settings |= SPI_XCOMM_SETTINGS_CPHA;
+	else
+		*settings &= ~SPI_XCOMM_SETTINGS_CPHA;
 
 	if (spi->mode & SPI_3WIRE)
 		*settings |= SPI_XCOMM_SETTINGS_3WIRE;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 10 lines · Axel Lin

The logic of setting SPI_XCOMM_SETTINGS_CPHA bit is reversed.

---
Hi Lars,
The logic of setting SPI_XCOMM_SETTINGS_CPHA bit looks wrong to me. Can you check if this patch works?

Thanks,
Axel

Hi Axel,

Thanks for the patch. But the code is correct as it is. The CPHA definition of the chip is inverted to that of Linux.

Thanks,
- Lars

Quoted 20 lines
 drivers/spi/spi-xcomm.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/spi-xcomm.c +2 -2
index 266a847..c2a3e8f 100644
@@ -99,9 +99,9 @@ static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm,
 		*settings &= ~SPI_XCOMM_SETTINGS_CPOL;
 
 	if (spi->mode & SPI_CPHA)
-		*settings &= ~SPI_XCOMM_SETTINGS_CPHA;
-	else
 		*settings |= SPI_XCOMM_SETTINGS_CPHA;
+	else
+		*settings &= ~SPI_XCOMM_SETTINGS_CPHA;
 
 	if (spi->mode & SPI_3WIRE)
 		*settings |= SPI_XCOMM_SETTINGS_3WIRE;