[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9296eddbaaa4f815978ce9433c7970a3a498d85b.1520956563.git.rodrigosiqueiramelo@gmail.com>
Date: Tue, 13 Mar 2018 13:05:48 -0300
From: Rodrigo Siqueira <rodrigosiqueiramelo@...il.com>
To: Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
Jonathan Cameron <jic23@...nel.org>,
Hartmut Knaack <knaack.h@....de>,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Graff Yang <graff.yang@...il.com>
Cc: daniel.baluta@....com, linux-iio@...r.kernel.org,
devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2 2/3] staging:iio:ad2s1210: Add frequency handler in
read_raw
Read data from fclkin and fexcit does not utilize the ad2s1210_read_raw
function. This patch, append the required handler in the
ad2s1210_read_raw to return the correct value. Also, this patch removes
the legacy code related to the read function
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@...il.com>
---
drivers/staging/iio/resolver/ad2s1210.c | 45 +++++++++++++++------------------
1 file changed, 20 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index 28c3fd439663..27a42ed10fcd 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -210,15 +210,6 @@ static inline int ad2s1210_soft_reset(struct ad2s1210_state *st)
return ad2s1210_config_write(st, 0x0);
}
-static ssize_t ad2s1210_show_fclkin(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
-
- return sprintf(buf, "%u\n", st->fclkin);
-}
-
static ssize_t ad2s1210_store_fclkin(struct device *dev,
struct device_attribute *attr,
const char *buf,
@@ -249,15 +240,6 @@ static ssize_t ad2s1210_store_fclkin(struct device *dev,
return ret < 0 ? ret : len;
}
-static ssize_t ad2s1210_show_fexcit(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
-
- return sprintf(buf, "%u\n", st->fexcit);
-}
-
static ssize_t ad2s1210_store_fexcit(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
@@ -486,7 +468,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val,
int *val2,
- long m)
+ long mask)
{
struct ad2s1210_state *st = iio_priv(indio_dev);
u16 negative;
@@ -535,23 +517,36 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev,
*val = vel;
ret = IIO_VAL_INT;
break;
+ case IIO_CHAN_INFO_FREQUENCY:
+ ret = IIO_VAL_INT;
+ switch (chan->channel) {
+ case FCLKIN:
+ *val = st->fclkin;
+ goto unlock_mutex;
+ case FEXCIT:
+ *val = st->fexcit;
+ goto unlock_mutex;
+ default:
+ ret = -EINVAL;
+ goto unlock_mutex;
+ }
+ break;
default:
- mutex_unlock(&st->lock);
- return -EINVAL;
+ ret = -EINVAL;
+ goto unlock_mutex;
}
error_ret:
gpio_set_value(st->pdata->sample, 1);
/* delay (2 * tck + 20) nano seconds */
udelay(1);
+unlock_mutex:
mutex_unlock(&st->lock);
return ret;
}
-static IIO_DEVICE_ATTR(fclkin, 0644,
- ad2s1210_show_fclkin, ad2s1210_store_fclkin, 0);
-static IIO_DEVICE_ATTR(fexcit, 0644,
- ad2s1210_show_fexcit, ad2s1210_store_fexcit, 0);
+static IIO_DEVICE_ATTR(fclkin, 0644, NULL, ad2s1210_store_fclkin, 0);
+static IIO_DEVICE_ATTR(fexcit, 0644, NULL, ad2s1210_store_fexcit, 0);
static IIO_DEVICE_ATTR(control, 0644,
ad2s1210_show_control, ad2s1210_store_control, 0);
static IIO_DEVICE_ATTR(bits, 0644,
--
2.16.2
Powered by blists - more mailing lists