staging:iio:ad799x: Remove unused ad799x_state fields
Subsystems (4)
PATCH 1/6 staging:iio:ad799x: Remove unused ad799x_state fields
Remove fields from the ad799x_state struct which are not used.
--- drivers/staging/iio/adc/ad799x.h | 2 -- 1 file changed, 2 deletions(-)
drivers/staging/iio/adc/ad799x.h +0 -2
@@ -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; };
Signature · 1 line
1.8.0
PATCH 2/6 staging:iio:ad799x: Remove internal reference support
None of the devices supported by this driver have an internal voltage reference, so remove support for it from the driver.
--- drivers/staging/iio/adc/ad799x.h | 2 -- drivers/staging/iio/adc/ad799x_core.c | 16 ++++------------ 2 files changed, 4 insertions(+), 14 deletions(-)
drivers/staging/iio/adc/ad799x.h +0 -2
@@ -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; };
drivers/staging/iio/adc/ad799x_core.c +4 -12
@@ -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)) {
Signature · 1 line
1.8.0
PATCH 3/6 staging:iio:ad799x: Use i2c_smbus_{read,write}_word_data_swapped
In reply to Lars-Peter ClausenUse i2c_smbus_{read,write}_word_data_swapped instead of open-coding it.
--- drivers/staging/iio/adc/ad799x_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad799x_core.c +3 -3
@@ -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" );
Signature · 1 line
1.8.0
PATCH 4/6 staging:iio:ad799x: Add helper macro for channel initialization
In reply to Lars-Peter ClausenThe 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.
--- drivers/staging/iio/adc/ad799x_core.c | 386 +++++----------------------------- 1 file changed, 56 insertions(+), 330 deletions(-)
drivers/staging/iio/adc/ad799x_core.c +56 -330
@@ -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,
Signature · 1 line
1.8.0
PATCH 5/6 staging:iio:ad799x: Set IIO_CHAN_INFO_SCALE mask
In reply to Lars-Peter ClausenThe 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.
--- drivers/staging/iio/adc/ad799x_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/iio/adc/ad799x_core.c +1 -0
@@ -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), \
Signature · 1 line
1.8.0
PATCH 6/6 staging:iio:ad799x: Preallocate sample buffer
In reply to Lars-Peter ClausenAvoid 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.
--- 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(-)
drivers/staging/iio/adc/ad799x.h +3 -0
@@ -106,6 +106,9 @@ struct ad799x_state {u16 int_vref_mv;unsigned id;u16 config; + +u8 *rx_buf; +unsigned int transfer_size; };/*
drivers/staging/iio/adc/ad799x_core.c +8 -0
@@ -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 ;
drivers/staging/iio/adc/ad799x_ring.c +4 -12
@@ -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);
Signature · 1 line
1.8.0
Jonathan Cameron
maintainerQuoted 3 lines · Lars-Peter Clausen
Remove fields from the
ad799x_statestruct which are not used.Signed-off-by Lars-Peter Clausen <[email protected]>
Whole series applied to togreg branch of iio.git
Quoted 21 lines
--- drivers/staging/iio/adc/ad799x.h | 2 -- 1 file changed, 2 deletions(-)drivers/staging/iio/adc/ad799x.h +0
-2@@ -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; };