From 89ca79afe50e9e9608ad3315bf099fdbb82c4eb5 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sat, 6 Dec 2014 05:54:00 +0000 Subject: [PATCH] iio:adc:ad799x: Add helper function to read/write config register 16-bit on ad7997/ad7998, 8-bit elsewhere Signed-off-by: Peter Meerwald Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad799x.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index 92401c958ea2..fe2a9b1170b0 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -136,6 +136,30 @@ struct ad799x_state { unsigned int transfer_size; }; +static int ad799x_write_config(struct ad799x_state *st, u16 val) +{ + switch (st->id) { + case ad7997: + case ad7998: + return i2c_smbus_write_word_swapped(st->client, AD7998_CONF_REG, + val); + default: + return i2c_smbus_write_byte_data(st->client, AD7998_CONF_REG, + val); + } +} + +static int ad799x_read_config(struct ad799x_state *st) +{ + switch (st->id) { + case ad7997: + case ad7998: + return i2c_smbus_read_word_swapped(st->client, AD7998_CONF_REG); + default: + return i2c_smbus_read_byte_data(st->client, AD7998_CONF_REG); + } +} + /** * ad799x_trigger_handler() bh of trigger launched polling to ring buffer * -- 2.20.1