|
@@ -134,6 +134,8 @@ struct ad7280_state {
|
|
unsigned char aux_threshhigh;
|
|
unsigned char aux_threshhigh;
|
|
unsigned char aux_threshlow;
|
|
unsigned char aux_threshlow;
|
|
unsigned char cb_mask[AD7280A_MAX_CHAIN];
|
|
unsigned char cb_mask[AD7280A_MAX_CHAIN];
|
|
|
|
+
|
|
|
|
+ __be32 buf[2] ____cacheline_aligned;
|
|
};
|
|
};
|
|
|
|
|
|
static void ad7280_crc8_build_table(unsigned char *crc_tab)
|
|
static void ad7280_crc8_build_table(unsigned char *crc_tab)
|
|
@@ -189,22 +191,22 @@ static void ad7280_delay(struct ad7280_state *st)
|
|
msleep(1);
|
|
msleep(1);
|
|
}
|
|
}
|
|
|
|
|
|
-static int __ad7280_read32(struct spi_device *spi, unsigned *val)
|
|
|
|
|
|
+static int __ad7280_read32(struct ad7280_state *st, unsigned *val)
|
|
{
|
|
{
|
|
- __be32 rx_buf, tx_buf = cpu_to_be32(AD7280A_READ_TXVAL);
|
|
|
|
int ret;
|
|
int ret;
|
|
-
|
|
|
|
struct spi_transfer t = {
|
|
struct spi_transfer t = {
|
|
- .tx_buf = &tx_buf,
|
|
|
|
- .rx_buf = &rx_buf,
|
|
|
|
|
|
+ .tx_buf = &st->buf[0],
|
|
|
|
+ .rx_buf = &st->buf[1],
|
|
.len = 4,
|
|
.len = 4,
|
|
};
|
|
};
|
|
|
|
|
|
- ret = spi_sync_transfer(spi, &t, 1);
|
|
|
|
|
|
+ st->buf[0] = cpu_to_be32(AD7280A_READ_TXVAL);
|
|
|
|
+
|
|
|
|
+ ret = spi_sync_transfer(st->spi, &t, 1);
|
|
if (ret)
|
|
if (ret)
|
|
return ret;
|
|
return ret;
|
|
|
|
|
|
- *val = be32_to_cpu(rx_buf);
|
|
|
|
|
|
+ *val = be32_to_cpu(st->buf[1]);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -214,12 +216,11 @@ static int ad7280_write(struct ad7280_state *st, unsigned devaddr,
|
|
{
|
|
{
|
|
unsigned reg = (devaddr << 27 | addr << 21 |
|
|
unsigned reg = (devaddr << 27 | addr << 21 |
|
|
(val & 0xFF) << 13 | all << 12);
|
|
(val & 0xFF) << 13 | all << 12);
|
|
- __be32 tx_buf;
|
|
|
|
|
|
|
|
reg |= ad7280_calc_crc8(st->crc_tab, reg >> 11) << 3 | 0x2;
|
|
reg |= ad7280_calc_crc8(st->crc_tab, reg >> 11) << 3 | 0x2;
|
|
- tx_buf = cpu_to_be32(reg);
|
|
|
|
|
|
+ st->buf[0] = cpu_to_be32(reg);
|
|
|
|
|
|
- return spi_write(st->spi, &tx_buf, 4);
|
|
|
|
|
|
+ return spi_write(st->spi, &st->buf[0], 4);
|
|
}
|
|
}
|
|
|
|
|
|
static int ad7280_read(struct ad7280_state *st, unsigned devaddr,
|
|
static int ad7280_read(struct ad7280_state *st, unsigned devaddr,
|
|
@@ -249,7 +250,7 @@ static int ad7280_read(struct ad7280_state *st, unsigned devaddr,
|
|
if (ret)
|
|
if (ret)
|
|
return ret;
|
|
return ret;
|
|
|
|
|
|
- __ad7280_read32(st->spi, &tmp);
|
|
|
|
|
|
+ __ad7280_read32(st, &tmp);
|
|
|
|
|
|
if (ad7280_check_crc(st, tmp))
|
|
if (ad7280_check_crc(st, tmp))
|
|
return -EIO;
|
|
return -EIO;
|
|
@@ -287,7 +288,7 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned devaddr,
|
|
|
|
|
|
ad7280_delay(st);
|
|
ad7280_delay(st);
|
|
|
|
|
|
- __ad7280_read32(st->spi, &tmp);
|
|
|
|
|
|
+ __ad7280_read32(st, &tmp);
|
|
|
|
|
|
if (ad7280_check_crc(st, tmp))
|
|
if (ad7280_check_crc(st, tmp))
|
|
return -EIO;
|
|
return -EIO;
|
|
@@ -320,7 +321,7 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned cnt,
|
|
ad7280_delay(st);
|
|
ad7280_delay(st);
|
|
|
|
|
|
for (i = 0; i < cnt; i++) {
|
|
for (i = 0; i < cnt; i++) {
|
|
- __ad7280_read32(st->spi, &tmp);
|
|
|
|
|
|
+ __ad7280_read32(st, &tmp);
|
|
|
|
|
|
if (ad7280_check_crc(st, tmp))
|
|
if (ad7280_check_crc(st, tmp))
|
|
return -EIO;
|
|
return -EIO;
|
|
@@ -363,7 +364,7 @@ static int ad7280_chain_setup(struct ad7280_state *st)
|
|
return ret;
|
|
return ret;
|
|
|
|
|
|
for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
|
|
for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
|
|
- __ad7280_read32(st->spi, &val);
|
|
|
|
|
|
+ __ad7280_read32(st, &val);
|
|
if (val == 0)
|
|
if (val == 0)
|
|
return n - 1;
|
|
return n - 1;
|
|
|
|
|