From: Hartmut Knaack <knaack.h@gmx.de>
To: Jonathan Cameron <jic23@kernel.org>, linux-iio@vger.kernel.org
Cc: kristina.martsenko@gmail.com, Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [PATCH 4/7] iio: gyro: adis16136 switch sampling frequency attr to core support.
Date: Sun, 29 Jun 2014 15:58:33 +0200 [thread overview]
Message-ID: <53B01B89.7080402@gmx.de> (raw)
In-Reply-To: <1403467186-26639-5-git-send-email-jic23@kernel.org>
Jonathan Cameron schrieb:
> By using the info_mask_shared_by_all element of the channel spec, acce
Same here: "access". More comments inline.
> to the sampling frequency becomes available to in kernel users of the
> driver. It also shortens and simplifies the code.
>
> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
> ---
> drivers/iio/gyro/adis16136.c | 58 ++++++--------------------------------------
> 1 file changed, 8 insertions(+), 50 deletions(-)
>
> diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c
> index 591bd55..4ed96d0 100644
> --- a/drivers/iio/gyro/adis16136.c
> +++ b/drivers/iio/gyro/adis16136.c
> @@ -197,45 +197,6 @@ static int adis16136_get_freq(struct adis16136 *adis16136, unsigned int *freq)
> return 0;
> }
>
> -static ssize_t adis16136_write_frequency(struct device *dev,
> - struct device_attribute *attr, const char *buf, size_t len)
> -{
> - struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> - struct adis16136 *adis16136 = iio_priv(indio_dev);
> - unsigned int val;
> - int ret;
> -
> - ret = kstrtouint(buf, 10, &val);
> - if (ret)
> - return ret;
> -
> - if (val == 0)
> - return -EINVAL;
> -
> - ret = adis16136_set_freq(adis16136, val);
> -
> - return ret ? ret : len;
> -}
> -
> -static ssize_t adis16136_read_frequency(struct device *dev,
> - struct device_attribute *attr, char *buf)
> -{
> - struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> - struct adis16136 *adis16136 = iio_priv(indio_dev);
> - unsigned int freq;
> - int ret;
> -
> - ret = adis16136_get_freq(adis16136, &freq);
> - if (ret < 0)
> - return ret;
> -
> - return sprintf(buf, "%d\n", freq);
> -}
> -
> -static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
> - adis16136_read_frequency,
> - adis16136_write_frequency);
> -
> static const unsigned adis16136_3db_divisors[] = {
> [0] = 2, /* Special case */
> [1] = 6,
> @@ -324,6 +285,8 @@ static int adis16136_read_raw(struct iio_dev *indio_dev,
> return IIO_VAL_INT;
> case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> return adis16136_get_filter(indio_dev, val);
> + case IIO_CHAN_INFO_SAMP_FREQ:
> + return adis16136_get_freq(adis16136, val);
This needs some error-handling and return IIO_VAL_INT.
> default:
> return -EINVAL;
> }
> @@ -340,6 +303,10 @@ static int adis16136_write_raw(struct iio_dev *indio_dev,
> ADIS16136_REG_GYRO_OFF2, val);
> case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> return adis16136_set_filter(indio_dev, val);
> + case IIO_CHAN_INFO_SAMP_FREQ:
> + if (val <= 0 || val2 != 0)
> + return -EINVAL;
> + return adis16136_set_freq(adis16136, val);
> default:
> break;
> }
> @@ -361,7 +328,7 @@ static const struct iio_chan_spec adis16136_channels[] = {
> BIT(IIO_CHAN_INFO_CALIBBIAS) |
> BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
> -
> + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> .address = ADIS16136_REG_GYRO_OUT2,
> .scan_index = ADIS16136_SCAN_GYRO,
> .scan_type = {
> @@ -376,6 +343,7 @@ static const struct iio_chan_spec adis16136_channels[] = {
> .channel = 0,
> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> BIT(IIO_CHAN_INFO_SCALE),
> + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
> .address = ADIS16136_REG_TEMP_OUT,
> .scan_index = ADIS16136_SCAN_TEMP,
> .scan_type = {
> @@ -388,18 +356,8 @@ static const struct iio_chan_spec adis16136_channels[] = {
> IIO_CHAN_SOFT_TIMESTAMP(2),
> };
>
> -static struct attribute *adis16136_attributes[] = {
> - &iio_dev_attr_sampling_frequency.dev_attr.attr,
> - NULL
> -};
> -
> -static const struct attribute_group adis16136_attribute_group = {
> - .attrs = adis16136_attributes,
> -};
> -
> static const struct iio_info adis16136_info = {
> .driver_module = THIS_MODULE,
> - .attrs = &adis16136_attribute_group,
> .read_raw = &adis16136_read_raw,
> .write_raw = &adis16136_write_raw,
> .update_scan_mode = adis_update_scan_mode,
next prev parent reply other threads:[~2014-06-29 13:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-22 19:59 [PATCH 0/7] Move more drivers to using samp_freq element of info_mask Jonathan Cameron
2014-06-22 19:59 ` [PATCH 1/7] iio:st sensors: remove custom sampling frequence attribute in favour of core support Jonathan Cameron
2014-06-29 11:27 ` Hartmut Knaack
2014-07-07 9:04 ` Jonathan Cameron
2014-06-22 19:59 ` [PATCH 2/7] iio: gyro: itg3200 switch sampling frequency attr to " Jonathan Cameron
2014-06-29 12:04 ` Hartmut Knaack
2014-07-07 9:04 ` Jonathan Cameron
2014-06-22 19:59 ` [PATCH 3/7] iio: imu: mpu6050 " Jonathan Cameron
2014-06-29 12:53 ` Hartmut Knaack
2014-06-22 19:59 ` [PATCH 4/7] iio: gyro: adis16136 " Jonathan Cameron
2014-06-29 13:58 ` Hartmut Knaack [this message]
2014-06-22 19:59 ` [PATCH 5/7] iio: adis: Switch " Jonathan Cameron
2014-06-29 15:27 ` Hartmut Knaack
2014-06-30 8:48 ` Lars-Peter Clausen
2014-07-07 9:03 ` Jonathan Cameron
2014-06-22 19:59 ` [PATCH 6/7] iio: imu: adis16400 switch " Jonathan Cameron
2014-06-29 15:36 ` Hartmut Knaack
2014-06-30 8:14 ` Lars-Peter Clausen
2014-07-07 9:03 ` Jonathan Cameron
2014-06-22 19:59 ` [PATCH 7/7] iio: imu: adis16480 " Jonathan Cameron
2014-06-29 15:46 ` Hartmut Knaack
2014-06-30 8:13 ` Lars-Peter Clausen
2014-07-07 9:02 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53B01B89.7080402@gmx.de \
--to=knaack.h@gmx.de \
--cc=jic23@kernel.org \
--cc=kristina.martsenko@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.