From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Jorge Marques <jorge.marques@analog.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH v2 5/9] iio: adc: ad4062: Add IIO Trigger support
Date: Mon, 24 Nov 2025 11:36:12 +0200 [thread overview]
Message-ID: <aSQnDMsE13zwM1YO@smile.fi.intel.com> (raw)
In-Reply-To: <20251124-staging-ad4062-v2-5-a375609afbb7@analog.com>
On Mon, Nov 24, 2025 at 10:18:04AM +0100, Jorge Marques wrote:
> Adds support for IIO Trigger. Optionally, gp1 is assigned as Data Ready
> signal, if not present, fallback to an I3C IBI with the same role.
> The software trigger is allocated by the device, but must be attached by
> the user before enabling the buffer. The purpose is to not impede
> removing the driver due to the increased reference count when
> iio_trigger_set_immutable or iio_trigger_get is used.
We refer to the functions as func(). Mind the parentheses.
...
> + struct ad4062_state *st = container_of(work, struct ad4062_state,
> + trig_conv);
I think the
struct ad4062_state *st =
container_of(work, struct ad4062_state, trig_conv);
reads better.
> + int ret;
...
> + /* Read current conversion, if at reg CONV_READ, stop bit triggers
> + * next sample and does not need writing the address.
> + */
/*
* The multi-line comment style is as in
* this example. Please, check and update.
*/
> +static irqreturn_t ad4062_poll_handler(int irq, void *p)
> +{
> + struct iio_poll_func *pf = p;
> + struct iio_dev *indio_dev = pf->indio_dev;
> + struct ad4062_state *st = iio_priv(indio_dev);
> +
> + iio_trigger_notify_done(indio_dev->trig);
> + schedule_work(&st->trig_conv);
> +
> + return IRQ_HANDLED;
> }
...
> +static int ad4062_triggered_buffer_postenable(struct iio_dev *indio_dev)
> +{
> + struct ad4062_state *st = iio_priv(indio_dev);
> + int ret;
> +
> + ret = pm_runtime_resume_and_get(&st->i3cdev->dev);
> + if (ret)
> + return ret;
> +
> + ret = ad4062_set_operation_mode(st, st->mode);
> + if (ret)
> + goto out_mode_error;
> +
> + /* CONV_READ requires read to trigger first sample. */
> + struct i3c_priv_xfer t[2] = {
> + {
> + .data.out = &st->reg_addr_conv,
> + .len = sizeof(st->reg_addr_conv),
> + .rnw = false,
> + },
> + {
> + .data.in = &st->buf.be32,
> + .len = sizeof(st->buf.be32),
> + .rnw = true,
> + }
> + };
> +
> + ret = i3c_device_do_priv_xfers(st->i3cdev, t, st->gpo_irq[1] ? 2 : 1);
> + if (ret)
> + goto out_mode_error;
> + return 0;
> +
> +out_mode_error:
> + pm_runtime_put_autosuspend(&st->i3cdev->dev);
> +
> + return ret;
I guess with ACQUIRE() this function will look better, because the explicit
reference count bumping (with an associated comment) is more descriptive on
what's going on here with PM. Same for other related functions.
> +}
...
> if (ret)
> return dev_err_probe(dev, ret, "Failed to request i3c ibi\n");
>
> + INIT_WORK(&st->trig_conv, ad4062_trigger_work);
This is mixture of devm_*() and non-devm_*() calls. How did you (stress) test
the removal and error paths here? Wouldn't devm-helpers.h APIs help here to
make / keep order correct?
> return devm_iio_device_register(dev, indio_dev);
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-11-24 9:36 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-24 9:17 [PATCH v2 0/9] Add support for AD4062 device family Jorge Marques
2025-11-24 9:18 ` [PATCH v2 1/9] dt-bindings: iio: adc: Add adi,ad4062 Jorge Marques
2025-11-25 9:50 ` Krzysztof Kozlowski
2025-11-26 16:14 ` Jorge Marques
2025-11-24 9:18 ` [PATCH v2 2/9] docs: iio: New docs for ad4062 driver Jorge Marques
2025-11-24 9:18 ` [PATCH v2 3/9] iio: adc: Add support for ad4062 Jorge Marques
2025-11-24 10:20 ` Andy Shevchenko
2025-11-26 11:40 ` Jorge Marques
2025-11-27 8:58 ` Andy Shevchenko
2025-11-28 18:50 ` Jorge Marques
2025-11-28 19:25 ` Andy Shevchenko
2025-12-04 21:37 ` Jorge Marques
2025-12-04 22:23 ` Andy Shevchenko
2025-12-06 16:39 ` Jonathan Cameron
2025-11-24 9:18 ` [PATCH v2 4/9] docs: iio: ad4062: Add IIO Trigger support Jorge Marques
2025-11-24 9:18 ` [PATCH v2 5/9] iio: adc: " Jorge Marques
2025-11-24 9:36 ` Andy Shevchenko [this message]
2025-11-26 14:03 ` Jorge Marques
2025-11-24 9:18 ` [PATCH v2 6/9] docs: iio: ad4062: Add IIO Events support Jorge Marques
2025-11-24 9:18 ` [PATCH v2 7/9] iio: adc: " Jorge Marques
2025-11-24 10:33 ` Andy Shevchenko
2025-11-26 15:00 ` Jorge Marques
2025-11-27 9:13 ` Andy Shevchenko
2025-12-04 21:37 ` Jorge Marques
2025-11-24 9:18 ` [PATCH v2 8/9] docs: iio: ad4062: Add GPIO Controller support Jorge Marques
2025-11-24 9:18 ` [PATCH v2 9/9] iio: adc: " Jorge Marques
2025-11-24 9:51 ` Linus Walleij
2025-11-24 10:40 ` Andy Shevchenko
2025-11-26 15:55 ` Jorge Marques
2025-11-27 9:20 ` Andy Shevchenko
2025-12-04 21:38 ` Jorge Marques
2025-12-04 22:21 ` Andy Shevchenko
2025-12-05 11:53 ` Jorge Marques
2025-12-05 12:02 ` 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=aSQnDMsE13zwM1YO@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=jorge.marques@analog.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@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).