* [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields
@ 2013-03-26 18:42 Lars-Peter Clausen
2013-03-26 18:43 ` [PATCH 2/6] staging:iio:ad799x: Remove internal reference support Lars-Peter Clausen
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Lars-Peter Clausen @ 2013-03-26 18:42 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Remove fields from the ad799x_state struct which are not used.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/adc/ad799x.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h
index 3e363c4..9f50f93 100644
--- a/drivers/staging/iio/adc/ad799x.h
+++ b/drivers/staging/iio/adc/ad799x.h
@@ -104,11 +104,9 @@ struct ad799x_chip_info {
struct ad799x_state {
struct i2c_client *client;
const struct ad799x_chip_info *chip_info;
- struct iio_trigger *trig;
struct regulator *reg;
u16 int_vref_mv;
unsigned id;
- char *name;
u16 config;
};
--
1.8.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/6] staging:iio:ad799x: Remove internal reference support 2013-03-26 18:42 [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields Lars-Peter Clausen @ 2013-03-26 18:43 ` Lars-Peter Clausen 2013-03-26 18:43 ` [PATCH 3/6] staging:iio:ad799x: Use i2c_smbus_{read,write}_word_data_swapped Lars-Peter Clausen ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: Lars-Peter Clausen @ 2013-03-26 18:43 UTC (permalink / raw) To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen None of the devices supported by this driver have an internal voltage reference, so remove support for it from the driver. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> --- drivers/staging/iio/adc/ad799x.h | 2 -- drivers/staging/iio/adc/ad799x_core.c | 16 ++++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h index 9f50f93..82e83bb 100644 --- a/drivers/staging/iio/adc/ad799x.h +++ b/drivers/staging/iio/adc/ad799x.h @@ -87,7 +87,6 @@ struct ad799x_state; * struct ad799x_chip_info - chip specifc information * @channel: channel specification * @num_channels: number of channels - * @int_vref_mv: the internal reference voltage * @monitor_mode: whether the chip supports monitor interrupts * @default_config: device default configuration * @event_attrs: pointer to the monitor event attribute group @@ -96,7 +95,6 @@ struct ad799x_state; struct ad799x_chip_info { struct iio_chan_spec channel[9]; int num_channels; - u16 int_vref_mv; u16 default_config; const struct iio_info *info; }; diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 40cc89a..d12a4b2 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -498,7 +498,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [4] = IIO_CHAN_SOFT_TIMESTAMP(4), }, .num_channels = 5, - .int_vref_mv = 4096, .info = &ad7991_info, }, [ad7995] = { @@ -538,7 +537,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [4] = IIO_CHAN_SOFT_TIMESTAMP(4), }, .num_channels = 5, - .int_vref_mv = 1024, .info = &ad7991_info, }, [ad7999] = { @@ -578,7 +576,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [4] = IIO_CHAN_SOFT_TIMESTAMP(4), }, .num_channels = 5, - .int_vref_mv = 1024, .info = &ad7991_info, }, [ad7992] = { @@ -604,7 +601,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [2] = IIO_CHAN_SOFT_TIMESTAMP(2), }, .num_channels = 3, - .int_vref_mv = 4096, .default_config = AD7998_ALERT_EN, .info = &ad7992_info, }, @@ -649,7 +645,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [4] = IIO_CHAN_SOFT_TIMESTAMP(4), }, .num_channels = 5, - .int_vref_mv = 1024, .default_config = AD7998_ALERT_EN, .info = &ad7993_4_7_8_info, }, @@ -694,7 +689,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [4] = IIO_CHAN_SOFT_TIMESTAMP(4), }, .num_channels = 5, - .int_vref_mv = 4096, .default_config = AD7998_ALERT_EN, .info = &ad7993_4_7_8_info, }, @@ -771,7 +765,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [8] = IIO_CHAN_SOFT_TIMESTAMP(8), }, .num_channels = 9, - .int_vref_mv = 1024, .default_config = AD7998_ALERT_EN, .info = &ad7993_4_7_8_info, }, @@ -848,7 +841,6 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [8] = IIO_CHAN_SOFT_TIMESTAMP(8), }, .num_channels = 9, - .int_vref_mv = 4096, .default_config = AD7998_ALERT_EN, .info = &ad7993_4_7_8_info, }, @@ -875,10 +867,10 @@ static int ad799x_probe(struct i2c_client *client, /* TODO: Add pdata options for filtering and bit delay */ - if (pdata) - st->int_vref_mv = pdata->vref_mv; - else - st->int_vref_mv = st->chip_info->int_vref_mv; + if (!pdata) + return -EINVAL; + + st->int_vref_mv = pdata->vref_mv; st->reg = regulator_get(&client->dev, "vcc"); if (!IS_ERR(st->reg)) { -- 1.8.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] staging:iio:ad799x: Use i2c_smbus_{read,write}_word_data_swapped 2013-03-26 18:42 [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields Lars-Peter Clausen 2013-03-26 18:43 ` [PATCH 2/6] staging:iio:ad799x: Remove internal reference support Lars-Peter Clausen @ 2013-03-26 18:43 ` Lars-Peter Clausen 2013-03-26 18:43 ` [PATCH 4/6] staging:iio:ad799x: Add helper macro for channel initialization Lars-Peter Clausen ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: Lars-Peter Clausen @ 2013-03-26 18:43 UTC (permalink / raw) To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen Use i2c_smbus_{read,write}_word_data_swapped instead of open-coding it. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> --- drivers/staging/iio/adc/ad799x_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index d12a4b2..8d2012c 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -48,13 +48,13 @@ static int ad799x_i2c_read16(struct ad799x_state *st, u8 reg, u16 *data) struct i2c_client *client = st->client; int ret = 0; - ret = i2c_smbus_read_word_data(client, reg); + ret = i2c_smbus_read_word_swapped(client, reg); if (ret < 0) { dev_err(&client->dev, "I2C read error\n"); return ret; } - *data = swab16((u16)ret); + *data = (u16)ret; return 0; } @@ -80,7 +80,7 @@ static int ad799x_i2c_write16(struct ad799x_state *st, u8 reg, u16 data) struct i2c_client *client = st->client; int ret = 0; - ret = i2c_smbus_write_word_data(client, reg, swab16(data)); + ret = i2c_smbus_write_word_swapped(client, reg, data); if (ret < 0) dev_err(&client->dev, "I2C write error\n"); -- 1.8.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] staging:iio:ad799x: Add helper macro for channel initialization 2013-03-26 18:42 [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields Lars-Peter Clausen 2013-03-26 18:43 ` [PATCH 2/6] staging:iio:ad799x: Remove internal reference support Lars-Peter Clausen 2013-03-26 18:43 ` [PATCH 3/6] staging:iio:ad799x: Use i2c_smbus_{read,write}_word_data_swapped Lars-Peter Clausen @ 2013-03-26 18:43 ` Lars-Peter Clausen 2013-03-26 18:43 ` [PATCH 5/6] staging:iio:ad799x: Set IIO_CHAN_INFO_SCALE mask Lars-Peter Clausen ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: Lars-Peter Clausen @ 2013-03-26 18:43 UTC (permalink / raw) To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen The ad779x channels all follow the same pattern. Add a helper macro to initialize the channel spec, this allows us to drop quite a few lines. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> --- drivers/staging/iio/adc/ad799x_core.c | 386 +++++----------------------------- 1 file changed, 56 insertions(+), 330 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 8d2012c..49972e1 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -460,145 +460,55 @@ static const struct iio_info ad7993_4_7_8_info = { #define AD799X_EV_MASK (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \ IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)) +#define AD799X_CHANNEL(_index, _realbits, _evmask) { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .channel = (_index), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .scan_index = (_index), \ + .scan_type = IIO_ST('u', _realbits, 16, 12 - (_realbits)), \ + .event_mask = (_evmask), \ +} + static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { [ad7991] = { .channel = { - [0] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 0, - .scan_type = IIO_ST('u', 12, 16, 0), - }, - [1] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 1, - .scan_type = IIO_ST('u', 12, 16, 0), - }, - [2] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 2, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 2, - .scan_type = IIO_ST('u', 12, 16, 0), - }, - [3] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 3, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 3, - .scan_type = IIO_ST('u', 12, 16, 0), - }, - [4] = IIO_CHAN_SOFT_TIMESTAMP(4), + AD799X_CHANNEL(0, 12, 0), + AD799X_CHANNEL(1, 12, 0), + AD799X_CHANNEL(2, 12, 0), + AD799X_CHANNEL(3, 12, 0), + IIO_CHAN_SOFT_TIMESTAMP(4), }, .num_channels = 5, .info = &ad7991_info, }, [ad7995] = { .channel = { - [0] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 0, - .scan_type = IIO_ST('u', 10, 16, 2), - }, - [1] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 1, - .scan_type = IIO_ST('u', 10, 16, 2), - }, - [2] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 2, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 2, - .scan_type = IIO_ST('u', 10, 16, 2), - }, - [3] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 3, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 3, - .scan_type = IIO_ST('u', 10, 16, 2), - }, - [4] = IIO_CHAN_SOFT_TIMESTAMP(4), + AD799X_CHANNEL(0, 10, 0), + AD799X_CHANNEL(1, 10, 0), + AD799X_CHANNEL(2, 10, 0), + AD799X_CHANNEL(3, 10, 0), + IIO_CHAN_SOFT_TIMESTAMP(4), }, .num_channels = 5, .info = &ad7991_info, }, [ad7999] = { .channel = { - [0] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 0, - .scan_type = IIO_ST('u', 8, 16, 4), - }, - [1] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 1, - .scan_type = IIO_ST('u', 8, 16, 4), - }, - [2] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 2, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 2, - .scan_type = IIO_ST('u', 8, 16, 4), - }, - [3] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 3, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 3, - .scan_type = IIO_ST('u', 8, 16, 4), - }, - [4] = IIO_CHAN_SOFT_TIMESTAMP(4), + AD799X_CHANNEL(0, 8, 0), + AD799X_CHANNEL(1, 8, 0), + AD799X_CHANNEL(2, 8, 0), + AD799X_CHANNEL(3, 8, 0), + IIO_CHAN_SOFT_TIMESTAMP(4), }, .num_channels = 5, .info = &ad7991_info, }, [ad7992] = { .channel = { - [0] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 0, - .scan_type = IIO_ST('u', 12, 16, 0), - .event_mask = AD799X_EV_MASK, - }, - [1] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 1, - .scan_type = IIO_ST('u', 12, 16, 0), - .event_mask = AD799X_EV_MASK, - }, - [2] = IIO_CHAN_SOFT_TIMESTAMP(2), + AD799X_CHANNEL(0, 12, AD799X_EV_MASK), + AD799X_CHANNEL(1, 12, AD799X_EV_MASK), + IIO_CHAN_SOFT_TIMESTAMP(3), }, .num_channels = 3, .default_config = AD7998_ALERT_EN, @@ -606,43 +516,11 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { }, [ad7993] = { .channel = { - [0] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 0, - .scan_type = IIO_ST('u', 10, 16, 2), - .event_mask = AD799X_EV_MASK, - }, - [1] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .scan_index = 1, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_type = IIO_ST('u', 10, 16, 2), - .event_mask = AD799X_EV_MASK, - }, - [2] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 2, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 2, - .scan_type = IIO_ST('u', 10, 16, 2), - .event_mask = AD799X_EV_MASK, - }, - [3] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 3, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 3, - .scan_type = IIO_ST('u', 10, 16, 2), - .event_mask = AD799X_EV_MASK, - }, - [4] = IIO_CHAN_SOFT_TIMESTAMP(4), + AD799X_CHANNEL(0, 10, AD799X_EV_MASK), + AD799X_CHANNEL(1, 10, AD799X_EV_MASK), + AD799X_CHANNEL(2, 10, AD799X_EV_MASK), + AD799X_CHANNEL(3, 10, AD799X_EV_MASK), + IIO_CHAN_SOFT_TIMESTAMP(4), }, .num_channels = 5, .default_config = AD7998_ALERT_EN, @@ -650,43 +528,11 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { }, [ad7994] = { .channel = { - [0] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 0, - .scan_type = IIO_ST('u', 12, 16, 0), - .event_mask = AD799X_EV_MASK, - }, - [1] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 1, - .scan_type = IIO_ST('u', 12, 16, 0), - .event_mask = AD799X_EV_MASK, - }, - [2] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 2, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 2, - .scan_type = IIO_ST('u', 12, 16, 0), - .event_mask = AD799X_EV_MASK, - }, - [3] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 3, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 3, - .scan_type = IIO_ST('u', 12, 16, 0), - .event_mask = AD799X_EV_MASK, - }, - [4] = IIO_CHAN_SOFT_TIMESTAMP(4), + AD799X_CHANNEL(0, 12, AD799X_EV_MASK), + AD799X_CHANNEL(1, 12, AD799X_EV_MASK), + AD799X_CHANNEL(2, 12, AD799X_EV_MASK), + AD799X_CHANNEL(3, 12, AD799X_EV_MASK), + IIO_CHAN_SOFT_TIMESTAMP(4), }, .num_channels = 5, .default_config = AD7998_ALERT_EN, @@ -694,75 +540,15 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { }, [ad7997] = { .channel = { - [0] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 0, - .scan_type = IIO_ST('u', 10, 16, 2), - .event_mask = AD799X_EV_MASK, - }, - [1] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 1, - .scan_type = IIO_ST('u', 10, 16, 2), - .event_mask = AD799X_EV_MASK, - }, - [2] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 2, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 2, - .scan_type = IIO_ST('u', 10, 16, 2), - .event_mask = AD799X_EV_MASK, - }, - [3] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 3, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 3, - .scan_type = IIO_ST('u', 10, 16, 2), - .event_mask = AD799X_EV_MASK, - }, - [4] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 4, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 4, - .scan_type = IIO_ST('u', 10, 16, 2), - }, - [5] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 5, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 5, - .scan_type = IIO_ST('u', 10, 16, 2), - }, - [6] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 6, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 6, - .scan_type = IIO_ST('u', 10, 16, 2), - }, - [7] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 7, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 7, - .scan_type = IIO_ST('u', 10, 16, 2), - }, - [8] = IIO_CHAN_SOFT_TIMESTAMP(8), + AD799X_CHANNEL(0, 10, AD799X_EV_MASK), + AD799X_CHANNEL(1, 10, AD799X_EV_MASK), + AD799X_CHANNEL(2, 10, AD799X_EV_MASK), + AD799X_CHANNEL(3, 10, AD799X_EV_MASK), + AD799X_CHANNEL(4, 10, 0), + AD799X_CHANNEL(5, 10, 0), + AD799X_CHANNEL(6, 10, 0), + AD799X_CHANNEL(7, 10, 0), + IIO_CHAN_SOFT_TIMESTAMP(8), }, .num_channels = 9, .default_config = AD7998_ALERT_EN, @@ -770,75 +556,15 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { }, [ad7998] = { .channel = { - [0] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 0, - .scan_type = IIO_ST('u', 12, 16, 0), - .event_mask = AD799X_EV_MASK, - }, - [1] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 1, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 1, - .scan_type = IIO_ST('u', 12, 16, 0), - .event_mask = AD799X_EV_MASK, - }, - [2] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 2, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 2, - .scan_type = IIO_ST('u', 12, 16, 0), - .event_mask = AD799X_EV_MASK, - }, - [3] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 3, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 3, - .scan_type = IIO_ST('u', 12, 16, 0), - .event_mask = AD799X_EV_MASK, - }, - [4] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 4, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 4, - .scan_type = IIO_ST('u', 12, 16, 0), - }, - [5] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 5, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 5, - .scan_type = IIO_ST('u', 12, 16, 0), - }, - [6] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 6, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 6, - .scan_type = IIO_ST('u', 12, 16, 0), - }, - [7] = { - .type = IIO_VOLTAGE, - .indexed = 1, - .channel = 7, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), - .scan_index = 7, - .scan_type = IIO_ST('u', 12, 16, 0), - }, - [8] = IIO_CHAN_SOFT_TIMESTAMP(8), + AD799X_CHANNEL(0, 12, AD799X_EV_MASK), + AD799X_CHANNEL(1, 12, AD799X_EV_MASK), + AD799X_CHANNEL(2, 12, AD799X_EV_MASK), + AD799X_CHANNEL(3, 12, AD799X_EV_MASK), + AD799X_CHANNEL(4, 12, 0), + AD799X_CHANNEL(5, 12, 0), + AD799X_CHANNEL(6, 12, 0), + AD799X_CHANNEL(7, 12, 0), + IIO_CHAN_SOFT_TIMESTAMP(8), }, .num_channels = 9, .default_config = AD7998_ALERT_EN, -- 1.8.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] staging:iio:ad799x: Set IIO_CHAN_INFO_SCALE mask 2013-03-26 18:42 [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields Lars-Peter Clausen ` (2 preceding siblings ...) 2013-03-26 18:43 ` [PATCH 4/6] staging:iio:ad799x: Add helper macro for channel initialization Lars-Peter Clausen @ 2013-03-26 18:43 ` Lars-Peter Clausen 2013-03-26 18:43 ` [PATCH 6/6] staging:iio:ad799x: Preallocate sample buffer Lars-Peter Clausen 2013-03-29 9:22 ` [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields Jonathan Cameron 5 siblings, 0 replies; 7+ messages in thread From: Lars-Peter Clausen @ 2013-03-26 18:43 UTC (permalink / raw) To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen The driver has support for reporting a channels scale, but none of the channels set the IIO_CHAN_INFO_SCALE mask. Add the IIO_CHAN_INFO_SCALE to all channels to indicate that the drivers supports reporting the scale. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> --- drivers/staging/iio/adc/ad799x_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 49972e1..b751055 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -465,6 +465,7 @@ static const struct iio_info ad7993_4_7_8_info = { .indexed = 1, \ .channel = (_index), \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ .scan_index = (_index), \ .scan_type = IIO_ST('u', _realbits, 16, 12 - (_realbits)), \ .event_mask = (_evmask), \ -- 1.8.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] staging:iio:ad799x: Preallocate sample buffer 2013-03-26 18:42 [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields Lars-Peter Clausen ` (3 preceding siblings ...) 2013-03-26 18:43 ` [PATCH 5/6] staging:iio:ad799x: Set IIO_CHAN_INFO_SCALE mask Lars-Peter Clausen @ 2013-03-26 18:43 ` Lars-Peter Clausen 2013-03-29 9:22 ` [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields Jonathan Cameron 5 siblings, 0 replies; 7+ messages in thread From: Lars-Peter Clausen @ 2013-03-26 18:43 UTC (permalink / raw) To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen Avoid allocating and freeing the sample buffer for each transfer. Instead allocate it once when we start sampling. Also pre-compute the number of bytes we need to transfer in the same way. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> --- drivers/staging/iio/adc/ad799x.h | 3 +++ drivers/staging/iio/adc/ad799x_core.c | 8 ++++++++ drivers/staging/iio/adc/ad799x_ring.c | 16 ++++------------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h index 82e83bb..b51680c 100644 --- a/drivers/staging/iio/adc/ad799x.h +++ b/drivers/staging/iio/adc/ad799x.h @@ -106,6 +106,9 @@ struct ad799x_state { u16 int_vref_mv; unsigned id; u16 config; + + u8 *rx_buf; + unsigned int transfer_size; }; /* diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index b751055..8dc97b3 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -104,6 +104,13 @@ static int ad7997_8_update_scan_mode(struct iio_dev *indio_dev, { struct ad799x_state *st = iio_priv(indio_dev); + kfree(st->rx_buf); + st->rx_buf = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); + if (!st->rx_buf) + return -ENOMEM; + + st->transfer_size = bitmap_weight(scan_mask, indio_dev->masklength) * 2; + switch (st->id) { case ad7997: case ad7998: @@ -665,6 +672,7 @@ static int ad799x_remove(struct i2c_client *client) regulator_disable(st->reg); regulator_put(st->reg); } + kfree(st->rx_buf); iio_device_free(indio_dev); return 0; diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c index 2c5f384..c2ebae1 100644 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ b/drivers/staging/iio/adc/ad799x_ring.c @@ -36,14 +36,9 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p) struct iio_dev *indio_dev = pf->indio_dev; struct ad799x_state *st = iio_priv(indio_dev); s64 time_ns; - __u8 *rxbuf; int b_sent; u8 cmd; - rxbuf = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); - if (rxbuf == NULL) - goto out; - switch (st->id) { case ad7991: case ad7995: @@ -66,20 +61,17 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p) } b_sent = i2c_smbus_read_i2c_block_data(st->client, - cmd, bitmap_weight(indio_dev->active_scan_mask, - indio_dev->masklength) * 2, rxbuf); + cmd, st->transfer_size, st->rx_buf); if (b_sent < 0) - goto done; + goto out; time_ns = iio_get_time_ns(); if (indio_dev->scan_timestamp) - memcpy(rxbuf + indio_dev->scan_bytes - sizeof(s64), + memcpy(st->rx_buf + indio_dev->scan_bytes - sizeof(s64), &time_ns, sizeof(time_ns)); - iio_push_to_buffers(indio_dev, rxbuf); -done: - kfree(rxbuf); + iio_push_to_buffers(indio_dev, st->rx_buf); out: iio_trigger_notify_done(indio_dev->trig); -- 1.8.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields 2013-03-26 18:42 [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields Lars-Peter Clausen ` (4 preceding siblings ...) 2013-03-26 18:43 ` [PATCH 6/6] staging:iio:ad799x: Preallocate sample buffer Lars-Peter Clausen @ 2013-03-29 9:22 ` Jonathan Cameron 5 siblings, 0 replies; 7+ messages in thread From: Jonathan Cameron @ 2013-03-29 9:22 UTC (permalink / raw) To: Lars-Peter Clausen; +Cc: linux-iio On 03/26/2013 06:42 PM, Lars-Peter Clausen wrote: > Remove fields from the ad799x_state struct which are not used. > > Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Whole series applied to togreg branch of iio.git > --- > drivers/staging/iio/adc/ad799x.h | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h > index 3e363c4..9f50f93 100644 > --- a/drivers/staging/iio/adc/ad799x.h > +++ b/drivers/staging/iio/adc/ad799x.h > @@ -104,11 +104,9 @@ struct ad799x_chip_info { > struct ad799x_state { > struct i2c_client *client; > const struct ad799x_chip_info *chip_info; > - struct iio_trigger *trig; > struct regulator *reg; > u16 int_vref_mv; > unsigned id; > - char *name; > u16 config; > }; > > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-03-29 9:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-26 18:42 [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields Lars-Peter Clausen
2013-03-26 18:43 ` [PATCH 2/6] staging:iio:ad799x: Remove internal reference support Lars-Peter Clausen
2013-03-26 18:43 ` [PATCH 3/6] staging:iio:ad799x: Use i2c_smbus_{read,write}_word_data_swapped Lars-Peter Clausen
2013-03-26 18:43 ` [PATCH 4/6] staging:iio:ad799x: Add helper macro for channel initialization Lars-Peter Clausen
2013-03-26 18:43 ` [PATCH 5/6] staging:iio:ad799x: Set IIO_CHAN_INFO_SCALE mask Lars-Peter Clausen
2013-03-26 18:43 ` [PATCH 6/6] staging:iio:ad799x: Preallocate sample buffer Lars-Peter Clausen
2013-03-29 9:22 ` [PATCH 1/6] staging:iio:ad799x: Remove unused ad799x_state fields Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox