mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>
To: Julia Lawall <julia.lawall@inria.fr>,
	Dan Carpenter <dan.carpenter@linaro.org>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 2/3] iio: imu: inv_icm42600: add WoM support
Date: Fri, 27 Jun 2025 15:32:04 +0000	[thread overview]
Message-ID: <FR3P281MB17577DF9326C6CC893711EC2CE45A@FR3P281MB1757.DEUP281.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2506262240440.3473@hadrien>

>
>
>________________________________________
>From: Julia Lawall <julia.lawall@inria.fr>
>Sent: Thursday, June 26, 2025 22:41
>To: Dan Carpenter <dan.carpenter@linaro.org>
>Cc: Jonathan Cameron <jic23@kernel.org>; David Lechner <dlechner@baylibre.com>; Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>; Lars-Peter Clausen <lars@metafoo.de>; Nuno Sá <nuno.sa@analog.com>; Andy Shevchenko <andy@kernel.org>; linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>
>Subject: Re: [PATCH v5 2/3] iio: imu: inv_icm42600: add WoM support
> 
>This Message Is From an External Sender
>This message came from outside your organization.
> 
>On Thu, 26 Jun 2025, Dan Carpenter wrote:
>
>> On Thu, Jun 26, 2025 at 07:53:23PM +0100, Jonathan Cameron wrote:
>> > > > +static int inv_icm42600_accel_disable_wom(struct iio_dev *indio_dev)
>> > > > +{
>> > > > +       struct inv_icm42600_state *st = iio_device_get_drvdata(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;
>> > > > +
>> > > > +       scoped_guard(mutex, &st->lock) {
>> > > > +               /*
>> > > > +                * Consider that turning off WoM is always working to avoid
>> > > > +                * blocking the chip in on mode and prevent going back to sleep.
>> > > > +                * If there is an error, the chip will anyway go back to sleep
>> > > > +                * and the feature will not work anymore.
>> > > > +                */
>> > > > +               st->apex.wom.enable = false;
>> > > > +               st->apex.on--;
>> > > > +               ret = inv_icm42600_disable_wom(st);
>> > > > +               if (ret)
>> > > > +                       break;
>> > >
>> > > The fact that scoped_guard() uses a for loop is an implementation
>> > > detail so using break here makes this look like improper C code. I
>> > > think this would be better to split out the protected section to a
>> > > separate function and just use the regular guard() macro.
>> >
>> > Good catch.  This feels like something we should have some static analysis
>> > around as we definitely don't want code assuming that implementation.
>> >
>> > +CC Dan / Julia to see if they agree.
>> >
>>
>> I feel like the scoped_guard() macro is so complicated because they
>> wanted break statements to work as expected...  (As opposed to how I write
>> half my loop macros using nested for loops so that when I break it only
>> breaks from the inner loop and corrupts memory).
>
>How about a goto if making another function is not practical?
>
>julia

Hello David, Jonathan, Dan and Julia,

no problem for me for rewriting this code using functions and avoid any use
of break. It is quite easy.

Thanks,
JB

>
>>
>> regards,
>> dan carpenter
>>
>>
>

  reply	other threads:[~2025-06-27 15:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23 12:55 [PATCH v5 0/3] Add support for WoM (Wake-on-Motion) feature Jean-Baptiste Maneyrol via B4 Relay
2025-06-23 12:55 ` [PATCH v5 1/3] iio: imu: inv_icm42600: move structure DMA buffers at the end Jean-Baptiste Maneyrol via B4 Relay
2025-06-23 22:13   ` David Lechner
2025-06-24  8:43     ` Jean-Baptiste Maneyrol
2025-06-26 18:48       ` Jonathan Cameron
2025-06-27 15:27         ` Jean-Baptiste Maneyrol
2025-06-27 17:19           ` David Lechner
2025-06-28 15:35             ` Jonathan Cameron
2025-06-23 12:55 ` [PATCH v5 2/3] iio: imu: inv_icm42600: add WoM support Jean-Baptiste Maneyrol via B4 Relay
2025-06-23 22:44   ` David Lechner
2025-06-26 18:53     ` Jonathan Cameron
2025-06-26 19:48       ` Dan Carpenter
2025-06-26 20:41         ` Julia Lawall
2025-06-27 15:32           ` Jean-Baptiste Maneyrol [this message]
2025-06-28 15:40         ` Jonathan Cameron
2025-06-23 12:55 ` [PATCH v5 3/3] iio: imu: inv_icm42600: add wakeup functionality for Wake-on-Motion Jean-Baptiste Maneyrol via B4 Relay

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=FR3P281MB17577DF9326C6CC893711EC2CE45A@FR3P281MB1757.DEUP281.PROD.OUTLOOK.COM \
    --to=jean-baptiste.maneyrol@tdk.com \
    --cc=andy@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=julia.lawall@inria.fr \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /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

all inboxes | Powered by JetHome®