lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <FR3P281MB1757A06D0F591758F066DB89CE6AA@FR3P281MB1757.DEUP281.PROD.OUTLOOK.COM>
Date: Tue, 10 Jun 2025 14:18:52 +0000
From: Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@....com>
To: Jonathan Cameron <jic23@...nel.org>
CC: Lars-Peter Clausen <lars@...afoo.de>,
        David Lechner
	<dlechner@...libre.com>,
        Nuno Sá <nuno.sa@...log.com>,
        Andy Shevchenko <andy@...nel.org>,
        "linux-iio@...r.kernel.org"
	<linux-iio@...r.kernel.org>,
        "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 1/2] iio: imu: inv_icm42600: add WoM support

Hello Jonathan,

sorry for the very late response, here are my answers.

Thanks,
JB

>________________________________________
>From: Jonathan Cameron <jic23@...nel.org>
>Sent: Monday, April 21, 2025 12:48
>To: Jean-Baptiste Maneyrol via B4 Relay <devnull+jean-baptiste.maneyrol.tdk.com@...nel.org>
>Cc: Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@....com>; Lars-Peter Clausen <lars@...afoo.de>; David Lechner <dlechner@...libre.com>; Nuno Sá <nuno.sa@...log.com>; Andy Shevchenko <andy@...nel.org>; linux-iio@...r.kernel.org <linux-iio@...r.kernel.org>; linux-kernel@...r.kernel.org <linux-kernel@...r.kernel.org>
>Subject: Re: [PATCH v3 1/2] iio: imu: inv_icm42600: add WoM support
> 
>This Message Is From an External Sender
>This message came from outside your organization.
> 
>On Fri, 18 Apr 2025 18:19:02 +0200
>Jean-Baptiste Maneyrol via B4 Relay <devnull+jean-baptiste.maneyrol.tdk.com@...nel.org> wrote:
>
>> From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@....com>
>> 
>> Add WoM as accel roc rising x|y|z event.
>> 
>> Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@....com>
>Hi Jean-Baptiste,
>
>One thing on mixing gotos and scoped_guard().  It might be fine but we've
>had weird issues with compilers and this stuff + the guidance in cleanup.h
>suggests not mixing the two approaches.
>
>Easy enough to sort out here with a helper function and I think the
>end result will both avoid that issue and be easier to read.
>
>Jonathan
>
>> ---
>>  drivers/iio/imu/inv_icm42600/inv_icm42600.h        |  54 +++-
>>  drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c  | 279 ++++++++++++++++++++-
>>  drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c |   2 +-
>>  drivers/iio/imu/inv_icm42600/inv_icm42600_core.c   |  58 +++++
>>  4 files changed, 385 insertions(+), 8 deletions(-)
>> 
>> diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600.h b/drivers/iio/imu/inv_icm42600/inv_icm42600.h
>> index f893dbe6996506a33eb5d3be47e6765a923665c9..bcf588a048836f909c26908f0677833303a94ef9 100644
>> --- a/drivers/iio/imu/inv_icm42600/inv_icm42600.h
>> +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600.h
>> @@ -135,6 +135,14 @@ struct inv_icm42600_suspended {
>>  	bool temp;
>>  };
>>  
>> +struct inv_icm42600_apex {
>> +	unsigned int on;
>> +	struct {
>> +		uint64_t value;
>> +		bool enable;
>> +	} wom;
>> +};
>> +
>>  /**
>>   *  struct inv_icm42600_state - driver state variables
>>   *  @lock:		lock for serializing multiple registers access.
>> @@ -148,9 +156,10 @@ struct inv_icm42600_suspended {
>>   *  @suspended:		suspended sensors configuration.
>>   *  @indio_gyro:	gyroscope IIO device.
>>   *  @indio_accel:	accelerometer IIO device.
>> - *  @buffer:		data transfer buffer aligned for DMA.
>> - *  @fifo:		FIFO management structure.
>>   *  @timestamp:		interrupt timestamps.
>> + *  @apex:		APEX features management.
>
>Maybe give a little more info on what APEX is somewhere?

No problem, it stands for Advanced Pedometer and Event detection. It is a small
compute core that runs algo like pedometer, gestures, ...

>
>
>
>> +static int inv_icm42600_accel_enable_wom(struct iio_dev *indio_dev)
>> +{
>> +	struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev);
>> +	struct inv_icm42600_sensor_state *accel_st = iio_priv(indio_dev);
>> +	struct device *pdev = regmap_get_device(st->map);
>> +	struct inv_icm42600_sensor_conf conf = INV_ICM42600_SENSOR_CONF_INIT;
>> +	unsigned int sleep_ms = 0;
>> +	int ret;
>> +
>> +	ret = pm_runtime_resume_and_get(pdev);
>> +	if (ret)
>> +		return ret;
>> +
>> +	scoped_guard(mutex, &st->lock) {
>> +		/* turn on accel sensor */
>> +		conf.mode = accel_st->power_mode;
>> +		conf.filter = accel_st->filter;
>> +		ret = inv_icm42600_set_accel_conf(st, &conf, &sleep_ms);
>> +		if (ret)
>> +			goto error_suspend;
>
>As below.  Compilers are not great at the more complex scope vs goto stuff.
>This one may be fine buf in general we avoid it.

Will fix it.

>
>> +	}
>> +
>> +	if (sleep_ms)
>> +		msleep(sleep_ms);
>> +
>> +	scoped_guard(mutex, &st->lock) {
>> +		ret = inv_icm42600_enable_wom(st);
>> +		if (ret)
>> +			goto error_suspend;
>
>This doesn't follow the guidance in cleanup.h about never mixing gotos and
>scoped cleanup. Two options here, either factor out everthing after the
>pm handling and have

Will change it.

>	ret = pm_runtime_resume_and_get(pdev);
>	if (ret)
>		return ret;
>
>	ret = __inv_icm62600_accel_enabled_wom();
>	if (ret) {
>		pm_runtime_mark_last_busy(pdev);
>		pm_runtime_put_autosuspend(pdev)'
>		return ret;
>	}
>
>	return 0;
>
>The rest of the cases are fine.
>
>> +		st->apex.on++;
>> +		st->apex.wom.enable = true;
>> +	}
>> +
>> +	return 0;
>> +
>> +error_suspend:
>> +	pm_runtime_mark_last_busy(pdev);
>> +	pm_runtime_put_autosuspend(pdev);
>> +	return ret;
>> +}
>
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ