Skip to content

Commit 5e4f99a

Browse files
dbogdanjic23
authored andcommitted
staging: iio: ad2s1210: Fix SPI reading
If the serial interface is used, the 8-bit address should be latched using the rising edge of the WR/FSYNC signal. This basically means that a CS change is required between the first byte sent, and the second one. This change splits the single-transfer transfer of 2 bytes into 2 transfers with a single byte, and CS change in-between. Note fixes tag is not accurate, but reflects a point beyond which there are too many refactors to make backporting straight forward. Fixes: b19e9ad ("staging:iio:resolver:ad2s1210 general driver cleanup.") Signed-off-by: Dragos Bogdan <[email protected]> Signed-off-by: Alexandru Ardelean <[email protected]> Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent aad4742 commit 5e4f99a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/staging/iio/resolver/ad2s1210.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,24 @@ static int ad2s1210_config_write(struct ad2s1210_state *st, u8 data)
130130
static int ad2s1210_config_read(struct ad2s1210_state *st,
131131
unsigned char address)
132132
{
133-
struct spi_transfer xfer = {
134-
.len = 2,
135-
.rx_buf = st->rx,
136-
.tx_buf = st->tx,
133+
struct spi_transfer xfers[] = {
134+
{
135+
.len = 1,
136+
.rx_buf = &st->rx[0],
137+
.tx_buf = &st->tx[0],
138+
.cs_change = 1,
139+
}, {
140+
.len = 1,
141+
.rx_buf = &st->rx[1],
142+
.tx_buf = &st->tx[1],
143+
},
137144
};
138145
int ret = 0;
139146

140147
ad2s1210_set_mode(MOD_CONFIG, st);
141148
st->tx[0] = address | AD2S1210_MSB_IS_HIGH;
142149
st->tx[1] = AD2S1210_REG_FAULT;
143-
ret = spi_sync_transfer(st->sdev, &xfer, 1);
150+
ret = spi_sync_transfer(st->sdev, xfers, 2);
144151
if (ret < 0)
145152
return ret;
146153

0 commit comments

Comments
 (0)