All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gwendal Grignou <gwendal@chromium.org>
To: bleung@chromium.org, enric.balletbo@collabora.com,
	Jonathan.Cameron@huawei.com
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Gwendal Grignou <gwendal@chromium.org>
Subject: [PATCH v6 11/11] iio: cros_ec: flush as hwfifo attribute
Date: Tue, 24 Mar 2020 13:27:36 -0700	[thread overview]
Message-ID: <20200324202736.243314-12-gwendal@chromium.org> (raw)
In-Reply-To: <20200324202736.243314-1-gwendal@chromium.org>

Add buffer/hwfifo_flush. It is not part of the ABI, but it follows ST
and HID lead: Tells the sensor hub to send to the host all pending
sensor events.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
New in v6.

 .../cros_ec_sensors/cros_ec_sensors_core.c    | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)

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 c831915ca7e56..aaf124a82e0e4 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
@@ -113,6 +113,33 @@ static int cros_ec_sensor_set_ec_rate(struct cros_ec_sensors_core_state *st,
 	return ret;
 }
 
+static ssize_t cros_ec_sensors_flush(struct device *dev,
+				     struct device_attribute *attr,
+				     const char *buf, size_t len)
+{
+	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+	struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
+	int ret = 0;
+	bool flush;
+
+	ret = strtobool(buf, &flush);
+	if (ret < 0)
+		return ret;
+	if (!flush)
+		return -EINVAL;
+
+	mutex_lock(&st->cmd_lock);
+	st->param.cmd = MOTIONSENSE_CMD_FIFO_FLUSH;
+	ret = cros_ec_motion_send_host_cmd(st, 0);
+	if (ret != 0)
+		dev_warn(&indio_dev->dev, "Unable to flush sensor\n");
+	mutex_unlock(&st->cmd_lock);
+	return ret ? ret : len;
+}
+
+static IIO_DEVICE_ATTR(hwfifo_flush, 0644, NULL,
+		       cros_ec_sensors_flush, 0);
+
 static ssize_t cros_ec_sensor_set_report_latency(struct device *dev,
 						 struct device_attribute *attr,
 						 const char *buf, size_t len)
@@ -175,6 +202,7 @@ static ssize_t hwfifo_watermark_max_show(struct device *dev,
 static IIO_DEVICE_ATTR_RO(hwfifo_watermark_max, 0);
 
 const struct attribute *cros_ec_sensor_fifo_attributes[] = {
+	&iio_dev_attr_hwfifo_flush.dev_attr.attr,
 	&iio_dev_attr_hwfifo_timeout.dev_attr.attr,
 	&iio_dev_attr_hwfifo_watermark_max.dev_attr.attr,
 	NULL,
-- 
2.25.1.696.g5e7596f4ac-goog


  parent reply	other threads:[~2020-03-24 20:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 20:27 [PATCH v6 00/11] Cros EC sensor hub FIFO support Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 01/11] platform: chrome: sensorhub: Add " Gwendal Grignou
2020-03-25 16:28   ` Enric Balletbo i Serra
2020-03-26  8:56     ` Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 02/11] platform: chrome: sensorhub: Add code to spread timestmap Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 03/11] platform: chrome: sensorhub: Add median filter Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 04/11] iio: cros_ec: Move function description to .c file Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 05/11] iio: expose iio_device_set_clock Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 06/11] iio: cros_ec: Register to cros_ec_sensorhub when EC supports FIFO Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 07/11] iio: cros_ec: Remove pm function Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 08/11] iio: cros_ec: Expose hwfifo_timeout Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 09/11] iio: cros_ec: Report hwfifo_watermark_max Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 10/11] iio: cros_ec: Use Hertz as unit for sampling frequency Gwendal Grignou
2020-03-24 20:27 ` Gwendal Grignou [this message]
2020-03-25 15:59 ` [PATCH v6 00/11] Cros EC sensor hub FIFO support Andy Shevchenko

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=20200324202736.243314-12-gwendal@chromium.org \
    --to=gwendal@chromium.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=bleung@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@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.