All of lore.kernel.org
 help / color / mirror / Atom feed
From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: Gwendal Grignou <gwendal@chromium.org>,
	bleung@chromium.org, Jonathan.Cameron@huawei.com
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 01/11] platform: chrome: sensorhub: Add FIFO support
Date: Wed, 25 Mar 2020 17:28:05 +0100	[thread overview]
Message-ID: <399a282a-e6a6-a1ed-26c4-1999008f242d@collabora.com> (raw)
In-Reply-To: <20200324202736.243314-2-gwendal@chromium.org>

Hi Gwendal,

Many thanks for sending this series upstream. Just one comment, other than that
looks good to me.

On 24/3/20 21:27, Gwendal Grignou wrote:
> cros_ec_sensorhub registers a listener and query motion sense FIFO,
> spread to iio sensors registers.
> 
> To test, we can use libiio:
> iiod&
> iio_readdev -u ip:localhost -T 10000 -s 25 -b 16 cros-ec-gyro | od -x
> 
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>

[snip]

> +/**
> + * cros_ec_sensorhub_ring_handler() - The trigger handler function
> + *
> + * @sensorhub: Sensor Hub object.
> + *
> + * Called by the notifier, process the EC sensor FIFO queue.
> + */
> +static void cros_ec_sensorhub_ring_handler(struct cros_ec_sensorhub *sensorhub)
> +{
> +	struct cros_ec_fifo_info *fifo_info = &sensorhub->fifo_info;
> +	struct cros_ec_dev *ec = sensorhub->ec;
> +	ktime_t fifo_timestamp, current_timestamp;
> +	int i, j, number_data, ret;
> +	unsigned long sensor_mask = 0;
> +	struct ec_response_motion_sensor_data *in;
> +	struct cros_ec_sensors_ring_sample *out, *last_out;
> +
> +	mutex_lock(&sensorhub->cmd_lock);
> +
> +	/* Get FIFO information if there are lost vectors. */
> +	if (fifo_info->info.total_lost) {
> +		/* Need to retrieve the number of lost vectors per sensor */
> +		sensorhub->params->cmd = MOTIONSENSE_CMD_FIFO_INFO;
> +		sensorhub->msg->outsize = 1;
> +		sensorhub->msg->insize =
> +			sizeof(struct ec_response_motion_sense_fifo_info) +
> +			sizeof(u16) * CROS_EC_SENSOR_MAX;
> +
> +		if (cros_ec_cmd_xfer_status(ec->ec_dev, sensorhub->msg) < 0)
> +			goto error;
> +
> +		memcpy(fifo_info, &sensorhub->resp->fifo_info,
> +		       sizeof(*fifo_info));
> +

Smatch is reporting:

cros_ec_sensorhub_ring_handler() error: memcpy() '&sensorhub->resp->fifo_info'
too small (10 vs 42)

Is it fine and safe to copy always the 42 bytes? I suspect that we should only
copy the number of lost events, total_lost , not always the maximum (16). Or the
EC is always sending the full array (16 bytes)?

Thanks,
Enric


  reply	other threads:[~2020-03-25 16: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 [this message]
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 ` [PATCH v6 11/11] iio: cros_ec: flush as hwfifo attribute Gwendal Grignou
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=399a282a-e6a6-a1ed-26c4-1999008f242d@collabora.com \
    --to=enric.balletbo@collabora.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=bleung@chromium.org \
    --cc=gwendal@chromium.org \
    --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.