Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 337698
b: refs/heads/master
c: fce7c3e
h: refs/heads/master
v: v3
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Nov 5, 2012
1 parent f5aa3ba commit dd601bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5daa751f89eb3e73424d0cb5c204f9e0bc14e25c
refs/heads/master: fce7c3eac7d4ca77ada5bf8332f867219fbb5068
28 changes: 13 additions & 15 deletions trunk/drivers/staging/iio/adc/ad7887.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct ad7887_state {
struct spi_transfer xfer[4];
struct spi_message msg[3];
struct spi_message *ring_msg;
unsigned char tx_cmd_buf[8];
unsigned char tx_cmd_buf[4];

/*
* DMA (thus cache coherency maintenance) requires the
Expand Down Expand Up @@ -238,6 +238,7 @@ static int __devinit ad7887_probe(struct spi_device *spi)
struct ad7887_platform_data *pdata = spi->dev.platform_data;
struct ad7887_state *st;
struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
uint8_t mode;
int ret;

if (indio_dev == NULL)
Expand Down Expand Up @@ -271,9 +272,13 @@ static int __devinit ad7887_probe(struct spi_device *spi)

/* Setup default message */

st->tx_cmd_buf[0] = AD7887_CH_AIN0 | AD7887_PM_MODE4 |
((pdata && pdata->use_onchip_ref) ?
0 : AD7887_REF_DIS);
mode = AD7887_PM_MODE4;
if (!pdata || !pdata->use_onchip_ref)
mode |= AD7887_REF_DIS;
if (pdata && pdata->en_dual)
mode |= AD7887_DUAL;

st->tx_cmd_buf[0] = AD7887_CH_AIN0 | mode;

st->xfer[0].rx_buf = &st->data[0];
st->xfer[0].tx_buf = &st->tx_cmd_buf[0];
Expand All @@ -283,29 +288,22 @@ static int __devinit ad7887_probe(struct spi_device *spi)
spi_message_add_tail(&st->xfer[0], &st->msg[AD7887_CH0]);

if (pdata && pdata->en_dual) {
st->tx_cmd_buf[0] |= AD7887_DUAL | AD7887_REF_DIS;

st->tx_cmd_buf[2] = AD7887_CH_AIN1 | AD7887_DUAL |
AD7887_REF_DIS | AD7887_PM_MODE4;
st->tx_cmd_buf[4] = AD7887_CH_AIN0 | AD7887_DUAL |
AD7887_REF_DIS | AD7887_PM_MODE4;
st->tx_cmd_buf[6] = AD7887_CH_AIN1 | AD7887_DUAL |
AD7887_REF_DIS | AD7887_PM_MODE4;
st->tx_cmd_buf[2] = AD7887_CH_AIN1 | mode;

st->xfer[1].rx_buf = &st->data[0];
st->xfer[1].tx_buf = &st->tx_cmd_buf[2];
st->xfer[1].len = 2;

st->xfer[2].rx_buf = &st->data[2];
st->xfer[2].tx_buf = &st->tx_cmd_buf[4];
st->xfer[2].tx_buf = &st->tx_cmd_buf[0];
st->xfer[2].len = 2;

spi_message_init(&st->msg[AD7887_CH0_CH1]);
spi_message_add_tail(&st->xfer[1], &st->msg[AD7887_CH0_CH1]);
spi_message_add_tail(&st->xfer[2], &st->msg[AD7887_CH0_CH1]);

st->xfer[3].rx_buf = &st->data[0];
st->xfer[3].tx_buf = &st->tx_cmd_buf[6];
st->xfer[3].rx_buf = &st->data[2];
st->xfer[3].tx_buf = &st->tx_cmd_buf[2];
st->xfer[3].len = 2;

spi_message_init(&st->msg[AD7887_CH1]);
Expand Down

0 comments on commit dd601bb

Please sign in to comment.