From: Jonathan Cameron <jic23@kernel.org>
To: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Cc: kernel@collabora.com, Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 7/8] iio: common: cros_ec_sensors: add sysfs attribute for frequencies
Date: Sat, 22 Jun 2019 11:18:27 +0100 [thread overview]
Message-ID: <20190622111827.54ebe9a9@archlinux> (raw)
In-Reply-To: <ee20a9b8d1700a3987570d2edd28fe9ac9e73123.1560848479.git.fabien.lahoudere@collabora.com>
On Tue, 18 Jun 2019 11:06:38 +0200
Fabien Lahoudere <fabien.lahoudere@collabora.com> wrote:
> Embedded controller return minimum and maximum frequencies, unfortunately
> we have no way to know the step for all available frequencies.
> Even if not complete, we can return a list of known values using the
> standard read_avail callback (IIO_CHAN_INFO_SAMP_FREQ) to provide them to
> userland.
>
> Now cros_ec_* sensors provides frequencies values in sysfs like this:
> "0 min max".
>
> 0 is always true to disable the sensor.
Hmm. 0 frequency feels like a kind of non standard use of the ABI.
I suppose it's fairly logical and it does no harm if userspace never uses
it so I guess we can let this use in without updating the docs.
I'd like some feedback from the chromeos side on whether this is a sensible
way of representing things? Note that generic userspace will only pick
one of those values, it won't magically decide to go for somewhere inbetween.
Jonathan
>
> Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
> ---
> .../cros_ec_sensors/cros_ec_sensors_core.c | 22 +++++++++++++++++++
> .../linux/iio/common/cros_ec_sensors_core.h | 4 +++-
> 2 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> index 2ce077b576a4..8df82b675752 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> @@ -10,6 +10,7 @@
> #include <linux/iio/buffer.h>
> #include <linux/iio/common/cros_ec_sensors_core.h>
> #include <linux/iio/iio.h>
> +#include <linux/iio/sysfs.h>
> #include <linux/iio/kfifo_buf.h>
> #include <linux/iio/trigger_consumer.h>
> #include <linux/iio/triggered_buffer.h>
> @@ -86,6 +87,26 @@ static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev,
> return ret;
> }
>
> +static int cros_ec_read_avail(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + const int **vals,
> + int *type,
> + int *length,
> + long mask)
> +{
> + struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_SAMP_FREQ:
> + *length = 3;
> + *vals = (const int *)&state->frequency_range;
> + *type = IIO_VAL_INT;
> + return IIO_AVAIL_LIST;
> + }
> +
> + return -EINVAL;
> +}
> +
> int cros_ec_sensors_core_init(struct platform_device *pdev,
> int num_channels,
> bool physical_device)
> @@ -161,6 +182,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
> }
> }
>
> + state->info.read_avail = cros_ec_read_avail;
> indio_dev->info = &state->info;
>
> /* Timestamp channel */
> diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
> index 89937ad242ef..5fa9ba5332e0 100644
> --- a/include/linux/iio/common/cros_ec_sensors_core.h
> +++ b/include/linux/iio/common/cros_ec_sensors_core.h
> @@ -140,7 +140,9 @@ int cros_ec_sensors_core_register(struct platform_device *pdev,
> channel[idx].scan_type.shift = 0;\
> channel[idx].scan_index = idx;\
> channel[idx].ext_info = cros_ec_sensors_ext_info;\
> - channel[idx].scan_type.sign = 'u';
> + channel[idx].scan_type.sign = 'u';\
> + channel[idx].info_mask_shared_by_all_available = \
> + BIT(IIO_CHAN_INFO_SAMP_FREQ);
>
> /**
> * cros_ec_motion_send_host_cmd() - send motion sense host command
next prev parent reply other threads:[~2019-06-22 10:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-18 9:06 [PATCH v3 0/8] Expose cros_ec_sensors frequency range via iio sysfs Fabien Lahoudere
2019-06-18 9:06 ` [PATCH v3 1/8] iio: common: cros_ec_sensors: move iio_info management to core Fabien Lahoudere
2019-06-18 9:06 ` [PATCH v3 2/8] iio: common: cros_ec_sensors: move channels to core structure Fabien Lahoudere
2019-06-22 10:07 ` Jonathan Cameron
2019-06-18 9:06 ` [PATCH v3 3/8] iio: common: cros_ec_sensors: move registration to core Fabien Lahoudere
2019-06-22 10:13 ` Jonathan Cameron
2019-06-22 10:24 ` Jonathan Cameron
2019-06-18 9:06 ` [PATCH v3 4/8] iio: common: cros_ec_sensors: clean code Fabien Lahoudere
2019-06-18 9:06 ` [PATCH v3 5/8] iio: common: cros_ec_sensors: use core structure Fabien Lahoudere
2019-06-22 10:24 ` Jonathan Cameron
2019-06-18 9:06 ` [PATCH v3 6/8] iio: common: cros_ec_sensors: support protocol v3 message Fabien Lahoudere
2019-06-22 10:15 ` Jonathan Cameron
2019-06-25 17:04 ` Enric Balletbo i Serra
2019-06-27 13:31 ` Fabien Lahoudere
2019-06-18 9:06 ` [PATCH v3 7/8] iio: common: cros_ec_sensors: add sysfs attribute for frequencies Fabien Lahoudere
2019-06-22 10:18 ` Jonathan Cameron [this message]
2019-06-18 9:06 ` [PATCH v3 8/8] docs: iio: add precision about sampling_frequency_available Fabien Lahoudere
2019-06-22 10:21 ` Jonathan Cameron
2019-07-09 9:43 ` Fabien Lahoudere
2019-06-19 12:24 ` [PATCH v3 0/8] Expose cros_ec_sensors frequency range via iio sysfs Fabien Lahoudere
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=20190622111827.54ebe9a9@archlinux \
--to=jic23@kernel.org \
--cc=fabien.lahoudere@collabora.com \
--cc=kernel@collabora.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox