* [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16
@ 2013-11-25 12:41 Lars-Peter Clausen
2013-11-25 12:41 ` [PATCH 02/15] iio:ad5504: Do not store transfer buffers on the stack Lars-Peter Clausen
` (14 more replies)
0 siblings, 15 replies; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:41 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Fixes the following warnings from sparse:
drivers/iio/dac/ad5504.c:71:19: warning: incorrect type in initializer (different base types)
drivers/iio/dac/ad5504.c:71:19: expected unsigned short [unsigned] [usertype] tmp
drivers/iio/dac/ad5504.c:71:19: got restricted __be16 [usertype] <noident>
drivers/iio/dac/ad5504.c:80:19: warning: incorrect type in initializer (different base types)
drivers/iio/dac/ad5504.c:80:19: expected unsigned short [unsigned] [usertype] tmp
drivers/iio/dac/ad5504.c:80:19: got restricted __be16 [usertype] <noident>
drivers/iio/dac/ad5504.c:93:16: warning: cast to restricted __be16
drivers/iio/dac/ad5504.c:93:16: warning: cast to restricted __be16
drivers/iio/dac/ad5504.c:93:16: warning: cast to restricted __be16
drivers/iio/dac/ad5504.c:93:16: warning: cast to restricted __be16
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/dac/ad5504.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
index c0957a9..6cd0dd6 100644
--- a/drivers/iio/dac/ad5504.c
+++ b/drivers/iio/dac/ad5504.c
@@ -68,7 +68,7 @@ enum ad5504_supported_device_ids {
static int ad5504_spi_write(struct spi_device *spi, u8 addr, u16 val)
{
- u16 tmp = cpu_to_be16(AD5504_CMD_WRITE |
+ __be16 tmp = cpu_to_be16(AD5504_CMD_WRITE |
AD5504_ADDR(addr) |
(val & AD5504_RES_MASK));
@@ -77,8 +77,8 @@ static int ad5504_spi_write(struct spi_device *spi, u8 addr, u16 val)
static int ad5504_spi_read(struct spi_device *spi, u8 addr)
{
- u16 tmp = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr));
- u16 val;
+ __be16 tmp = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr));
+ __be16 val;
int ret;
struct spi_transfer t = {
.tx_buf = &tmp,
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 02/15] iio:ad5504: Do not store transfer buffers on the stack
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
@ 2013-11-25 12:41 ` Lars-Peter Clausen
2013-11-30 11:07 ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 03/15] iio:ad5421: Mark transfer buffer as __be32 Lars-Peter Clausen
` (13 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:41 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Some SPI controllers may not be able to handle transfer buffers that are placed
on the stack.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/dac/ad5504.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
index 6cd0dd6..d44c8f5 100644
--- a/drivers/iio/dac/ad5504.c
+++ b/drivers/iio/dac/ad5504.c
@@ -47,14 +47,16 @@
* @vref_mv: actual reference voltage used
* @pwr_down_mask power down mask
* @pwr_down_mode current power down mode
+ * @data: transfer buffer
*/
-
struct ad5504_state {
struct spi_device *spi;
struct regulator *reg;
unsigned short vref_mv;
unsigned pwr_down_mask;
unsigned pwr_down_mode;
+
+ __be16 data[2] ____cacheline_aligned;
};
/**
@@ -66,31 +68,29 @@ enum ad5504_supported_device_ids {
ID_AD5501,
};
-static int ad5504_spi_write(struct spi_device *spi, u8 addr, u16 val)
+static int ad5504_spi_write(struct ad5504_state *st, u8 addr, u16 val)
{
- __be16 tmp = cpu_to_be16(AD5504_CMD_WRITE |
- AD5504_ADDR(addr) |
+ st->data[0] = cpu_to_be16(AD5504_CMD_WRITE | AD5504_ADDR(addr) |
(val & AD5504_RES_MASK));
- return spi_write(spi, (u8 *)&tmp, 2);
+ return spi_write(st->spi, &st->data[0], 2);
}
-static int ad5504_spi_read(struct spi_device *spi, u8 addr)
+static int ad5504_spi_read(struct ad5504_state *st, u8 addr)
{
- __be16 tmp = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr));
- __be16 val;
int ret;
- struct spi_transfer t = {
- .tx_buf = &tmp,
- .rx_buf = &val,
- .len = 2,
- };
- ret = spi_sync_transfer(spi, &t, 1);
-
+ struct spi_transfer t = {
+ .tx_buf = &st->data[0],
+ .rx_buf = &st->data[1],
+ .len = 2,
+ };
+
+ st->data[0] = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr));
+ ret = spi_sync_transfer(st->spi, &t, 1);
if (ret < 0)
return ret;
- return be16_to_cpu(val) & AD5504_RES_MASK;
+ return be16_to_cpu(st->data[1]) & AD5504_RES_MASK;
}
static int ad5504_read_raw(struct iio_dev *indio_dev,
@@ -104,7 +104,7 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
switch (m) {
case IIO_CHAN_INFO_RAW:
- ret = ad5504_spi_read(st->spi, chan->address);
+ ret = ad5504_spi_read(st, chan->address);
if (ret < 0)
return ret;
@@ -133,7 +133,7 @@ static int ad5504_write_raw(struct iio_dev *indio_dev,
if (val >= (1 << chan->scan_type.realbits) || val < 0)
return -EINVAL;
- return ad5504_spi_write(st->spi, chan->address, val);
+ return ad5504_spi_write(st, chan->address, val);
default:
ret = -EINVAL;
}
@@ -197,12 +197,12 @@ static ssize_t ad5504_write_dac_powerdown(struct iio_dev *indio_dev,
else
st->pwr_down_mask &= ~(1 << chan->channel);
- ret = ad5504_spi_write(st->spi, AD5504_ADDR_CTRL,
+ ret = ad5504_spi_write(st, AD5504_ADDR_CTRL,
AD5504_DAC_PWRDWN_MODE(st->pwr_down_mode) |
AD5504_DAC_PWR(st->pwr_down_mask));
/* writes to the CTRL register must be followed by a NOOP */
- ad5504_spi_write(st->spi, AD5504_ADDR_NOOP, 0);
+ ad5504_spi_write(st, AD5504_ADDR_NOOP, 0);
return ret ? ret : len;
}
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 03/15] iio:ad5421: Mark transfer buffer as __be32
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
2013-11-25 12:41 ` [PATCH 02/15] iio:ad5504: Do not store transfer buffers on the stack Lars-Peter Clausen
@ 2013-11-25 12:41 ` Lars-Peter Clausen
2013-11-30 11:07 ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 04/15] iio:ad5686: " Lars-Peter Clausen
` (12 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:41 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Fixes the following warnings from sparse:
drivers/iio/dac/ad5421.c:134:25: warning: incorrect type in assignment (different base types)
drivers/iio/dac/ad5421.c:134:25: expected unsigned int [unsigned] [usertype] d32
drivers/iio/dac/ad5421.c:134:25: got restricted __be32 [usertype] <noident>
drivers/iio/dac/ad5421.c:168:25: warning: incorrect type in assignment (different base types)
drivers/iio/dac/ad5421.c:168:25: expected unsigned int [unsigned] [usertype] d32
drivers/iio/dac/ad5421.c:168:25: got restricted __be32 [usertype] <noident>
drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/dac/ad5421.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c
index 3eeaa82..fcb599c 100644
--- a/drivers/iio/dac/ad5421.c
+++ b/drivers/iio/dac/ad5421.c
@@ -75,7 +75,7 @@ struct ad5421_state {
* transfer buffers to live in their own cache lines.
*/
union {
- u32 d32;
+ __be32 d32;
u8 d8[4];
} data[2] ____cacheline_aligned;
};
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 04/15] iio:ad5686: Mark transfer buffer as __be32
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
2013-11-25 12:41 ` [PATCH 02/15] iio:ad5504: Do not store transfer buffers on the stack Lars-Peter Clausen
2013-11-25 12:41 ` [PATCH 03/15] iio:ad5421: Mark transfer buffer as __be32 Lars-Peter Clausen
@ 2013-11-25 12:41 ` Lars-Peter Clausen
2013-11-30 11:07 ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 05/15] iio:ad5755: " Lars-Peter Clausen
` (11 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:41 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Fixes the following warnings from sparse:
drivers/iio/dac/ad5686.c:100:25: warning: incorrect type in assignment (different base types)
drivers/iio/dac/ad5686.c:100:25: expected unsigned int [unsigned] [usertype] d32
drivers/iio/dac/ad5686.c:100:25: got restricted __be32 [usertype] <noident>
drivers/iio/dac/ad5686.c:122:25: warning: incorrect type in assignment (different base types)
drivers/iio/dac/ad5686.c:122:25: expected unsigned int [unsigned] [usertype] d32
drivers/iio/dac/ad5686.c:122:25: got restricted __be32 [usertype] <noident>
drivers/iio/dac/ad5686.c:124:25: warning: incorrect type in assignment (different base types)
drivers/iio/dac/ad5686.c:124:25: expected unsigned int [unsigned] [usertype] d32
drivers/iio/dac/ad5686.c:124:25: got restricted __be32 [usertype] <noident>
drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/dac/ad5686.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index 30e506e..e56ec0a 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -78,7 +78,7 @@ struct ad5686_state {
*/
union {
- u32 d32;
+ __be32 d32;
u8 d8[4];
} data[3] ____cacheline_aligned;
};
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 05/15] iio:ad5755: Mark transfer buffer as __be32
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (2 preceding siblings ...)
2013-11-25 12:41 ` [PATCH 04/15] iio:ad5686: " Lars-Peter Clausen
@ 2013-11-25 12:41 ` Lars-Peter Clausen
2013-11-30 11:08 ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 06/15] iio:ad5791: Mark transfer buffers " Lars-Peter Clausen
` (10 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:41 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Fixes the following warnings from sparse:
drivers/iio/dac/ad5755.c:117:25: warning: incorrect type in assignment (different base types)
drivers/iio/dac/ad5755.c:117:25: expected unsigned int [unsigned] [usertype] d32
drivers/iio/dac/ad5755.c:117:25: got restricted __be32 [usertype] <noident>
drivers/iio/dac/ad5755.c:171:25: warning: incorrect type in assignment (different base types)
drivers/iio/dac/ad5755.c:171:25: expected unsigned int [unsigned] [usertype] d32
drivers/iio/dac/ad5755.c:171:25: got restricted __be32 [usertype] <noident>
drivers/iio/dac/ad5755.c:172:25: warning: incorrect type in assignment (different base types)
drivers/iio/dac/ad5755.c:172:25: expected unsigned int [unsigned] [usertype] d32
drivers/iio/dac/ad5755.c:172:25: got restricted __be32 [usertype] <noident>
drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/dac/ad5755.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
index 9a78d5a..bdf302d 100644
--- a/drivers/iio/dac/ad5755.c
+++ b/drivers/iio/dac/ad5755.c
@@ -97,7 +97,7 @@ struct ad5755_state {
*/
union {
- u32 d32;
+ __be32 d32;
u8 d8[4];
} data[2] ____cacheline_aligned;
};
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 06/15] iio:ad5791: Mark transfer buffers as __be32
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (3 preceding siblings ...)
2013-11-25 12:41 ` [PATCH 05/15] iio:ad5755: " Lars-Peter Clausen
@ 2013-11-25 12:41 ` Lars-Peter Clausen
2013-11-30 11:08 ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 07/15] iio:ad5791: Do not store transfer buffers on the stack Lars-Peter Clausen
` (9 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:41 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Fixes the following warnings from sparse:
drivers/iio/dac/ad5791.c:114:18: warning: incorrect type in assignment (different base types)
drivers/iio/dac/ad5791.c:114:18: expected unsigned int [unsigned] [usertype] d32
drivers/iio/dac/ad5791.c:114:18: got restricted __be32 [usertype] <noident>
drivers/iio/dac/ad5791.c:142:21: warning: incorrect type in assignment (different base types)
drivers/iio/dac/ad5791.c:142:21: expected unsigned int [unsigned] [usertype] d32
drivers/iio/dac/ad5791.c:142:21: got restricted __be32 [usertype] <noident>
drivers/iio/dac/ad5791.c:144:21: warning: incorrect type in assignment (different base types)
drivers/iio/dac/ad5791.c:144:21: expected unsigned int [unsigned] [usertype] d32
drivers/iio/dac/ad5791.c:144:21: got restricted __be32 [usertype] <noident>
drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/dac/ad5791.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
index d64acbd..1e7f4cd 100644
--- a/drivers/iio/dac/ad5791.c
+++ b/drivers/iio/dac/ad5791.c
@@ -107,7 +107,7 @@ enum ad5791_supported_device_ids {
static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
{
union {
- u32 d32;
+ __be32 d32;
u8 d8[4];
} data;
@@ -121,7 +121,7 @@ static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
{
union {
- u32 d32;
+ __be32 d32;
u8 d8[4];
} data[3];
int ret;
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 07/15] iio:ad5791: Do not store transfer buffers on the stack
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (4 preceding siblings ...)
2013-11-25 12:41 ` [PATCH 06/15] iio:ad5791: Mark transfer buffers " Lars-Peter Clausen
@ 2013-11-25 12:41 ` Lars-Peter Clausen
2013-11-30 11:09 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 08/15] iio:ad7266: Mark transfer buffer as __be16 Lars-Peter Clausen
` (8 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:41 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Some SPI controllers may not be able to handle transfer buffers that are placed
on the stack.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/dac/ad5791.c | 46 +++++++++++++++++++++-------------------------
1 file changed, 21 insertions(+), 25 deletions(-)
diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
index 1e7f4cd..79bf199 100644
--- a/drivers/iio/dac/ad5791.c
+++ b/drivers/iio/dac/ad5791.c
@@ -91,6 +91,11 @@ struct ad5791_state {
unsigned ctrl;
unsigned pwr_down_mode;
bool pwr_down;
+
+ union {
+ __be32 d32;
+ u8 d8[4];
+ } data[3] ____cacheline_aligned;
};
/**
@@ -104,48 +109,39 @@ enum ad5791_supported_device_ids {
ID_AD5791,
};
-static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
+static int ad5791_spi_write(struct ad5791_state *st, u8 addr, u32 val)
{
- union {
- __be32 d32;
- u8 d8[4];
- } data;
-
- data.d32 = cpu_to_be32(AD5791_CMD_WRITE |
+ st->data[0].d32 = cpu_to_be32(AD5791_CMD_WRITE |
AD5791_ADDR(addr) |
(val & AD5791_DAC_MASK));
- return spi_write(spi, &data.d8[1], 3);
+ return spi_write(st->spi, &st->data[0].d8[1], 3);
}
-static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
+static int ad5791_spi_read(struct ad5791_state *st, u8 addr, u32 *val)
{
- union {
- __be32 d32;
- u8 d8[4];
- } data[3];
int ret;
struct spi_transfer xfers[] = {
{
- .tx_buf = &data[0].d8[1],
+ .tx_buf = &st->data[0].d8[1],
.bits_per_word = 8,
.len = 3,
.cs_change = 1,
}, {
- .tx_buf = &data[1].d8[1],
- .rx_buf = &data[2].d8[1],
+ .tx_buf = &st->data[1].d8[1],
+ .rx_buf = &st->data[2].d8[1],
.bits_per_word = 8,
.len = 3,
},
};
- data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
+ st->data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
AD5791_ADDR(addr));
- data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
+ st->data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
- ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers));
+ ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
- *val = be32_to_cpu(data[2].d32);
+ *val = be32_to_cpu(st->data[2].d32);
return ret;
}
@@ -210,7 +206,7 @@ static ssize_t ad5791_write_dac_powerdown(struct iio_dev *indio_dev,
}
st->pwr_down = pwr_down;
- ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl);
+ ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl);
return ret ? ret : len;
}
@@ -263,7 +259,7 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
switch (m) {
case IIO_CHAN_INFO_RAW:
- ret = ad5791_spi_read(st->spi, chan->address, val);
+ ret = ad5791_spi_read(st, chan->address, val);
if (ret)
return ret;
*val &= AD5791_DAC_MASK;
@@ -330,7 +326,7 @@ static int ad5791_write_raw(struct iio_dev *indio_dev,
val &= AD5791_RES_MASK(chan->scan_type.realbits);
val <<= chan->scan_type.shift;
- return ad5791_spi_write(st->spi, chan->address, val);
+ return ad5791_spi_write(st, chan->address, val);
default:
return -EINVAL;
@@ -393,7 +389,7 @@ static int ad5791_probe(struct spi_device *spi)
dev_warn(&spi->dev, "reference voltage unspecified\n");
}
- ret = ad5791_spi_write(spi, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
+ ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
if (ret)
goto error_disable_reg_neg;
@@ -405,7 +401,7 @@ static int ad5791_probe(struct spi_device *spi)
| ((pdata && pdata->use_rbuf_gain2) ? 0 : AD5791_CTRL_RBUF) |
AD5791_CTRL_BIN2SC;
- ret = ad5791_spi_write(spi, AD5791_ADDR_CTRL, st->ctrl |
+ ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl |
AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
if (ret)
goto error_disable_reg_neg;
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 08/15] iio:ad7266: Mark transfer buffer as __be16
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (5 preceding siblings ...)
2013-11-25 12:41 ` [PATCH 07/15] iio:ad5791: Do not store transfer buffers on the stack Lars-Peter Clausen
@ 2013-11-25 12:42 ` Lars-Peter Clausen
2013-11-30 11:10 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 09/15] iio:vcnl4000: " Lars-Peter Clausen
` (7 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:42 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Fixes the following warnings from sparse:
drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16
drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16
drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16
drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/adc/ad7266.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index 58e9455..70f78c3 100644
--- a/drivers/iio/adc/ad7266.c
+++ b/drivers/iio/adc/ad7266.c
@@ -43,19 +43,22 @@ struct ad7266_state {
* The buffer needs to be large enough to hold two samples (4 bytes) and
* the naturally aligned timestamp (8 bytes).
*/
- uint8_t data[ALIGN(4, sizeof(s64)) + sizeof(s64)] ____cacheline_aligned;
+ struct {
+ __be16 sample[2];
+ s64 timestamp;
+ } data ____cacheline_aligned;
};
static int ad7266_wakeup(struct ad7266_state *st)
{
/* Any read with >= 2 bytes will wake the device */
- return spi_read(st->spi, st->data, 2);
+ return spi_read(st->spi, &st->data.sample[0], 2);
}
static int ad7266_powerdown(struct ad7266_state *st)
{
/* Any read with < 2 bytes will powerdown the device */
- return spi_read(st->spi, st->data, 1);
+ return spi_read(st->spi, &st->data.sample[0], 1);
}
static int ad7266_preenable(struct iio_dev *indio_dev)
@@ -84,9 +87,9 @@ static irqreturn_t ad7266_trigger_handler(int irq, void *p)
struct ad7266_state *st = iio_priv(indio_dev);
int ret;
- ret = spi_read(st->spi, st->data, 4);
+ ret = spi_read(st->spi, st->data.sample, 4);
if (ret == 0) {
- iio_push_to_buffers_with_timestamp(indio_dev, st->data,
+ iio_push_to_buffers_with_timestamp(indio_dev, &st->data,
pf->timestamp);
}
@@ -137,7 +140,7 @@ static int ad7266_read_single(struct ad7266_state *st, int *val,
ad7266_select_input(st, address);
ret = spi_sync(st->spi, &st->single_msg);
- *val = be16_to_cpu(st->data[address % 2]);
+ *val = be16_to_cpu(st->data.sample[address % 2]);
return ret;
}
@@ -442,15 +445,15 @@ static int ad7266_probe(struct spi_device *spi)
ad7266_init_channels(indio_dev);
/* wakeup */
- st->single_xfer[0].rx_buf = &st->data;
+ st->single_xfer[0].rx_buf = &st->data.sample[0];
st->single_xfer[0].len = 2;
st->single_xfer[0].cs_change = 1;
/* conversion */
- st->single_xfer[1].rx_buf = &st->data;
+ st->single_xfer[1].rx_buf = st->data.sample;
st->single_xfer[1].len = 4;
st->single_xfer[1].cs_change = 1;
/* powerdown */
- st->single_xfer[2].tx_buf = &st->data;
+ st->single_xfer[2].tx_buf = &st->data.sample[0];
st->single_xfer[2].len = 1;
spi_message_init(&st->single_msg);
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 09/15] iio:vcnl4000: Mark transfer buffer as __be16
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (6 preceding siblings ...)
2013-11-25 12:42 ` [PATCH 08/15] iio:ad7266: Mark transfer buffer as __be16 Lars-Peter Clausen
@ 2013-11-25 12:42 ` Lars-Peter Clausen
2013-11-30 11:11 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 10/15] staging:iio:ad7280a: Mark transfer buffer as __be32 Lars-Peter Clausen
` (6 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:42 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Peter Meerwald
Fixes the following warnings from sparse:
drivers/iio/light/vcnl4000.c:88:16: warning: cast to restricted __be16
drivers/iio/light/vcnl4000.c:88:16: warning: cast to restricted __be16
drivers/iio/light/vcnl4000.c:88:16: warning: cast to restricted __be16
drivers/iio/light/vcnl4000.c:88:16: warning: cast to restricted __be16
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
---
drivers/iio/light/vcnl4000.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index ecb3341..2f2c9be 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -56,7 +56,7 @@ static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask,
u8 rdy_mask, u8 data_reg, int *val)
{
int tries = 20;
- u16 buf;
+ __be16 buf;
int ret;
ret = i2c_smbus_write_byte_data(data->client, VCNL4000_COMMAND,
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 10/15] staging:iio:ad7280a: Mark transfer buffer as __be32
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (7 preceding siblings ...)
2013-11-25 12:42 ` [PATCH 09/15] iio:vcnl4000: " Lars-Peter Clausen
@ 2013-11-25 12:42 ` Lars-Peter Clausen
2013-11-30 11:12 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 11/15] staging:iio:ad7280a: Do not store transfer buffer on the stack Lars-Peter Clausen
` (5 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:42 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Fixes the following warnings from sparse:
drivers/staging/iio/adc/ad7280a.c:194:35: warning: incorrect type in initializer (different base types)
drivers/staging/iio/adc/ad7280a.c:194:35: expected unsigned int [unsigned] tx_buf
drivers/staging/iio/adc/ad7280a.c:194:35: got restricted __be32 [usertype] <noident>
drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
drivers/staging/iio/adc/ad7280a.c:219:13: warning: incorrect type in assignment (different base types)
drivers/staging/iio/adc/ad7280a.c:219:13: expected unsigned int [unsigned] [assigned] reg
drivers/staging/iio/adc/ad7280a.c:219:13: got restricted __be32 [usertype] <noident>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/adc/ad7280a.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index 8209fa5..89ee65b 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -191,7 +191,7 @@ static void ad7280_delay(struct ad7280_state *st)
static int __ad7280_read32(struct spi_device *spi, unsigned *val)
{
- unsigned rx_buf, tx_buf = cpu_to_be32(AD7280A_READ_TXVAL);
+ __be32 rx_buf, tx_buf = cpu_to_be32(AD7280A_READ_TXVAL);
int ret;
struct spi_transfer t = {
@@ -214,11 +214,12 @@ static int ad7280_write(struct ad7280_state *st, unsigned devaddr,
{
unsigned reg = (devaddr << 27 | addr << 21 |
(val & 0xFF) << 13 | all << 12);
+ __be32 tx_buf;
reg |= ad7280_calc_crc8(st->crc_tab, reg >> 11) << 3 | 0x2;
- reg = cpu_to_be32(reg);
+ tx_buf = cpu_to_be32(reg);
- return spi_write(st->spi, ®, 4);
+ return spi_write(st->spi, &tx_buf, 4);
}
static int ad7280_read(struct ad7280_state *st, unsigned devaddr,
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 11/15] staging:iio:ad7280a: Do not store transfer buffer on the stack
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (8 preceding siblings ...)
2013-11-25 12:42 ` [PATCH 10/15] staging:iio:ad7280a: Mark transfer buffer as __be32 Lars-Peter Clausen
@ 2013-11-25 12:42 ` Lars-Peter Clausen
2013-11-30 11:12 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 12/15] staging:iio:ad7746: Mark transfer buffer as __be32 Lars-Peter Clausen
` (4 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:42 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Some I2C controllers may not be able to handle transfer buffers that are placed
on the stack.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/adc/ad7280a.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index 89ee65b..1ac11f6 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -134,6 +134,8 @@ struct ad7280_state {
unsigned char aux_threshhigh;
unsigned char aux_threshlow;
unsigned char cb_mask[AD7280A_MAX_CHAIN];
+
+ __be32 buf[2] ____cacheline_aligned;
};
static void ad7280_crc8_build_table(unsigned char *crc_tab)
@@ -189,22 +191,22 @@ static void ad7280_delay(struct ad7280_state *st)
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;
-
struct spi_transfer t = {
- .tx_buf = &tx_buf,
- .rx_buf = &rx_buf,
+ .tx_buf = &st->buf[0],
+ .rx_buf = &st->buf[1],
.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)
return ret;
- *val = be32_to_cpu(rx_buf);
+ *val = be32_to_cpu(st->buf[1]);
return 0;
}
@@ -214,12 +216,11 @@ static int ad7280_write(struct ad7280_state *st, unsigned devaddr,
{
unsigned reg = (devaddr << 27 | addr << 21 |
(val & 0xFF) << 13 | all << 12);
- __be32 tx_buf;
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,
@@ -249,7 +250,7 @@ static int ad7280_read(struct ad7280_state *st, unsigned devaddr,
if (ret)
return ret;
- __ad7280_read32(st->spi, &tmp);
+ __ad7280_read32(st, &tmp);
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -287,7 +288,7 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned devaddr,
ad7280_delay(st);
- __ad7280_read32(st->spi, &tmp);
+ __ad7280_read32(st, &tmp);
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -320,7 +321,7 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned cnt,
ad7280_delay(st);
for (i = 0; i < cnt; i++) {
- __ad7280_read32(st->spi, &tmp);
+ __ad7280_read32(st, &tmp);
if (ad7280_check_crc(st, tmp))
return -EIO;
@@ -363,7 +364,7 @@ static int ad7280_chain_setup(struct ad7280_state *st)
return ret;
for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
- __ad7280_read32(st->spi, &val);
+ __ad7280_read32(st, &val);
if (val == 0)
return n - 1;
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 12/15] staging:iio:ad7746: Mark transfer buffer as __be32
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (9 preceding siblings ...)
2013-11-25 12:42 ` [PATCH 11/15] staging:iio:ad7280a: Do not store transfer buffer on the stack Lars-Peter Clausen
@ 2013-11-25 12:42 ` Lars-Peter Clausen
2013-11-30 11:13 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 13/15] staging:iio:ad7746: Do not store the transfer buffer on the stack Lars-Peter Clausen
` (3 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:42 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Fixes the following warnings from sparse:
drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/cdc/ad7746.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 862d68d..01e15e2 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -567,7 +567,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
u8 regval, reg;
union {
- u32 d32;
+ __be32 d32;
u8 d8[4];
} data;
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 13/15] staging:iio:ad7746: Do not store the transfer buffer on the stack
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (10 preceding siblings ...)
2013-11-25 12:42 ` [PATCH 12/15] staging:iio:ad7746: Mark transfer buffer as __be32 Lars-Peter Clausen
@ 2013-11-25 12:42 ` Lars-Peter Clausen
2013-11-30 11:13 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 14/15] staging:iio:ad9832: Mark transfer buffers as __be16 Lars-Peter Clausen
` (2 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:42 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Some I2C controllers might not be able to handle transfer buffers that are
stored on stack.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/cdc/ad7746.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 01e15e2..cbb1588 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -105,6 +105,11 @@ struct ad7746_chip_info {
u8 vt_setup;
u8 capdac[2][2];
s8 capdac_set;
+
+ union {
+ __be32 d32;
+ u8 d8[4];
+ } data ____cacheline_aligned;
};
enum ad7746_chan {
@@ -566,11 +571,6 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
int ret, delay;
u8 regval, reg;
- union {
- __be32 d32;
- u8 d8[4];
- } data;
-
mutex_lock(&indio_dev->mlock);
switch (mask) {
@@ -591,12 +591,12 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
/* Now read the actual register */
ret = i2c_smbus_read_i2c_block_data(chip->client,
- chan->address >> 8, 3, &data.d8[1]);
+ chan->address >> 8, 3, &chip->data.d8[1]);
if (ret < 0)
goto out;
- *val = (be32_to_cpu(data.d32) & 0xFFFFFF) - 0x800000;
+ *val = (be32_to_cpu(chip->data.d32) & 0xFFFFFF) - 0x800000;
switch (chan->type) {
case IIO_TEMP:
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 14/15] staging:iio:ad9832: Mark transfer buffers as __be16
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (11 preceding siblings ...)
2013-11-25 12:42 ` [PATCH 13/15] staging:iio:ad7746: Do not store the transfer buffer on the stack Lars-Peter Clausen
@ 2013-11-25 12:42 ` Lars-Peter Clausen
2013-11-30 11:14 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 15/15] staging:iio:ad9834: Mark transfer buffers as __b16 Lars-Peter Clausen
2013-11-30 11:03 ` [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Jonathan Cameron
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:42 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Fixes the following warnings from sparse:
drivers/staging/iio/frequency/ad9832.c:43:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9832.c:43:26: expected unsigned short [unsigned] [short] <noident>
drivers/staging/iio/frequency/ad9832.c:43:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9832.c:46:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9832.c:46:26: expected unsigned short [unsigned] [short] <noident>
drivers/staging/iio/frequency/ad9832.c:46:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9832.c:49:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9832.c:49:26: expected unsigned short [unsigned] [short] <noident>
drivers/staging/iio/frequency/ad9832.c:49:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9832.c:52:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9832.c:52:26: expected unsigned short [unsigned] [short] <noident>
drivers/staging/iio/frequency/ad9832.c:52:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9832.c:65:27: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9832.c:65:27: expected unsigned short [unsigned] [short] <noident>
drivers/staging/iio/frequency/ad9832.c:65:27: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9832.c:68:27: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9832.c:68:27: expected unsigned short [unsigned] [short] <noident>
drivers/staging/iio/frequency/ad9832.c:68:27: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9832.c:107:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9832.c:107:26: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9832.c:107:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9832.c:120:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9832.c:120:26: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9832.c:120:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9832.c:133:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9832.c:133:26: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9832.c:133:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9832.c:144:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9832.c:144:26: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9832.c:144:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9832.c:277:18: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9832.c:277:18: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9832.c:277:18: got restricted __be16 [usertype] <noident>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/frequency/ad9832.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/iio/frequency/ad9832.h b/drivers/staging/iio/frequency/ad9832.h
index c5b701f..386f4dc 100644
--- a/drivers/staging/iio/frequency/ad9832.h
+++ b/drivers/staging/iio/frequency/ad9832.h
@@ -92,9 +92,9 @@ struct ad9832_state {
* transfer buffers to live in their own cache lines.
*/
union {
- unsigned short freq_data[4]____cacheline_aligned;
- unsigned short phase_data[2];
- unsigned short data;
+ __be16 freq_data[4]____cacheline_aligned;
+ __be16 phase_data[2];
+ __be16 data;
};
};
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 15/15] staging:iio:ad9834: Mark transfer buffers as __b16
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (12 preceding siblings ...)
2013-11-25 12:42 ` [PATCH 14/15] staging:iio:ad9832: Mark transfer buffers as __be16 Lars-Peter Clausen
@ 2013-11-25 12:42 ` Lars-Peter Clausen
2013-11-30 11:14 ` Jonathan Cameron
2013-11-30 11:03 ` [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Jonathan Cameron
14 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-11-25 12:42 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Fixes the following warnings from sparse:
drivers/staging/iio/frequency/ad9834.c:45:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9834.c:45:26: expected unsigned short [unsigned] [short] <noident>
drivers/staging/iio/frequency/ad9834.c:45:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9834.c:47:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9834.c:47:26: expected unsigned short [unsigned] [short] <noident>
drivers/staging/iio/frequency/ad9834.c:47:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9834.c:59:18: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9834.c:59:18: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9834.c:59:18: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9834.c:100:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9834.c:100:26: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9834.c:100:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9834.c:108:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9834.c:108:26: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9834.c:108:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9834.c:122:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9834.c:122:26: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9834.c:122:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9834.c:131:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9834.c:131:26: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9834.c:131:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9834.c:194:26: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9834.c:194:26: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9834.c:194:26: got restricted __be16 [usertype] <noident>
drivers/staging/iio/frequency/ad9834.c:387:18: warning: incorrect type in assignment (different base types)
drivers/staging/iio/frequency/ad9834.c:387:18: expected unsigned short [unsigned] data
drivers/staging/iio/frequency/ad9834.c:387:18: got restricted __be16 [usertype] <noident>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/frequency/ad9834.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/iio/frequency/ad9834.h b/drivers/staging/iio/frequency/ad9834.h
index ed5ed8d..8ca6e52 100644
--- a/drivers/staging/iio/frequency/ad9834.h
+++ b/drivers/staging/iio/frequency/ad9834.h
@@ -65,8 +65,8 @@ struct ad9834_state {
* DMA (thus cache coherency maintenance) requires the
* transfer buffers to live in their own cache lines.
*/
- unsigned short data ____cacheline_aligned;
- unsigned short freq_data[2] ;
+ __be16 data ____cacheline_aligned;
+ __be16 freq_data[2];
};
--
1.8.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* Re: [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
` (13 preceding siblings ...)
2013-11-25 12:42 ` [PATCH 15/15] staging:iio:ad9834: Mark transfer buffers as __b16 Lars-Peter Clausen
@ 2013-11-30 11:03 ` Jonathan Cameron
14 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:03 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:41, Lars-Peter Clausen wrote:
> Fixes the following warnings from sparse:
> drivers/iio/dac/ad5504.c:71:19: warning: incorrect type in initializer (different base types)
> drivers/iio/dac/ad5504.c:71:19: expected unsigned short [unsigned] [usertype] tmp
> drivers/iio/dac/ad5504.c:71:19: got restricted __be16 [usertype] <noident>
> drivers/iio/dac/ad5504.c:80:19: warning: incorrect type in initializer (different base types)
> drivers/iio/dac/ad5504.c:80:19: expected unsigned short [unsigned] [usertype] tmp
> drivers/iio/dac/ad5504.c:80:19: got restricted __be16 [usertype] <noident>
> drivers/iio/dac/ad5504.c:93:16: warning: cast to restricted __be16
> drivers/iio/dac/ad5504.c:93:16: warning: cast to restricted __be16
> drivers/iio/dac/ad5504.c:93:16: warning: cast to restricted __be16
> drivers/iio/dac/ad5504.c:93:16: warning: cast to restricted __be16
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks,
> ---
> drivers/iio/dac/ad5504.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
> index c0957a9..6cd0dd6 100644
> --- a/drivers/iio/dac/ad5504.c
> +++ b/drivers/iio/dac/ad5504.c
> @@ -68,7 +68,7 @@ enum ad5504_supported_device_ids {
>
> static int ad5504_spi_write(struct spi_device *spi, u8 addr, u16 val)
> {
> - u16 tmp = cpu_to_be16(AD5504_CMD_WRITE |
> + __be16 tmp = cpu_to_be16(AD5504_CMD_WRITE |
> AD5504_ADDR(addr) |
> (val & AD5504_RES_MASK));
>
> @@ -77,8 +77,8 @@ static int ad5504_spi_write(struct spi_device *spi, u8 addr, u16 val)
>
> static int ad5504_spi_read(struct spi_device *spi, u8 addr)
> {
> - u16 tmp = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr));
> - u16 val;
> + __be16 tmp = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr));
> + __be16 val;
> int ret;
> struct spi_transfer t = {
> .tx_buf = &tmp,
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 02/15] iio:ad5504: Do not store transfer buffers on the stack
2013-11-25 12:41 ` [PATCH 02/15] iio:ad5504: Do not store transfer buffers on the stack Lars-Peter Clausen
@ 2013-11-30 11:07 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:07 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:41, Lars-Peter Clausen wrote:
> Some SPI controllers may not be able to handle transfer buffers that are placed
> on the stack.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks
> ---
> drivers/iio/dac/ad5504.c | 40 ++++++++++++++++++++--------------------
> 1 file changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
> index 6cd0dd6..d44c8f5 100644
> --- a/drivers/iio/dac/ad5504.c
> +++ b/drivers/iio/dac/ad5504.c
> @@ -47,14 +47,16 @@
> * @vref_mv: actual reference voltage used
> * @pwr_down_mask power down mask
> * @pwr_down_mode current power down mode
> + * @data: transfer buffer
> */
> -
> struct ad5504_state {
> struct spi_device *spi;
> struct regulator *reg;
> unsigned short vref_mv;
> unsigned pwr_down_mask;
> unsigned pwr_down_mode;
> +
> + __be16 data[2] ____cacheline_aligned;
> };
>
> /**
> @@ -66,31 +68,29 @@ enum ad5504_supported_device_ids {
> ID_AD5501,
> };
>
> -static int ad5504_spi_write(struct spi_device *spi, u8 addr, u16 val)
> +static int ad5504_spi_write(struct ad5504_state *st, u8 addr, u16 val)
> {
> - __be16 tmp = cpu_to_be16(AD5504_CMD_WRITE |
> - AD5504_ADDR(addr) |
> + st->data[0] = cpu_to_be16(AD5504_CMD_WRITE | AD5504_ADDR(addr) |
> (val & AD5504_RES_MASK));
>
> - return spi_write(spi, (u8 *)&tmp, 2);
> + return spi_write(st->spi, &st->data[0], 2);
> }
>
> -static int ad5504_spi_read(struct spi_device *spi, u8 addr)
> +static int ad5504_spi_read(struct ad5504_state *st, u8 addr)
> {
> - __be16 tmp = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr));
> - __be16 val;
> int ret;
> - struct spi_transfer t = {
> - .tx_buf = &tmp,
> - .rx_buf = &val,
> - .len = 2,
> - };
> - ret = spi_sync_transfer(spi, &t, 1);
> -
> + struct spi_transfer t = {
> + .tx_buf = &st->data[0],
> + .rx_buf = &st->data[1],
> + .len = 2,
> + };
> +
> + st->data[0] = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr));
> + ret = spi_sync_transfer(st->spi, &t, 1);
> if (ret < 0)
> return ret;
>
> - return be16_to_cpu(val) & AD5504_RES_MASK;
> + return be16_to_cpu(st->data[1]) & AD5504_RES_MASK;
> }
>
> static int ad5504_read_raw(struct iio_dev *indio_dev,
> @@ -104,7 +104,7 @@ static int ad5504_read_raw(struct iio_dev *indio_dev,
>
> switch (m) {
> case IIO_CHAN_INFO_RAW:
> - ret = ad5504_spi_read(st->spi, chan->address);
> + ret = ad5504_spi_read(st, chan->address);
> if (ret < 0)
> return ret;
>
> @@ -133,7 +133,7 @@ static int ad5504_write_raw(struct iio_dev *indio_dev,
> if (val >= (1 << chan->scan_type.realbits) || val < 0)
> return -EINVAL;
>
> - return ad5504_spi_write(st->spi, chan->address, val);
> + return ad5504_spi_write(st, chan->address, val);
> default:
> ret = -EINVAL;
> }
> @@ -197,12 +197,12 @@ static ssize_t ad5504_write_dac_powerdown(struct iio_dev *indio_dev,
> else
> st->pwr_down_mask &= ~(1 << chan->channel);
>
> - ret = ad5504_spi_write(st->spi, AD5504_ADDR_CTRL,
> + ret = ad5504_spi_write(st, AD5504_ADDR_CTRL,
> AD5504_DAC_PWRDWN_MODE(st->pwr_down_mode) |
> AD5504_DAC_PWR(st->pwr_down_mask));
>
> /* writes to the CTRL register must be followed by a NOOP */
> - ad5504_spi_write(st->spi, AD5504_ADDR_NOOP, 0);
> + ad5504_spi_write(st, AD5504_ADDR_NOOP, 0);
>
> return ret ? ret : len;
> }
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 03/15] iio:ad5421: Mark transfer buffer as __be32
2013-11-25 12:41 ` [PATCH 03/15] iio:ad5421: Mark transfer buffer as __be32 Lars-Peter Clausen
@ 2013-11-30 11:07 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:07 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:41, Lars-Peter Clausen wrote:
> Fixes the following warnings from sparse:
> drivers/iio/dac/ad5421.c:134:25: warning: incorrect type in assignment (different base types)
> drivers/iio/dac/ad5421.c:134:25: expected unsigned int [unsigned] [usertype] d32
> drivers/iio/dac/ad5421.c:134:25: got restricted __be32 [usertype] <noident>
> drivers/iio/dac/ad5421.c:168:25: warning: incorrect type in assignment (different base types)
> drivers/iio/dac/ad5421.c:168:25: expected unsigned int [unsigned] [usertype] d32
> drivers/iio/dac/ad5421.c:168:25: got restricted __be32 [usertype] <noident>
> drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
> drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
> drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
> drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
> drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
> drivers/iio/dac/ad5421.c:172:23: warning: cast to restricted __be32
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
thanks
> ---
> drivers/iio/dac/ad5421.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c
> index 3eeaa82..fcb599c 100644
> --- a/drivers/iio/dac/ad5421.c
> +++ b/drivers/iio/dac/ad5421.c
> @@ -75,7 +75,7 @@ struct ad5421_state {
> * transfer buffers to live in their own cache lines.
> */
> union {
> - u32 d32;
> + __be32 d32;
> u8 d8[4];
> } data[2] ____cacheline_aligned;
> };
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 04/15] iio:ad5686: Mark transfer buffer as __be32
2013-11-25 12:41 ` [PATCH 04/15] iio:ad5686: " Lars-Peter Clausen
@ 2013-11-30 11:07 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:07 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:41, Lars-Peter Clausen wrote:
> Fixes the following warnings from sparse:
> drivers/iio/dac/ad5686.c:100:25: warning: incorrect type in assignment (different base types)
> drivers/iio/dac/ad5686.c:100:25: expected unsigned int [unsigned] [usertype] d32
> drivers/iio/dac/ad5686.c:100:25: got restricted __be32 [usertype] <noident>
> drivers/iio/dac/ad5686.c:122:25: warning: incorrect type in assignment (different base types)
> drivers/iio/dac/ad5686.c:122:25: expected unsigned int [unsigned] [usertype] d32
> drivers/iio/dac/ad5686.c:122:25: got restricted __be32 [usertype] <noident>
> drivers/iio/dac/ad5686.c:124:25: warning: incorrect type in assignment (different base types)
> drivers/iio/dac/ad5686.c:124:25: expected unsigned int [unsigned] [usertype] d32
> drivers/iio/dac/ad5686.c:124:25: got restricted __be32 [usertype] <noident>
> drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
> drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
> drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
> drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
> drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
> drivers/iio/dac/ad5686.c:130:16: warning: cast to restricted __be32
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks,
> ---
> drivers/iio/dac/ad5686.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
> index 30e506e..e56ec0a 100644
> --- a/drivers/iio/dac/ad5686.c
> +++ b/drivers/iio/dac/ad5686.c
> @@ -78,7 +78,7 @@ struct ad5686_state {
> */
>
> union {
> - u32 d32;
> + __be32 d32;
> u8 d8[4];
> } data[3] ____cacheline_aligned;
> };
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 05/15] iio:ad5755: Mark transfer buffer as __be32
2013-11-25 12:41 ` [PATCH 05/15] iio:ad5755: " Lars-Peter Clausen
@ 2013-11-30 11:08 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:08 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:41, Lars-Peter Clausen wrote:
> Fixes the following warnings from sparse:
> drivers/iio/dac/ad5755.c:117:25: warning: incorrect type in assignment (different base types)
> drivers/iio/dac/ad5755.c:117:25: expected unsigned int [unsigned] [usertype] d32
> drivers/iio/dac/ad5755.c:117:25: got restricted __be32 [usertype] <noident>
> drivers/iio/dac/ad5755.c:171:25: warning: incorrect type in assignment (different base types)
> drivers/iio/dac/ad5755.c:171:25: expected unsigned int [unsigned] [usertype] d32
> drivers/iio/dac/ad5755.c:171:25: got restricted __be32 [usertype] <noident>
> drivers/iio/dac/ad5755.c:172:25: warning: incorrect type in assignment (different base types)
> drivers/iio/dac/ad5755.c:172:25: expected unsigned int [unsigned] [usertype] d32
> drivers/iio/dac/ad5755.c:172:25: got restricted __be32 [usertype] <noident>
> drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
> drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
> drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
> drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
> drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
> drivers/iio/dac/ad5755.c:176:23: warning: cast to restricted __be32
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks,
> ---
> drivers/iio/dac/ad5755.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c
> index 9a78d5a..bdf302d 100644
> --- a/drivers/iio/dac/ad5755.c
> +++ b/drivers/iio/dac/ad5755.c
> @@ -97,7 +97,7 @@ struct ad5755_state {
> */
>
> union {
> - u32 d32;
> + __be32 d32;
> u8 d8[4];
> } data[2] ____cacheline_aligned;
> };
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 06/15] iio:ad5791: Mark transfer buffers as __be32
2013-11-25 12:41 ` [PATCH 06/15] iio:ad5791: Mark transfer buffers " Lars-Peter Clausen
@ 2013-11-30 11:08 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:08 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:41, Lars-Peter Clausen wrote:
> Fixes the following warnings from sparse:
> drivers/iio/dac/ad5791.c:114:18: warning: incorrect type in assignment (different base types)
> drivers/iio/dac/ad5791.c:114:18: expected unsigned int [unsigned] [usertype] d32
> drivers/iio/dac/ad5791.c:114:18: got restricted __be32 [usertype] <noident>
> drivers/iio/dac/ad5791.c:142:21: warning: incorrect type in assignment (different base types)
> drivers/iio/dac/ad5791.c:142:21: expected unsigned int [unsigned] [usertype] d32
> drivers/iio/dac/ad5791.c:142:21: got restricted __be32 [usertype] <noident>
> drivers/iio/dac/ad5791.c:144:21: warning: incorrect type in assignment (different base types)
> drivers/iio/dac/ad5791.c:144:21: expected unsigned int [unsigned] [usertype] d32
> drivers/iio/dac/ad5791.c:144:21: got restricted __be32 [usertype] <noident>
> drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
> drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
> drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
> drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
> drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
> drivers/iio/dac/ad5791.c:148:16: warning: cast to restricted __be32
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks
> ---
> drivers/iio/dac/ad5791.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
> index d64acbd..1e7f4cd 100644
> --- a/drivers/iio/dac/ad5791.c
> +++ b/drivers/iio/dac/ad5791.c
> @@ -107,7 +107,7 @@ enum ad5791_supported_device_ids {
> static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
> {
> union {
> - u32 d32;
> + __be32 d32;
> u8 d8[4];
> } data;
>
> @@ -121,7 +121,7 @@ static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
> static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
> {
> union {
> - u32 d32;
> + __be32 d32;
> u8 d8[4];
> } data[3];
> int ret;
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 07/15] iio:ad5791: Do not store transfer buffers on the stack
2013-11-25 12:41 ` [PATCH 07/15] iio:ad5791: Do not store transfer buffers on the stack Lars-Peter Clausen
@ 2013-11-30 11:09 ` Jonathan Cameron
2013-12-22 17:36 ` Jonathan Cameron
0 siblings, 1 reply; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:09 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:41, Lars-Peter Clausen wrote:
> Some SPI controllers may not be able to handle transfer buffers that are placed
> on the stack.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks
> ---
> drivers/iio/dac/ad5791.c | 46 +++++++++++++++++++++-------------------------
> 1 file changed, 21 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
> index 1e7f4cd..79bf199 100644
> --- a/drivers/iio/dac/ad5791.c
> +++ b/drivers/iio/dac/ad5791.c
> @@ -91,6 +91,11 @@ struct ad5791_state {
> unsigned ctrl;
> unsigned pwr_down_mode;
> bool pwr_down;
> +
> + union {
> + __be32 d32;
> + u8 d8[4];
> + } data[3] ____cacheline_aligned;
> };
>
> /**
> @@ -104,48 +109,39 @@ enum ad5791_supported_device_ids {
> ID_AD5791,
> };
>
> -static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
> +static int ad5791_spi_write(struct ad5791_state *st, u8 addr, u32 val)
> {
> - union {
> - __be32 d32;
> - u8 d8[4];
> - } data;
> -
> - data.d32 = cpu_to_be32(AD5791_CMD_WRITE |
> + st->data[0].d32 = cpu_to_be32(AD5791_CMD_WRITE |
> AD5791_ADDR(addr) |
> (val & AD5791_DAC_MASK));
>
> - return spi_write(spi, &data.d8[1], 3);
> + return spi_write(st->spi, &st->data[0].d8[1], 3);
> }
>
> -static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
> +static int ad5791_spi_read(struct ad5791_state *st, u8 addr, u32 *val)
> {
> - union {
> - __be32 d32;
> - u8 d8[4];
> - } data[3];
> int ret;
> struct spi_transfer xfers[] = {
> {
> - .tx_buf = &data[0].d8[1],
> + .tx_buf = &st->data[0].d8[1],
> .bits_per_word = 8,
> .len = 3,
> .cs_change = 1,
> }, {
> - .tx_buf = &data[1].d8[1],
> - .rx_buf = &data[2].d8[1],
> + .tx_buf = &st->data[1].d8[1],
> + .rx_buf = &st->data[2].d8[1],
> .bits_per_word = 8,
> .len = 3,
> },
> };
>
> - data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
> + st->data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
> AD5791_ADDR(addr));
> - data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
> + st->data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
>
> - ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers));
> + ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
>
> - *val = be32_to_cpu(data[2].d32);
> + *val = be32_to_cpu(st->data[2].d32);
>
> return ret;
> }
> @@ -210,7 +206,7 @@ static ssize_t ad5791_write_dac_powerdown(struct iio_dev *indio_dev,
> }
> st->pwr_down = pwr_down;
>
> - ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl);
> + ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl);
>
> return ret ? ret : len;
> }
> @@ -263,7 +259,7 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
>
> switch (m) {
> case IIO_CHAN_INFO_RAW:
> - ret = ad5791_spi_read(st->spi, chan->address, val);
> + ret = ad5791_spi_read(st, chan->address, val);
> if (ret)
> return ret;
> *val &= AD5791_DAC_MASK;
> @@ -330,7 +326,7 @@ static int ad5791_write_raw(struct iio_dev *indio_dev,
> val &= AD5791_RES_MASK(chan->scan_type.realbits);
> val <<= chan->scan_type.shift;
>
> - return ad5791_spi_write(st->spi, chan->address, val);
> + return ad5791_spi_write(st, chan->address, val);
>
> default:
> return -EINVAL;
> @@ -393,7 +389,7 @@ static int ad5791_probe(struct spi_device *spi)
> dev_warn(&spi->dev, "reference voltage unspecified\n");
> }
>
> - ret = ad5791_spi_write(spi, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
> + ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
> if (ret)
> goto error_disable_reg_neg;
>
> @@ -405,7 +401,7 @@ static int ad5791_probe(struct spi_device *spi)
> | ((pdata && pdata->use_rbuf_gain2) ? 0 : AD5791_CTRL_RBUF) |
> AD5791_CTRL_BIN2SC;
>
> - ret = ad5791_spi_write(spi, AD5791_ADDR_CTRL, st->ctrl |
> + ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl |
> AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
> if (ret)
> goto error_disable_reg_neg;
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 08/15] iio:ad7266: Mark transfer buffer as __be16
2013-11-25 12:42 ` [PATCH 08/15] iio:ad7266: Mark transfer buffer as __be16 Lars-Peter Clausen
@ 2013-11-30 11:10 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:10 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:42, Lars-Peter Clausen wrote:
> Fixes the following warnings from sparse:
> drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16
> drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16
> drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16
> drivers/iio/adc/ad7266.c:140:16: warning: cast to restricted __be16
Technically this does a fair bit of other refactoring, but that's all good
anyway.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks.
> ---
> drivers/iio/adc/ad7266.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
> index 58e9455..70f78c3 100644
> --- a/drivers/iio/adc/ad7266.c
> +++ b/drivers/iio/adc/ad7266.c
> @@ -43,19 +43,22 @@ struct ad7266_state {
> * The buffer needs to be large enough to hold two samples (4 bytes) and
> * the naturally aligned timestamp (8 bytes).
> */
> - uint8_t data[ALIGN(4, sizeof(s64)) + sizeof(s64)] ____cacheline_aligned;
> + struct {
> + __be16 sample[2];
> + s64 timestamp;
> + } data ____cacheline_aligned;
> };
>
> static int ad7266_wakeup(struct ad7266_state *st)
> {
> /* Any read with >= 2 bytes will wake the device */
> - return spi_read(st->spi, st->data, 2);
> + return spi_read(st->spi, &st->data.sample[0], 2);
> }
>
> static int ad7266_powerdown(struct ad7266_state *st)
> {
> /* Any read with < 2 bytes will powerdown the device */
> - return spi_read(st->spi, st->data, 1);
> + return spi_read(st->spi, &st->data.sample[0], 1);
> }
>
> static int ad7266_preenable(struct iio_dev *indio_dev)
> @@ -84,9 +87,9 @@ static irqreturn_t ad7266_trigger_handler(int irq, void *p)
> struct ad7266_state *st = iio_priv(indio_dev);
> int ret;
>
> - ret = spi_read(st->spi, st->data, 4);
> + ret = spi_read(st->spi, st->data.sample, 4);
> if (ret == 0) {
> - iio_push_to_buffers_with_timestamp(indio_dev, st->data,
> + iio_push_to_buffers_with_timestamp(indio_dev, &st->data,
> pf->timestamp);
> }
>
> @@ -137,7 +140,7 @@ static int ad7266_read_single(struct ad7266_state *st, int *val,
> ad7266_select_input(st, address);
>
> ret = spi_sync(st->spi, &st->single_msg);
> - *val = be16_to_cpu(st->data[address % 2]);
> + *val = be16_to_cpu(st->data.sample[address % 2]);
>
> return ret;
> }
> @@ -442,15 +445,15 @@ static int ad7266_probe(struct spi_device *spi)
> ad7266_init_channels(indio_dev);
>
> /* wakeup */
> - st->single_xfer[0].rx_buf = &st->data;
> + st->single_xfer[0].rx_buf = &st->data.sample[0];
> st->single_xfer[0].len = 2;
> st->single_xfer[0].cs_change = 1;
> /* conversion */
> - st->single_xfer[1].rx_buf = &st->data;
> + st->single_xfer[1].rx_buf = st->data.sample;
> st->single_xfer[1].len = 4;
> st->single_xfer[1].cs_change = 1;
> /* powerdown */
> - st->single_xfer[2].tx_buf = &st->data;
> + st->single_xfer[2].tx_buf = &st->data.sample[0];
> st->single_xfer[2].len = 1;
>
> spi_message_init(&st->single_msg);
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 09/15] iio:vcnl4000: Mark transfer buffer as __be16
2013-11-25 12:42 ` [PATCH 09/15] iio:vcnl4000: " Lars-Peter Clausen
@ 2013-11-30 11:11 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:11 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio, Peter Meerwald
On 11/25/13 12:42, Lars-Peter Clausen wrote:
> Fixes the following warnings from sparse:
> drivers/iio/light/vcnl4000.c:88:16: warning: cast to restricted __be16
> drivers/iio/light/vcnl4000.c:88:16: warning: cast to restricted __be16
> drivers/iio/light/vcnl4000.c:88:16: warning: cast to restricted __be16
> drivers/iio/light/vcnl4000.c:88:16: warning: cast to restricted __be16
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git
Thanks
> ---
> drivers/iio/light/vcnl4000.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index ecb3341..2f2c9be 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -56,7 +56,7 @@ static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask,
> u8 rdy_mask, u8 data_reg, int *val)
> {
> int tries = 20;
> - u16 buf;
> + __be16 buf;
> int ret;
>
> ret = i2c_smbus_write_byte_data(data->client, VCNL4000_COMMAND,
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 10/15] staging:iio:ad7280a: Mark transfer buffer as __be32
2013-11-25 12:42 ` [PATCH 10/15] staging:iio:ad7280a: Mark transfer buffer as __be32 Lars-Peter Clausen
@ 2013-11-30 11:12 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:12 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:42, Lars-Peter Clausen wrote:
> Fixes the following warnings from sparse:
> drivers/staging/iio/adc/ad7280a.c:194:35: warning: incorrect type in initializer (different base types)
> drivers/staging/iio/adc/ad7280a.c:194:35: expected unsigned int [unsigned] tx_buf
> drivers/staging/iio/adc/ad7280a.c:194:35: got restricted __be32 [usertype] <noident>
> drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
> drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
> drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
> drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
> drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
> drivers/staging/iio/adc/ad7280a.c:207:16: warning: cast to restricted __be32
> drivers/staging/iio/adc/ad7280a.c:219:13: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/adc/ad7280a.c:219:13: expected unsigned int [unsigned] [assigned] reg
> drivers/staging/iio/adc/ad7280a.c:219:13: got restricted __be32 [usertype] <noident>
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
thanks
> ---
> drivers/staging/iio/adc/ad7280a.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index 8209fa5..89ee65b 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -191,7 +191,7 @@ static void ad7280_delay(struct ad7280_state *st)
>
> static int __ad7280_read32(struct spi_device *spi, unsigned *val)
> {
> - unsigned rx_buf, tx_buf = cpu_to_be32(AD7280A_READ_TXVAL);
> + __be32 rx_buf, tx_buf = cpu_to_be32(AD7280A_READ_TXVAL);
> int ret;
>
> struct spi_transfer t = {
> @@ -214,11 +214,12 @@ static int ad7280_write(struct ad7280_state *st, unsigned devaddr,
> {
> unsigned reg = (devaddr << 27 | addr << 21 |
> (val & 0xFF) << 13 | all << 12);
> + __be32 tx_buf;
>
> reg |= ad7280_calc_crc8(st->crc_tab, reg >> 11) << 3 | 0x2;
> - reg = cpu_to_be32(reg);
> + tx_buf = cpu_to_be32(reg);
>
> - return spi_write(st->spi, ®, 4);
> + return spi_write(st->spi, &tx_buf, 4);
> }
>
> static int ad7280_read(struct ad7280_state *st, unsigned devaddr,
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 11/15] staging:iio:ad7280a: Do not store transfer buffer on the stack
2013-11-25 12:42 ` [PATCH 11/15] staging:iio:ad7280a: Do not store transfer buffer on the stack Lars-Peter Clausen
@ 2013-11-30 11:12 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:12 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:42, Lars-Peter Clausen wrote:
> Some I2C controllers may not be able to handle transfer buffers that are placed
> on the stack.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
> ---
> drivers/staging/iio/adc/ad7280a.c | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index 89ee65b..1ac11f6 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -134,6 +134,8 @@ struct ad7280_state {
> unsigned char aux_threshhigh;
> unsigned char aux_threshlow;
> unsigned char cb_mask[AD7280A_MAX_CHAIN];
> +
> + __be32 buf[2] ____cacheline_aligned;
> };
>
> static void ad7280_crc8_build_table(unsigned char *crc_tab)
> @@ -189,22 +191,22 @@ static void ad7280_delay(struct ad7280_state *st)
> 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;
> -
> struct spi_transfer t = {
> - .tx_buf = &tx_buf,
> - .rx_buf = &rx_buf,
> + .tx_buf = &st->buf[0],
> + .rx_buf = &st->buf[1],
> .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)
> return ret;
>
> - *val = be32_to_cpu(rx_buf);
> + *val = be32_to_cpu(st->buf[1]);
>
> return 0;
> }
> @@ -214,12 +216,11 @@ static int ad7280_write(struct ad7280_state *st, unsigned devaddr,
> {
> unsigned reg = (devaddr << 27 | addr << 21 |
> (val & 0xFF) << 13 | all << 12);
> - __be32 tx_buf;
>
> 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,
> @@ -249,7 +250,7 @@ static int ad7280_read(struct ad7280_state *st, unsigned devaddr,
> if (ret)
> return ret;
>
> - __ad7280_read32(st->spi, &tmp);
> + __ad7280_read32(st, &tmp);
>
> if (ad7280_check_crc(st, tmp))
> return -EIO;
> @@ -287,7 +288,7 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned devaddr,
>
> ad7280_delay(st);
>
> - __ad7280_read32(st->spi, &tmp);
> + __ad7280_read32(st, &tmp);
>
> if (ad7280_check_crc(st, tmp))
> return -EIO;
> @@ -320,7 +321,7 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned cnt,
> ad7280_delay(st);
>
> for (i = 0; i < cnt; i++) {
> - __ad7280_read32(st->spi, &tmp);
> + __ad7280_read32(st, &tmp);
>
> if (ad7280_check_crc(st, tmp))
> return -EIO;
> @@ -363,7 +364,7 @@ static int ad7280_chain_setup(struct ad7280_state *st)
> return ret;
>
> for (n = 0; n <= AD7280A_MAX_CHAIN; n++) {
> - __ad7280_read32(st->spi, &val);
> + __ad7280_read32(st, &val);
> if (val == 0)
> return n - 1;
>
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 12/15] staging:iio:ad7746: Mark transfer buffer as __be32
2013-11-25 12:42 ` [PATCH 12/15] staging:iio:ad7746: Mark transfer buffer as __be32 Lars-Peter Clausen
@ 2013-11-30 11:13 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:13 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:42, Lars-Peter Clausen wrote:
> Fixes the following warnings from sparse:
> drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
> drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
> drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
> drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
> drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
> drivers/staging/iio/cdc/ad7746.c:599:25: warning: cast to restricted __be32
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks
> ---
> drivers/staging/iio/cdc/ad7746.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
> index 862d68d..01e15e2 100644
> --- a/drivers/staging/iio/cdc/ad7746.c
> +++ b/drivers/staging/iio/cdc/ad7746.c
> @@ -567,7 +567,7 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
> u8 regval, reg;
>
> union {
> - u32 d32;
> + __be32 d32;
> u8 d8[4];
> } data;
>
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 13/15] staging:iio:ad7746: Do not store the transfer buffer on the stack
2013-11-25 12:42 ` [PATCH 13/15] staging:iio:ad7746: Do not store the transfer buffer on the stack Lars-Peter Clausen
@ 2013-11-30 11:13 ` Jonathan Cameron
2013-12-22 17:22 ` Jonathan Cameron
0 siblings, 1 reply; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:13 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:42, Lars-Peter Clausen wrote:
> Some I2C controllers might not be able to handle transfer buffers that are
> stored on stack.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks,
> ---
> drivers/staging/iio/cdc/ad7746.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
> index 01e15e2..cbb1588 100644
> --- a/drivers/staging/iio/cdc/ad7746.c
> +++ b/drivers/staging/iio/cdc/ad7746.c
> @@ -105,6 +105,11 @@ struct ad7746_chip_info {
> u8 vt_setup;
> u8 capdac[2][2];
> s8 capdac_set;
> +
> + union {
> + __be32 d32;
> + u8 d8[4];
> + } data ____cacheline_aligned;
> };
>
> enum ad7746_chan {
> @@ -566,11 +571,6 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
> int ret, delay;
> u8 regval, reg;
>
> - union {
> - __be32 d32;
> - u8 d8[4];
> - } data;
> -
> mutex_lock(&indio_dev->mlock);
>
> switch (mask) {
> @@ -591,12 +591,12 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
> /* Now read the actual register */
>
> ret = i2c_smbus_read_i2c_block_data(chip->client,
> - chan->address >> 8, 3, &data.d8[1]);
> + chan->address >> 8, 3, &chip->data.d8[1]);
>
> if (ret < 0)
> goto out;
>
> - *val = (be32_to_cpu(data.d32) & 0xFFFFFF) - 0x800000;
> + *val = (be32_to_cpu(chip->data.d32) & 0xFFFFFF) - 0x800000;
>
> switch (chan->type) {
> case IIO_TEMP:
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 14/15] staging:iio:ad9832: Mark transfer buffers as __be16
2013-11-25 12:42 ` [PATCH 14/15] staging:iio:ad9832: Mark transfer buffers as __be16 Lars-Peter Clausen
@ 2013-11-30 11:14 ` Jonathan Cameron
2013-12-03 10:27 ` Lars-Peter Clausen
0 siblings, 1 reply; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:14 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:42, Lars-Peter Clausen wrote:
> Fixes the following warnings from sparse:
> drivers/staging/iio/frequency/ad9832.c:43:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9832.c:43:26: expected unsigned short [unsigned] [short] <noident>
> drivers/staging/iio/frequency/ad9832.c:43:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9832.c:46:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9832.c:46:26: expected unsigned short [unsigned] [short] <noident>
> drivers/staging/iio/frequency/ad9832.c:46:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9832.c:49:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9832.c:49:26: expected unsigned short [unsigned] [short] <noident>
> drivers/staging/iio/frequency/ad9832.c:49:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9832.c:52:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9832.c:52:26: expected unsigned short [unsigned] [short] <noident>
> drivers/staging/iio/frequency/ad9832.c:52:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9832.c:65:27: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9832.c:65:27: expected unsigned short [unsigned] [short] <noident>
> drivers/staging/iio/frequency/ad9832.c:65:27: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9832.c:68:27: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9832.c:68:27: expected unsigned short [unsigned] [short] <noident>
> drivers/staging/iio/frequency/ad9832.c:68:27: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9832.c:107:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9832.c:107:26: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9832.c:107:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9832.c:120:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9832.c:120:26: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9832.c:120:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9832.c:133:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9832.c:133:26: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9832.c:133:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9832.c:144:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9832.c:144:26: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9832.c:144:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9832.c:277:18: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9832.c:277:18: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9832.c:277:18: got restricted __be16 [usertype] <noident>
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks,
> ---
> drivers/staging/iio/frequency/ad9832.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/iio/frequency/ad9832.h b/drivers/staging/iio/frequency/ad9832.h
> index c5b701f..386f4dc 100644
> --- a/drivers/staging/iio/frequency/ad9832.h
> +++ b/drivers/staging/iio/frequency/ad9832.h
> @@ -92,9 +92,9 @@ struct ad9832_state {
> * transfer buffers to live in their own cache lines.
> */
> union {
> - unsigned short freq_data[4]____cacheline_aligned;
> - unsigned short phase_data[2];
> - unsigned short data;
> + __be16 freq_data[4]____cacheline_aligned;
> + __be16 phase_data[2];
> + __be16 data;
> };
> };
>
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 15/15] staging:iio:ad9834: Mark transfer buffers as __b16
2013-11-25 12:42 ` [PATCH 15/15] staging:iio:ad9834: Mark transfer buffers as __b16 Lars-Peter Clausen
@ 2013-11-30 11:14 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-11-30 11:14 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/25/13 12:42, Lars-Peter Clausen wrote:
> Fixes the following warnings from sparse:
> drivers/staging/iio/frequency/ad9834.c:45:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9834.c:45:26: expected unsigned short [unsigned] [short] <noident>
> drivers/staging/iio/frequency/ad9834.c:45:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9834.c:47:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9834.c:47:26: expected unsigned short [unsigned] [short] <noident>
> drivers/staging/iio/frequency/ad9834.c:47:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9834.c:59:18: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9834.c:59:18: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9834.c:59:18: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9834.c:100:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9834.c:100:26: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9834.c:100:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9834.c:108:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9834.c:108:26: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9834.c:108:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9834.c:122:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9834.c:122:26: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9834.c:122:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9834.c:131:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9834.c:131:26: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9834.c:131:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9834.c:194:26: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9834.c:194:26: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9834.c:194:26: got restricted __be16 [usertype] <noident>
> drivers/staging/iio/frequency/ad9834.c:387:18: warning: incorrect type in assignment (different base types)
> drivers/staging/iio/frequency/ad9834.c:387:18: expected unsigned short [unsigned] data
> drivers/staging/iio/frequency/ad9834.c:387:18: got restricted __be16 [usertype] <noident>
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks
> ---
> drivers/staging/iio/frequency/ad9834.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/iio/frequency/ad9834.h b/drivers/staging/iio/frequency/ad9834.h
> index ed5ed8d..8ca6e52 100644
> --- a/drivers/staging/iio/frequency/ad9834.h
> +++ b/drivers/staging/iio/frequency/ad9834.h
> @@ -65,8 +65,8 @@ struct ad9834_state {
> * DMA (thus cache coherency maintenance) requires the
> * transfer buffers to live in their own cache lines.
> */
> - unsigned short data ____cacheline_aligned;
> - unsigned short freq_data[2] ;
> + __be16 data ____cacheline_aligned;
> + __be16 freq_data[2];
> };
>
>
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 14/15] staging:iio:ad9832: Mark transfer buffers as __be16
2013-11-30 11:14 ` Jonathan Cameron
@ 2013-12-03 10:27 ` Lars-Peter Clausen
2013-12-03 14:56 ` Jonathan Cameron
0 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-12-03 10:27 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio
On 11/30/2013 12:14 PM, Jonathan Cameron wrote:
> On 11/25/13 12:42, Lars-Peter Clausen wrote:
>> Fixes the following warnings from sparse:
>> drivers/staging/iio/frequency/ad9832.c:43:26: warning: incorrect type in assignment (different base types)
>> drivers/staging/iio/frequency/ad9832.c:43:26: expected unsigned short [unsigned] [short] <noident>
>> drivers/staging/iio/frequency/ad9832.c:43:26: got restricted __be16 [usertype] <noident>
>> drivers/staging/iio/frequency/ad9832.c:46:26: warning: incorrect type in assignment (different base types)
>> drivers/staging/iio/frequency/ad9832.c:46:26: expected unsigned short [unsigned] [short] <noident>
>> drivers/staging/iio/frequency/ad9832.c:46:26: got restricted __be16 [usertype] <noident>
>> drivers/staging/iio/frequency/ad9832.c:49:26: warning: incorrect type in assignment (different base types)
>> drivers/staging/iio/frequency/ad9832.c:49:26: expected unsigned short [unsigned] [short] <noident>
>> drivers/staging/iio/frequency/ad9832.c:49:26: got restricted __be16 [usertype] <noident>
>> drivers/staging/iio/frequency/ad9832.c:52:26: warning: incorrect type in assignment (different base types)
>> drivers/staging/iio/frequency/ad9832.c:52:26: expected unsigned short [unsigned] [short] <noident>
>> drivers/staging/iio/frequency/ad9832.c:52:26: got restricted __be16 [usertype] <noident>
>> drivers/staging/iio/frequency/ad9832.c:65:27: warning: incorrect type in assignment (different base types)
>> drivers/staging/iio/frequency/ad9832.c:65:27: expected unsigned short [unsigned] [short] <noident>
>> drivers/staging/iio/frequency/ad9832.c:65:27: got restricted __be16 [usertype] <noident>
>> drivers/staging/iio/frequency/ad9832.c:68:27: warning: incorrect type in assignment (different base types)
>> drivers/staging/iio/frequency/ad9832.c:68:27: expected unsigned short [unsigned] [short] <noident>
>> drivers/staging/iio/frequency/ad9832.c:68:27: got restricted __be16 [usertype] <noident>
>> drivers/staging/iio/frequency/ad9832.c:107:26: warning: incorrect type in assignment (different base types)
>> drivers/staging/iio/frequency/ad9832.c:107:26: expected unsigned short [unsigned] data
>> drivers/staging/iio/frequency/ad9832.c:107:26: got restricted __be16 [usertype] <noident>
>> drivers/staging/iio/frequency/ad9832.c:120:26: warning: incorrect type in assignment (different base types)
>> drivers/staging/iio/frequency/ad9832.c:120:26: expected unsigned short [unsigned] data
>> drivers/staging/iio/frequency/ad9832.c:120:26: got restricted __be16 [usertype] <noident>
>> drivers/staging/iio/frequency/ad9832.c:133:26: warning: incorrect type in assignment (different base types)
>> drivers/staging/iio/frequency/ad9832.c:133:26: expected unsigned short [unsigned] data
>> drivers/staging/iio/frequency/ad9832.c:133:26: got restricted __be16 [usertype] <noident>
>> drivers/staging/iio/frequency/ad9832.c:144:26: warning: incorrect type in assignment (different base types)
>> drivers/staging/iio/frequency/ad9832.c:144:26: expected unsigned short [unsigned] data
>> drivers/staging/iio/frequency/ad9832.c:144:26: got restricted __be16 [usertype] <noident>
>> drivers/staging/iio/frequency/ad9832.c:277:18: warning: incorrect type in assignment (different base types)
>> drivers/staging/iio/frequency/ad9832.c:277:18: expected unsigned short [unsigned] data
>> drivers/staging/iio/frequency/ad9832.c:277:18: got restricted __be16 [usertype] <noident>
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Applied to the togreg branch of iio.git
Thanks, for taking care of the patches. Somehow this one and the ad9834
didn't make it. Shall I resend?
- Lars
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 14/15] staging:iio:ad9832: Mark transfer buffers as __be16
2013-12-03 10:27 ` Lars-Peter Clausen
@ 2013-12-03 14:56 ` Jonathan Cameron
2013-12-03 20:09 ` Jonathan Cameron
0 siblings, 1 reply; 38+ messages in thread
From: Jonathan Cameron @ 2013-12-03 14:56 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
Lars-Peter Clausen <lars@metafoo.de> wrote:
>On 11/30/2013 12:14 PM, Jonathan Cameron wrote:
>> On 11/25/13 12:42, Lars-Peter Clausen wrote:
>>> Fixes the following warnings from sparse:
>>> drivers/staging/iio/frequency/ad9832.c:43:26: warning: incorrect
>type in assignment (different base types)
>>> drivers/staging/iio/frequency/ad9832.c:43:26: expected unsigned
>short [unsigned] [short] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:43:26: got restricted
>__be16 [usertype] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:46:26: warning: incorrect
>type in assignment (different base types)
>>> drivers/staging/iio/frequency/ad9832.c:46:26: expected unsigned
>short [unsigned] [short] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:46:26: got restricted
>__be16 [usertype] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:49:26: warning: incorrect
>type in assignment (different base types)
>>> drivers/staging/iio/frequency/ad9832.c:49:26: expected unsigned
>short [unsigned] [short] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:49:26: got restricted
>__be16 [usertype] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:52:26: warning: incorrect
>type in assignment (different base types)
>>> drivers/staging/iio/frequency/ad9832.c:52:26: expected unsigned
>short [unsigned] [short] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:52:26: got restricted
>__be16 [usertype] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:65:27: warning: incorrect
>type in assignment (different base types)
>>> drivers/staging/iio/frequency/ad9832.c:65:27: expected unsigned
>short [unsigned] [short] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:65:27: got restricted
>__be16 [usertype] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:68:27: warning: incorrect
>type in assignment (different base types)
>>> drivers/staging/iio/frequency/ad9832.c:68:27: expected unsigned
>short [unsigned] [short] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:68:27: got restricted
>__be16 [usertype] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:107:26: warning: incorrect
>type in assignment (different base types)
>>> drivers/staging/iio/frequency/ad9832.c:107:26: expected unsigned
>short [unsigned] data
>>> drivers/staging/iio/frequency/ad9832.c:107:26: got restricted
>__be16 [usertype] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:120:26: warning: incorrect
>type in assignment (different base types)
>>> drivers/staging/iio/frequency/ad9832.c:120:26: expected unsigned
>short [unsigned] data
>>> drivers/staging/iio/frequency/ad9832.c:120:26: got restricted
>__be16 [usertype] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:133:26: warning: incorrect
>type in assignment (different base types)
>>> drivers/staging/iio/frequency/ad9832.c:133:26: expected unsigned
>short [unsigned] data
>>> drivers/staging/iio/frequency/ad9832.c:133:26: got restricted
>__be16 [usertype] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:144:26: warning: incorrect
>type in assignment (different base types)
>>> drivers/staging/iio/frequency/ad9832.c:144:26: expected unsigned
>short [unsigned] data
>>> drivers/staging/iio/frequency/ad9832.c:144:26: got restricted
>__be16 [usertype] <noident>
>>> drivers/staging/iio/frequency/ad9832.c:277:18: warning: incorrect
>type in assignment (different base types)
>>> drivers/staging/iio/frequency/ad9832.c:277:18: expected unsigned
>short [unsigned] data
>>> drivers/staging/iio/frequency/ad9832.c:277:18: got restricted
>__be16 [usertype] <noident>
>>>
>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>> Applied to the togreg branch of iio.git
>
>Thanks, for taking care of the patches. Somehow this one and the ad9834
>didn't make it. Shall I resend?
>
Oops I probably got distracted. Don't worry about the resending. I will track them down.
>- Lars
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 14/15] staging:iio:ad9832: Mark transfer buffers as __be16
2013-12-03 14:56 ` Jonathan Cameron
@ 2013-12-03 20:09 ` Jonathan Cameron
2013-12-03 20:11 ` Lars-Peter Clausen
0 siblings, 1 reply; 38+ messages in thread
From: Jonathan Cameron @ 2013-12-03 20:09 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 12/03/13 14:56, Jonathan Cameron wrote:
>
>
> Lars-Peter Clausen <lars@metafoo.de> wrote:
>> On 11/30/2013 12:14 PM, Jonathan Cameron wrote:
>>> On 11/25/13 12:42, Lars-Peter Clausen wrote:
>>>> Fixes the following warnings from sparse:
>>>> drivers/staging/iio/frequency/ad9832.c:43:26: warning: incorrect
>> type in assignment (different base types)
>>>> drivers/staging/iio/frequency/ad9832.c:43:26: expected unsigned
>> short [unsigned] [short] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:43:26: got restricted
>> __be16 [usertype] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:46:26: warning: incorrect
>> type in assignment (different base types)
>>>> drivers/staging/iio/frequency/ad9832.c:46:26: expected unsigned
>> short [unsigned] [short] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:46:26: got restricted
>> __be16 [usertype] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:49:26: warning: incorrect
>> type in assignment (different base types)
>>>> drivers/staging/iio/frequency/ad9832.c:49:26: expected unsigned
>> short [unsigned] [short] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:49:26: got restricted
>> __be16 [usertype] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:52:26: warning: incorrect
>> type in assignment (different base types)
>>>> drivers/staging/iio/frequency/ad9832.c:52:26: expected unsigned
>> short [unsigned] [short] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:52:26: got restricted
>> __be16 [usertype] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:65:27: warning: incorrect
>> type in assignment (different base types)
>>>> drivers/staging/iio/frequency/ad9832.c:65:27: expected unsigned
>> short [unsigned] [short] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:65:27: got restricted
>> __be16 [usertype] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:68:27: warning: incorrect
>> type in assignment (different base types)
>>>> drivers/staging/iio/frequency/ad9832.c:68:27: expected unsigned
>> short [unsigned] [short] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:68:27: got restricted
>> __be16 [usertype] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:107:26: warning: incorrect
>> type in assignment (different base types)
>>>> drivers/staging/iio/frequency/ad9832.c:107:26: expected unsigned
>> short [unsigned] data
>>>> drivers/staging/iio/frequency/ad9832.c:107:26: got restricted
>> __be16 [usertype] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:120:26: warning: incorrect
>> type in assignment (different base types)
>>>> drivers/staging/iio/frequency/ad9832.c:120:26: expected unsigned
>> short [unsigned] data
>>>> drivers/staging/iio/frequency/ad9832.c:120:26: got restricted
>> __be16 [usertype] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:133:26: warning: incorrect
>> type in assignment (different base types)
>>>> drivers/staging/iio/frequency/ad9832.c:133:26: expected unsigned
>> short [unsigned] data
>>>> drivers/staging/iio/frequency/ad9832.c:133:26: got restricted
>> __be16 [usertype] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:144:26: warning: incorrect
>> type in assignment (different base types)
>>>> drivers/staging/iio/frequency/ad9832.c:144:26: expected unsigned
>> short [unsigned] data
>>>> drivers/staging/iio/frequency/ad9832.c:144:26: got restricted
>> __be16 [usertype] <noident>
>>>> drivers/staging/iio/frequency/ad9832.c:277:18: warning: incorrect
>> type in assignment (different base types)
>>>> drivers/staging/iio/frequency/ad9832.c:277:18: expected unsigned
>> short [unsigned] data
>>>> drivers/staging/iio/frequency/ad9832.c:277:18: got restricted
>> __be16 [usertype] <noident>
>>>>
>>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>>> Applied to the togreg branch of iio.git
>>
>> Thanks, for taking care of the patches. Somehow this one and the ad9834
>> didn't make it. Shall I resend?
>>
> Oops I probably got distracted. Don't worry about the resending. I will track them down.
Both have now 'actually' been applied and pushed out.
>> - Lars
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 14/15] staging:iio:ad9832: Mark transfer buffers as __be16
2013-12-03 20:09 ` Jonathan Cameron
@ 2013-12-03 20:11 ` Lars-Peter Clausen
0 siblings, 0 replies; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-12-03 20:11 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio
On 12/03/2013 09:09 PM, Jonathan Cameron wrote:
> On 12/03/13 14:56, Jonathan Cameron wrote:
>>
>>
>> Lars-Peter Clausen <lars@metafoo.de> wrote:
>>> On 11/30/2013 12:14 PM, Jonathan Cameron wrote:
>>>> On 11/25/13 12:42, Lars-Peter Clausen wrote:
>>>>> Fixes the following warnings from sparse:
>>>>> drivers/staging/iio/frequency/ad9832.c:43:26: warning: incorrect
>>> type in assignment (different base types)
>>>>> drivers/staging/iio/frequency/ad9832.c:43:26: expected unsigned
>>> short [unsigned] [short] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:43:26: got restricted
>>> __be16 [usertype] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:46:26: warning: incorrect
>>> type in assignment (different base types)
>>>>> drivers/staging/iio/frequency/ad9832.c:46:26: expected unsigned
>>> short [unsigned] [short] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:46:26: got restricted
>>> __be16 [usertype] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:49:26: warning: incorrect
>>> type in assignment (different base types)
>>>>> drivers/staging/iio/frequency/ad9832.c:49:26: expected unsigned
>>> short [unsigned] [short] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:49:26: got restricted
>>> __be16 [usertype] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:52:26: warning: incorrect
>>> type in assignment (different base types)
>>>>> drivers/staging/iio/frequency/ad9832.c:52:26: expected unsigned
>>> short [unsigned] [short] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:52:26: got restricted
>>> __be16 [usertype] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:65:27: warning: incorrect
>>> type in assignment (different base types)
>>>>> drivers/staging/iio/frequency/ad9832.c:65:27: expected unsigned
>>> short [unsigned] [short] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:65:27: got restricted
>>> __be16 [usertype] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:68:27: warning: incorrect
>>> type in assignment (different base types)
>>>>> drivers/staging/iio/frequency/ad9832.c:68:27: expected unsigned
>>> short [unsigned] [short] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:68:27: got restricted
>>> __be16 [usertype] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:107:26: warning: incorrect
>>> type in assignment (different base types)
>>>>> drivers/staging/iio/frequency/ad9832.c:107:26: expected unsigned
>>> short [unsigned] data
>>>>> drivers/staging/iio/frequency/ad9832.c:107:26: got restricted
>>> __be16 [usertype] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:120:26: warning: incorrect
>>> type in assignment (different base types)
>>>>> drivers/staging/iio/frequency/ad9832.c:120:26: expected unsigned
>>> short [unsigned] data
>>>>> drivers/staging/iio/frequency/ad9832.c:120:26: got restricted
>>> __be16 [usertype] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:133:26: warning: incorrect
>>> type in assignment (different base types)
>>>>> drivers/staging/iio/frequency/ad9832.c:133:26: expected unsigned
>>> short [unsigned] data
>>>>> drivers/staging/iio/frequency/ad9832.c:133:26: got restricted
>>> __be16 [usertype] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:144:26: warning: incorrect
>>> type in assignment (different base types)
>>>>> drivers/staging/iio/frequency/ad9832.c:144:26: expected unsigned
>>> short [unsigned] data
>>>>> drivers/staging/iio/frequency/ad9832.c:144:26: got restricted
>>> __be16 [usertype] <noident>
>>>>> drivers/staging/iio/frequency/ad9832.c:277:18: warning: incorrect
>>> type in assignment (different base types)
>>>>> drivers/staging/iio/frequency/ad9832.c:277:18: expected unsigned
>>> short [unsigned] data
>>>>> drivers/staging/iio/frequency/ad9832.c:277:18: got restricted
>>> __be16 [usertype] <noident>
>>>>>
>>>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>>>> Applied to the togreg branch of iio.git
>>>
>>> Thanks, for taking care of the patches. Somehow this one and the ad9834
>>> didn't make it. Shall I resend?
>>>
>> Oops I probably got distracted. Don't worry about the resending. I will track them down.
> Both have now 'actually' been applied and pushed out.
thanks.
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 13/15] staging:iio:ad7746: Do not store the transfer buffer on the stack
2013-11-30 11:13 ` Jonathan Cameron
@ 2013-12-22 17:22 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-12-22 17:22 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/30/13 11:13, Jonathan Cameron wrote:
> On 11/25/13 12:42, Lars-Peter Clausen wrote:
>> Some I2C controllers might not be able to handle transfer buffers that are
>> stored on stack.
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Applied to the togreg branch of iio.git
>
> Thanks,
Hi Lars,
I let this one through without quite enough scrutiny. It's a valid cleanup, but the statement
that some i2c controllers migh tnot be able to handle transfer buffers that are stored on the
stack is missleading, seeing as the relevant i2c calls do an explicit memcpy - (curriously to
another buffer that is also on the stack...) I guess this might change in future. In the pull
request I've mentioned that it isn't a problem right now.
So I should have picked up on the commit message content!
oops.
I'm not rebasing for a missleading bit of comment though so hopefully no one upstream will care
too much!
>> ---
>> drivers/staging/iio/cdc/ad7746.c | 14 +++++++-------
>> 1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
>> index 01e15e2..cbb1588 100644
>> --- a/drivers/staging/iio/cdc/ad7746.c
>> +++ b/drivers/staging/iio/cdc/ad7746.c
>> @@ -105,6 +105,11 @@ struct ad7746_chip_info {
>> u8 vt_setup;
>> u8 capdac[2][2];
>> s8 capdac_set;
>> +
>> + union {
>> + __be32 d32;
>> + u8 d8[4];
>> + } data ____cacheline_aligned;
>> };
>>
>> enum ad7746_chan {
>> @@ -566,11 +571,6 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
>> int ret, delay;
>> u8 regval, reg;
>>
>> - union {
>> - __be32 d32;
>> - u8 d8[4];
>> - } data;
>> -
>> mutex_lock(&indio_dev->mlock);
>>
>> switch (mask) {
>> @@ -591,12 +591,12 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
>> /* Now read the actual register */
>>
>> ret = i2c_smbus_read_i2c_block_data(chip->client,
>> - chan->address >> 8, 3, &data.d8[1]);
>> + chan->address >> 8, 3, &chip->data.d8[1]);
>>
>> if (ret < 0)
>> goto out;
>>
>> - *val = (be32_to_cpu(data.d32) & 0xFFFFFF) - 0x800000;
>> + *val = (be32_to_cpu(chip->data.d32) & 0xFFFFFF) - 0x800000;
>>
>> switch (chan->type) {
>> case IIO_TEMP:
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 07/15] iio:ad5791: Do not store transfer buffers on the stack
2013-11-30 11:09 ` Jonathan Cameron
@ 2013-12-22 17:36 ` Jonathan Cameron
2013-12-22 17:40 ` Lars-Peter Clausen
0 siblings, 1 reply; 38+ messages in thread
From: Jonathan Cameron @ 2013-12-22 17:36 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 11/30/13 11:09, Jonathan Cameron wrote:
> On 11/25/13 12:41, Lars-Peter Clausen wrote:
>> Some SPI controllers may not be able to handle transfer buffers that are placed
>> on the stack.
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Applied to the togreg branch of iio.git
>
> Thanks
I really didn't review this series well enough. This should probably have
gone in as a fix rather that through the togreg branch as should the other sp
driver. Bit late now though given the size of the patch.
Sorry it has taken me so long to do a pull request to Greg. I always
get a bit lazy on the stuff for next as can always do it tomorrow!
Slipped rather long this time though!
Jonathan
>> ---
>> drivers/iio/dac/ad5791.c | 46 +++++++++++++++++++++-------------------------
>> 1 file changed, 21 insertions(+), 25 deletions(-)
>>
>> diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
>> index 1e7f4cd..79bf199 100644
>> --- a/drivers/iio/dac/ad5791.c
>> +++ b/drivers/iio/dac/ad5791.c
>> @@ -91,6 +91,11 @@ struct ad5791_state {
>> unsigned ctrl;
>> unsigned pwr_down_mode;
>> bool pwr_down;
>> +
>> + union {
>> + __be32 d32;
>> + u8 d8[4];
>> + } data[3] ____cacheline_aligned;
>> };
>>
>> /**
>> @@ -104,48 +109,39 @@ enum ad5791_supported_device_ids {
>> ID_AD5791,
>> };
>>
>> -static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
>> +static int ad5791_spi_write(struct ad5791_state *st, u8 addr, u32 val)
>> {
>> - union {
>> - __be32 d32;
>> - u8 d8[4];
>> - } data;
>> -
>> - data.d32 = cpu_to_be32(AD5791_CMD_WRITE |
>> + st->data[0].d32 = cpu_to_be32(AD5791_CMD_WRITE |
>> AD5791_ADDR(addr) |
>> (val & AD5791_DAC_MASK));
>>
>> - return spi_write(spi, &data.d8[1], 3);
>> + return spi_write(st->spi, &st->data[0].d8[1], 3);
>> }
>>
>> -static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
>> +static int ad5791_spi_read(struct ad5791_state *st, u8 addr, u32 *val)
>> {
>> - union {
>> - __be32 d32;
>> - u8 d8[4];
>> - } data[3];
>> int ret;
>> struct spi_transfer xfers[] = {
>> {
>> - .tx_buf = &data[0].d8[1],
>> + .tx_buf = &st->data[0].d8[1],
>> .bits_per_word = 8,
>> .len = 3,
>> .cs_change = 1,
>> }, {
>> - .tx_buf = &data[1].d8[1],
>> - .rx_buf = &data[2].d8[1],
>> + .tx_buf = &st->data[1].d8[1],
>> + .rx_buf = &st->data[2].d8[1],
>> .bits_per_word = 8,
>> .len = 3,
>> },
>> };
>>
>> - data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
>> + st->data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
>> AD5791_ADDR(addr));
>> - data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
>> + st->data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
>>
>> - ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers));
>> + ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
>>
>> - *val = be32_to_cpu(data[2].d32);
>> + *val = be32_to_cpu(st->data[2].d32);
>>
>> return ret;
>> }
>> @@ -210,7 +206,7 @@ static ssize_t ad5791_write_dac_powerdown(struct iio_dev *indio_dev,
>> }
>> st->pwr_down = pwr_down;
>>
>> - ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl);
>> + ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl);
>>
>> return ret ? ret : len;
>> }
>> @@ -263,7 +259,7 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
>>
>> switch (m) {
>> case IIO_CHAN_INFO_RAW:
>> - ret = ad5791_spi_read(st->spi, chan->address, val);
>> + ret = ad5791_spi_read(st, chan->address, val);
>> if (ret)
>> return ret;
>> *val &= AD5791_DAC_MASK;
>> @@ -330,7 +326,7 @@ static int ad5791_write_raw(struct iio_dev *indio_dev,
>> val &= AD5791_RES_MASK(chan->scan_type.realbits);
>> val <<= chan->scan_type.shift;
>>
>> - return ad5791_spi_write(st->spi, chan->address, val);
>> + return ad5791_spi_write(st, chan->address, val);
>>
>> default:
>> return -EINVAL;
>> @@ -393,7 +389,7 @@ static int ad5791_probe(struct spi_device *spi)
>> dev_warn(&spi->dev, "reference voltage unspecified\n");
>> }
>>
>> - ret = ad5791_spi_write(spi, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
>> + ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
>> if (ret)
>> goto error_disable_reg_neg;
>>
>> @@ -405,7 +401,7 @@ static int ad5791_probe(struct spi_device *spi)
>> | ((pdata && pdata->use_rbuf_gain2) ? 0 : AD5791_CTRL_RBUF) |
>> AD5791_CTRL_BIN2SC;
>>
>> - ret = ad5791_spi_write(spi, AD5791_ADDR_CTRL, st->ctrl |
>> + ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl |
>> AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
>> if (ret)
>> goto error_disable_reg_neg;
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 07/15] iio:ad5791: Do not store transfer buffers on the stack
2013-12-22 17:36 ` Jonathan Cameron
@ 2013-12-22 17:40 ` Lars-Peter Clausen
2013-12-22 17:43 ` Jonathan Cameron
0 siblings, 1 reply; 38+ messages in thread
From: Lars-Peter Clausen @ 2013-12-22 17:40 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio
On 12/22/2013 06:36 PM, Jonathan Cameron wrote:
> On 11/30/13 11:09, Jonathan Cameron wrote:
>> On 11/25/13 12:41, Lars-Peter Clausen wrote:
>>> Some SPI controllers may not be able to handle transfer buffers that are placed
>>> on the stack.
>>>
>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>> Applied to the togreg branch of iio.git
>>
>> Thanks
>
> I really didn't review this series well enough. This should probably have
> gone in as a fix rather that through the togreg branch as should the other sp
> driver. Bit late now though given the size of the patch.
>
> Sorry it has taken me so long to do a pull request to Greg. I always
> get a bit lazy on the stuff for next as can always do it tomorrow!
>
> Slipped rather long this time though!
I think most SPI driver simply don't care as they don't do any DMA. So as long
as there is a board with a DMA SPI controller + this chip combination that is
in active use I don't think the patch needs to go into fixes.
>
> Jonathan
>
>>> ---
>>> drivers/iio/dac/ad5791.c | 46 +++++++++++++++++++++-------------------------
>>> 1 file changed, 21 insertions(+), 25 deletions(-)
>>>
>>> diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
>>> index 1e7f4cd..79bf199 100644
>>> --- a/drivers/iio/dac/ad5791.c
>>> +++ b/drivers/iio/dac/ad5791.c
>>> @@ -91,6 +91,11 @@ struct ad5791_state {
>>> unsigned ctrl;
>>> unsigned pwr_down_mode;
>>> bool pwr_down;
>>> +
>>> + union {
>>> + __be32 d32;
>>> + u8 d8[4];
>>> + } data[3] ____cacheline_aligned;
>>> };
>>>
>>> /**
>>> @@ -104,48 +109,39 @@ enum ad5791_supported_device_ids {
>>> ID_AD5791,
>>> };
>>>
>>> -static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
>>> +static int ad5791_spi_write(struct ad5791_state *st, u8 addr, u32 val)
>>> {
>>> - union {
>>> - __be32 d32;
>>> - u8 d8[4];
>>> - } data;
>>> -
>>> - data.d32 = cpu_to_be32(AD5791_CMD_WRITE |
>>> + st->data[0].d32 = cpu_to_be32(AD5791_CMD_WRITE |
>>> AD5791_ADDR(addr) |
>>> (val & AD5791_DAC_MASK));
>>>
>>> - return spi_write(spi, &data.d8[1], 3);
>>> + return spi_write(st->spi, &st->data[0].d8[1], 3);
>>> }
>>>
>>> -static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
>>> +static int ad5791_spi_read(struct ad5791_state *st, u8 addr, u32 *val)
>>> {
>>> - union {
>>> - __be32 d32;
>>> - u8 d8[4];
>>> - } data[3];
>>> int ret;
>>> struct spi_transfer xfers[] = {
>>> {
>>> - .tx_buf = &data[0].d8[1],
>>> + .tx_buf = &st->data[0].d8[1],
>>> .bits_per_word = 8,
>>> .len = 3,
>>> .cs_change = 1,
>>> }, {
>>> - .tx_buf = &data[1].d8[1],
>>> - .rx_buf = &data[2].d8[1],
>>> + .tx_buf = &st->data[1].d8[1],
>>> + .rx_buf = &st->data[2].d8[1],
>>> .bits_per_word = 8,
>>> .len = 3,
>>> },
>>> };
>>>
>>> - data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
>>> + st->data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
>>> AD5791_ADDR(addr));
>>> - data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
>>> + st->data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
>>>
>>> - ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers));
>>> + ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
>>>
>>> - *val = be32_to_cpu(data[2].d32);
>>> + *val = be32_to_cpu(st->data[2].d32);
>>>
>>> return ret;
>>> }
>>> @@ -210,7 +206,7 @@ static ssize_t ad5791_write_dac_powerdown(struct iio_dev *indio_dev,
>>> }
>>> st->pwr_down = pwr_down;
>>>
>>> - ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl);
>>> + ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl);
>>>
>>> return ret ? ret : len;
>>> }
>>> @@ -263,7 +259,7 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
>>>
>>> switch (m) {
>>> case IIO_CHAN_INFO_RAW:
>>> - ret = ad5791_spi_read(st->spi, chan->address, val);
>>> + ret = ad5791_spi_read(st, chan->address, val);
>>> if (ret)
>>> return ret;
>>> *val &= AD5791_DAC_MASK;
>>> @@ -330,7 +326,7 @@ static int ad5791_write_raw(struct iio_dev *indio_dev,
>>> val &= AD5791_RES_MASK(chan->scan_type.realbits);
>>> val <<= chan->scan_type.shift;
>>>
>>> - return ad5791_spi_write(st->spi, chan->address, val);
>>> + return ad5791_spi_write(st, chan->address, val);
>>>
>>> default:
>>> return -EINVAL;
>>> @@ -393,7 +389,7 @@ static int ad5791_probe(struct spi_device *spi)
>>> dev_warn(&spi->dev, "reference voltage unspecified\n");
>>> }
>>>
>>> - ret = ad5791_spi_write(spi, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
>>> + ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
>>> if (ret)
>>> goto error_disable_reg_neg;
>>>
>>> @@ -405,7 +401,7 @@ static int ad5791_probe(struct spi_device *spi)
>>> | ((pdata && pdata->use_rbuf_gain2) ? 0 : AD5791_CTRL_RBUF) |
>>> AD5791_CTRL_BIN2SC;
>>>
>>> - ret = ad5791_spi_write(spi, AD5791_ADDR_CTRL, st->ctrl |
>>> + ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl |
>>> AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
>>> if (ret)
>>> goto error_disable_reg_neg;
>>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 07/15] iio:ad5791: Do not store transfer buffers on the stack
2013-12-22 17:40 ` Lars-Peter Clausen
@ 2013-12-22 17:43 ` Jonathan Cameron
0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2013-12-22 17:43 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: linux-iio
On 12/22/13 17:40, Lars-Peter Clausen wrote:
> On 12/22/2013 06:36 PM, Jonathan Cameron wrote:
>> On 11/30/13 11:09, Jonathan Cameron wrote:
>>> On 11/25/13 12:41, Lars-Peter Clausen wrote:
>>>> Some SPI controllers may not be able to handle transfer buffers that are placed
>>>> on the stack.
>>>>
>>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>>> Applied to the togreg branch of iio.git
>>>
>>> Thanks
>>
>> I really didn't review this series well enough. This should probably have
>> gone in as a fix rather that through the togreg branch as should the other sp
>> driver. Bit late now though given the size of the patch.
>>
>> Sorry it has taken me so long to do a pull request to Greg. I always
>> get a bit lazy on the stuff for next as can always do it tomorrow!
>>
>> Slipped rather long this time though!
>
> I think most SPI driver simply don't care as they don't do any DMA. So as long as there is a board with a DMA SPI
> controller + this chip combination that is in active use I don't think the patch needs to go into fixes.
Not vital, but generally I'd got for fixes for this sort of thing, because it's entirely plausible
someone will base there tree off an old mainline with patches adding dma support to their driver.
Never mind though ;)
>
>>
>> Jonathan
>>
>>>> ---
>>>> drivers/iio/dac/ad5791.c | 46 +++++++++++++++++++++-------------------------
>>>> 1 file changed, 21 insertions(+), 25 deletions(-)
>>>>
>>>> diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
>>>> index 1e7f4cd..79bf199 100644
>>>> --- a/drivers/iio/dac/ad5791.c
>>>> +++ b/drivers/iio/dac/ad5791.c
>>>> @@ -91,6 +91,11 @@ struct ad5791_state {
>>>> unsigned ctrl;
>>>> unsigned pwr_down_mode;
>>>> bool pwr_down;
>>>> +
>>>> + union {
>>>> + __be32 d32;
>>>> + u8 d8[4];
>>>> + } data[3] ____cacheline_aligned;
>>>> };
>>>>
>>>> /**
>>>> @@ -104,48 +109,39 @@ enum ad5791_supported_device_ids {
>>>> ID_AD5791,
>>>> };
>>>>
>>>> -static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
>>>> +static int ad5791_spi_write(struct ad5791_state *st, u8 addr, u32 val)
>>>> {
>>>> - union {
>>>> - __be32 d32;
>>>> - u8 d8[4];
>>>> - } data;
>>>> -
>>>> - data.d32 = cpu_to_be32(AD5791_CMD_WRITE |
>>>> + st->data[0].d32 = cpu_to_be32(AD5791_CMD_WRITE |
>>>> AD5791_ADDR(addr) |
>>>> (val & AD5791_DAC_MASK));
>>>>
>>>> - return spi_write(spi, &data.d8[1], 3);
>>>> + return spi_write(st->spi, &st->data[0].d8[1], 3);
>>>> }
>>>>
>>>> -static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
>>>> +static int ad5791_spi_read(struct ad5791_state *st, u8 addr, u32 *val)
>>>> {
>>>> - union {
>>>> - __be32 d32;
>>>> - u8 d8[4];
>>>> - } data[3];
>>>> int ret;
>>>> struct spi_transfer xfers[] = {
>>>> {
>>>> - .tx_buf = &data[0].d8[1],
>>>> + .tx_buf = &st->data[0].d8[1],
>>>> .bits_per_word = 8,
>>>> .len = 3,
>>>> .cs_change = 1,
>>>> }, {
>>>> - .tx_buf = &data[1].d8[1],
>>>> - .rx_buf = &data[2].d8[1],
>>>> + .tx_buf = &st->data[1].d8[1],
>>>> + .rx_buf = &st->data[2].d8[1],
>>>> .bits_per_word = 8,
>>>> .len = 3,
>>>> },
>>>> };
>>>>
>>>> - data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
>>>> + st->data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
>>>> AD5791_ADDR(addr));
>>>> - data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
>>>> + st->data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
>>>>
>>>> - ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers));
>>>> + ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers));
>>>>
>>>> - *val = be32_to_cpu(data[2].d32);
>>>> + *val = be32_to_cpu(st->data[2].d32);
>>>>
>>>> return ret;
>>>> }
>>>> @@ -210,7 +206,7 @@ static ssize_t ad5791_write_dac_powerdown(struct iio_dev *indio_dev,
>>>> }
>>>> st->pwr_down = pwr_down;
>>>>
>>>> - ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl);
>>>> + ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl);
>>>>
>>>> return ret ? ret : len;
>>>> }
>>>> @@ -263,7 +259,7 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,
>>>>
>>>> switch (m) {
>>>> case IIO_CHAN_INFO_RAW:
>>>> - ret = ad5791_spi_read(st->spi, chan->address, val);
>>>> + ret = ad5791_spi_read(st, chan->address, val);
>>>> if (ret)
>>>> return ret;
>>>> *val &= AD5791_DAC_MASK;
>>>> @@ -330,7 +326,7 @@ static int ad5791_write_raw(struct iio_dev *indio_dev,
>>>> val &= AD5791_RES_MASK(chan->scan_type.realbits);
>>>> val <<= chan->scan_type.shift;
>>>>
>>>> - return ad5791_spi_write(st->spi, chan->address, val);
>>>> + return ad5791_spi_write(st, chan->address, val);
>>>>
>>>> default:
>>>> return -EINVAL;
>>>> @@ -393,7 +389,7 @@ static int ad5791_probe(struct spi_device *spi)
>>>> dev_warn(&spi->dev, "reference voltage unspecified\n");
>>>> }
>>>>
>>>> - ret = ad5791_spi_write(spi, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
>>>> + ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
>>>> if (ret)
>>>> goto error_disable_reg_neg;
>>>>
>>>> @@ -405,7 +401,7 @@ static int ad5791_probe(struct spi_device *spi)
>>>> | ((pdata && pdata->use_rbuf_gain2) ? 0 : AD5791_CTRL_RBUF) |
>>>> AD5791_CTRL_BIN2SC;
>>>>
>>>> - ret = ad5791_spi_write(spi, AD5791_ADDR_CTRL, st->ctrl |
>>>> + ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl |
>>>> AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
>>>> if (ret)
>>>> goto error_disable_reg_neg;
>>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 38+ messages in thread
end of thread, other threads:[~2013-12-22 17:43 UTC | newest]
Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-25 12:41 [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Lars-Peter Clausen
2013-11-25 12:41 ` [PATCH 02/15] iio:ad5504: Do not store transfer buffers on the stack Lars-Peter Clausen
2013-11-30 11:07 ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 03/15] iio:ad5421: Mark transfer buffer as __be32 Lars-Peter Clausen
2013-11-30 11:07 ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 04/15] iio:ad5686: " Lars-Peter Clausen
2013-11-30 11:07 ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 05/15] iio:ad5755: " Lars-Peter Clausen
2013-11-30 11:08 ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 06/15] iio:ad5791: Mark transfer buffers " Lars-Peter Clausen
2013-11-30 11:08 ` Jonathan Cameron
2013-11-25 12:41 ` [PATCH 07/15] iio:ad5791: Do not store transfer buffers on the stack Lars-Peter Clausen
2013-11-30 11:09 ` Jonathan Cameron
2013-12-22 17:36 ` Jonathan Cameron
2013-12-22 17:40 ` Lars-Peter Clausen
2013-12-22 17:43 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 08/15] iio:ad7266: Mark transfer buffer as __be16 Lars-Peter Clausen
2013-11-30 11:10 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 09/15] iio:vcnl4000: " Lars-Peter Clausen
2013-11-30 11:11 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 10/15] staging:iio:ad7280a: Mark transfer buffer as __be32 Lars-Peter Clausen
2013-11-30 11:12 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 11/15] staging:iio:ad7280a: Do not store transfer buffer on the stack Lars-Peter Clausen
2013-11-30 11:12 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 12/15] staging:iio:ad7746: Mark transfer buffer as __be32 Lars-Peter Clausen
2013-11-30 11:13 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 13/15] staging:iio:ad7746: Do not store the transfer buffer on the stack Lars-Peter Clausen
2013-11-30 11:13 ` Jonathan Cameron
2013-12-22 17:22 ` Jonathan Cameron
2013-11-25 12:42 ` [PATCH 14/15] staging:iio:ad9832: Mark transfer buffers as __be16 Lars-Peter Clausen
2013-11-30 11:14 ` Jonathan Cameron
2013-12-03 10:27 ` Lars-Peter Clausen
2013-12-03 14:56 ` Jonathan Cameron
2013-12-03 20:09 ` Jonathan Cameron
2013-12-03 20:11 ` Lars-Peter Clausen
2013-11-25 12:42 ` [PATCH 15/15] staging:iio:ad9834: Mark transfer buffers as __b16 Lars-Peter Clausen
2013-11-30 11:14 ` Jonathan Cameron
2013-11-30 11:03 ` [PATCH 01/15] iio:ad5504: Mark transfer buffers as __be16 Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).