Commit 9308bc9a authored by Michael Hennerich's avatar Michael Hennerich Committed by Greg Kroah-Hartman

staging:iio:meter:ade7758: Fix list and set of available sample frequencies.

Fix list of available sample frequencies.
Fix ade7758_write_frequency().
Signed-off-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Acked-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent fb7f6cca
...@@ -533,7 +533,6 @@ static ssize_t ade7758_write_frequency(struct device *dev, ...@@ -533,7 +533,6 @@ static ssize_t ade7758_write_frequency(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev); struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct ade7758_state *st = iio_dev_get_devdata(indio_dev);
unsigned long val; unsigned long val;
int ret; int ret;
u8 reg, t; u8 reg, t;
...@@ -544,14 +543,23 @@ static ssize_t ade7758_write_frequency(struct device *dev, ...@@ -544,14 +543,23 @@ static ssize_t ade7758_write_frequency(struct device *dev,
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
t = (26040 / val); switch (val) {
if (t > 0) case 26040:
t >>= 1; t = 0;
break;
if (t > 1) case 13020:
st->us->max_speed_hz = ADE7758_SPI_SLOW; t = 1;
else break;
st->us->max_speed_hz = ADE7758_SPI_FAST; case 6510:
t = 2;
break;
case 3255:
t = 3;
break;
default:
ret = -EINVAL;
goto out;
}
ret = ade7758_spi_read_reg_8(dev, ret = ade7758_spi_read_reg_8(dev,
ADE7758_WAVMODE, ADE7758_WAVMODE,
...@@ -671,7 +679,7 @@ static IIO_DEV_ATTR_WAVEFORM_TYPE(S_IWUSR | S_IRUGO, ...@@ -671,7 +679,7 @@ static IIO_DEV_ATTR_WAVEFORM_TYPE(S_IWUSR | S_IRUGO,
static IIO_DEV_ATTR_RESET(ade7758_write_reset); static IIO_DEV_ATTR_RESET(ade7758_write_reset);
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26000 13000 65000 33000"); static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26040 13020 6510 3255");
static struct attribute *ade7758_attributes[] = { static struct attribute *ade7758_attributes[] = {
&iio_dev_attr_temp_raw.dev_attr.attr, &iio_dev_attr_temp_raw.dev_attr.attr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment