linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Gwendal Grignou <gwendal@chromium.org>
Cc: jic23@kernel.org, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, chrome-platform@lists.linux.dev
Subject: Re: [PATCH] drivers: iio: cros_ec_sensors: Flush changing the FIFO timeout
Date: Wed, 2 Apr 2025 09:29:57 +0000	[thread overview]
Message-ID: <Z-0DleD6CRIsz3mY@google.com> (raw)
In-Reply-To: <20250331164832.4039379-1-gwendal@chromium.org>

On Mon, Mar 31, 2025 at 09:48:32AM -0700, Gwendal Grignou wrote:
> fifo_timeout is used by the EC firmware only when a new sample is
> available.

I guess you mean: "FIFO timeout".  There is no specific symbol called
`fifo_timeout`.

> ---

"drivers: " in the patch's title prefix can be dropped.

> -static int cros_ec_sensor_set_ec_rate(struct cros_ec_sensors_core_state *st,
> -				      int rate)
> -{
> -	int ret;
> -
> -	if (rate > U16_MAX)
> -		rate = U16_MAX;
> -
> -	mutex_lock(&st->cmd_lock);
> -	st->param.cmd = MOTIONSENSE_CMD_EC_RATE;
> -	st->param.ec_rate.data = rate;
> -	ret = cros_ec_motion_send_host_cmd(st, 0);
> -	mutex_unlock(&st->cmd_lock);
> -	return ret;
> -}
> -
>  static ssize_t cros_ec_sensor_set_report_latency(struct device *dev,
>  						 struct device_attribute *attr,
>  						 const char *buf, size_t len)
> @@ -134,7 +118,25 @@ static ssize_t cros_ec_sensor_set_report_latency(struct device *dev,
>  
>  	/* EC rate is in ms. */
>  	latency = integer * 1000 + fract / 1000;
> -	ret = cros_ec_sensor_set_ec_rate(st, latency);
> +
> +	mutex_lock(&st->cmd_lock);
> +	st->param.cmd = MOTIONSENSE_CMD_EC_RATE;
> +	st->param.ec_rate.data = min(U16_MAX, latency);
> +	ret = cros_ec_motion_send_host_cmd(st, 0);
> +	mutex_unlock(&st->cmd_lock);
> +	if (ret < 0)
> +		return ret;

It isn't obvious (at least irrelevant to the commit message) that
cros_ec_sensor_set_ec_rate() becomes inline here.

> @@ -152,7 +154,6 @@ static ssize_t cros_ec_sensor_get_report_latency(struct device *dev,
>  	mutex_lock(&st->cmd_lock);
>  	st->param.cmd = MOTIONSENSE_CMD_EC_RATE;
>  	st->param.ec_rate.data = EC_MOTION_SENSE_NO_VALUE;
> -
>  	ret = cros_ec_motion_send_host_cmd(st, 0);
>  	latency = st->resp->ec_rate.ret;
>  	mutex_unlock(&st->cmd_lock);

Unwanted change.

> @@ -853,6 +858,16 @@ int cros_ec_sensors_core_write(struct cros_ec_sensors_core_state *st,
>  		st->param.sensor_odr.roundup = 1;
>  
>  		ret = cros_ec_motion_send_host_cmd(st, 0);
> +
> +		/* Flush the FIFO in case we are stopping a sensor.
> +		 * If the FIFO has just been emptied, pending samples will be
> +		 * stuck until new samples are available. It will not happen
> +		 * when all the sensors are stopped.
> +		 */
> +		if (frequency == 0) {
> +			st->param.cmd = MOTIONSENSE_CMD_FIFO_FLUSH;
> +			cros_ec_motion_send_host_cmd(st, 0);

Wouldn't it want to check `ret` from previous cros_ec_motion_send_host_cmd()
and override `ret` by the latest call?

  reply	other threads:[~2025-04-02  9:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31 16:48 [PATCH] drivers: iio: cros_ec_sensors: Flush changing the FIFO timeout Gwendal Grignou
2025-04-02  9:29 ` Tzung-Bi Shih [this message]
2025-04-08  5:50   ` Gwendal Grignou
2025-04-08  5:54     ` [PATCH v2] iio: cros_ec_sensors: Flush when " Gwendal Grignou
2025-04-08  7:59       ` Tzung-Bi Shih
2025-04-08 15:56         ` Gwendal Grignou
2025-04-08 15:56     ` [PATCH v3] " Gwendal Grignou
2025-04-09  1:19       ` Tzung-Bi Shih
2025-04-12 10:42       ` Jonathan Cameron
2025-04-23 22:05         ` Gwendal Grignou
  -- strict thread matches above, loose matches on Subject: below --
2025-06-23 18:48 [PATCH] drivers: iio: cros_ec_sensors: Flush " Gwendal Grignou
2025-06-23 18:51 ` Gwendal Grignou

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=Z-0DleD6CRIsz3mY@google.com \
    --to=tzungbi@kernel.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=devicetree@vger.kernel.org \
    --cc=gwendal@chromium.org \
    --cc=jic23@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).