Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Adil Hüsrev Tepe" <tadilhusrev@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 2/2] iio: proximity: add Imagis ISG5320A SAR sensor driver
Date: Tue, 17 Nov 2026 17:55:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-219292@kernel.org> (raw)
In-Reply-To: <20261117173333.1853986-3-tadilhusrev@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] iio: proximity: isg5320a: missing teardown on IRQ error in
  isg5320a_probe()
- [Low] iio: proximity: isg5320a: disable runtime PM in
  isg5320a_shutdown()
--

commit baa300415c1a96074ec67b396caa0dfe08ba9dae
Author: Adil Hüsrev Tepe <tadilhusrev@gmail.com>

iio: proximity: add Imagis ISG5320A SAR sensor driver

This commit adds an IIO driver for the Imagis ISG5320A I2C capacitive
SAR/grip sensor, exposing a proximity channel and threshold events.

> diff --git a/drivers/iio/proximity/isg5320a.c b/drivers/iio/proximity/isg5320a.c
> new file mode 100644
> index 0000000000000..4df0e09d39143
> --- /dev/null
> +++ b/drivers/iio/proximity/isg5320a.c
[ ... ]
> +static int isg5320a_probe(struct i2c_client *client)
> +{
[ ... ]
> +	ret = isg5320a_mode_normal(data);			/* :1621 */
> +	if (ret)
> +		return dev_err_probe(dev, ret, "start failed\n");
> +
> +	/*
> +	 * The chip is already active, so a later failure (e.g. the IRQ
> +	 * request below) must still put it back to sleep instead of leaving
> +	 * it scanning with nothing bound to it.
> +	 */
> +	pm_runtime_set_autosuspend_delay(dev, ISG5320A_AUTOSUSPEND_MS);
> +	pm_runtime_use_autosuspend(dev);
> +	pm_runtime_set_active(dev);
> +	pm_runtime_get_noresume(dev);
> +	pm_runtime_enable(dev);
> +	pm_runtime_put_autosuspend(dev);
> +
> +	if (data->irq > 0) {
> +		irqflags = irq_get_trigger_type(data->irq);
> +		if (!irqflags)
> +			irqflags = IRQF_TRIGGER_FALLING;	/* :1932 */
> +
> +		ret = devm_request_threaded_irq(dev, data->irq, NULL,
> +						isg5320a_irq_thread,
> +						irqflags | IRQF_ONESHOT |
> +						IRQF_NO_AUTOEN,
> +						"isg5320a", indio_dev);
> +		if (ret)
> +			return dev_err_probe(dev, ret, "irq request failed\n");
> +
> +		if (device_property_read_bool(dev, "wakeup-source"))
> +			device_init_wakeup(dev, true);
> +	}
> +
> +	/*
> +	 * Registered after the IRQ request, so devm's LIFO unwind runs this
> +	 * teardown (which may disable_irq()/disable_irq_wake() the IRQ in
> +	 * isg5320a_events_off()) before the IRQ itself is freed, not after.
> +	 */
> +	ret = devm_add_action_or_reset(dev, isg5320a_teardown, data);
> +	if (ret)
> +		return ret;

[Severity: Medium]
Does a failure in devm_request_threaded_irq() skip isg5320a_teardown()?

isg5320a_mode_normal() has already started the sensor and runtime PM is
enabled with an armed autosuspend timer, but isg5320a_teardown() is only
registered after devm_request_threaded_irq() succeeds.  If the IRQ request
fails (for example with -EPROBE_DEFER), the chip is left scanning, runtime
PM stays enabled on the unbound device, and the pending autosuspend timer
can fire isg5320a_runtime_suspend() while devres is freeing data->regmap
and indio_dev.

Requesting the IRQ (which uses IRQF_NO_AUTOEN) before calling
isg5320a_mode_normal() and enabling runtime PM would let
isg5320a_teardown() be registered immediately after pm_runtime_enable()
while still unwinding before the IRQ is freed.

[ ... ]
> +/* vendor isg5320a_shutdown(), :2071-2080, synchronized like isg5320a_teardown() */
> +static void isg5320a_shutdown(struct i2c_client *client)
> +{
> +	struct isg5320a_data *data = iio_priv(i2c_get_clientdata(client));
> +	struct device *dev = data->dev;
> +
> +	guard(mutex)(&data->ev_lock);
> +
> +	if (data->ev_enabled) {
> +		isg5320a_events_off(data);
> +		pm_runtime_put_noidle(dev);
> +	}
> +
> +	if (!pm_runtime_status_suspended(dev))
> +		isg5320a_mode_sleep(data);
> +}

[Severity: Low]
Can a concurrent sysfs access resume the sensor or re-enable events during
or after isg5320a_shutdown()?

Unlike isg5320a_teardown(), isg5320a_shutdown() runs while indio_dev is
still registered and does not call pm_runtime_disable(dev).  A concurrent
isg5320a_read_raw() -> isg5320a_get_sample() does not take data->ev_lock
and can runtime-resume the chip back into normal mode, or a later
isg5320a_write_event_config() call can re-enable the interrupt and wakeup
source after shutdown finishes:

CPU0                                  CPU1
isg5320a_shutdown()
  guard(mutex)(&data->ev_lock)
  !pm_runtime_status_suspended(dev)
  isg5320a_mode_sleep(data)
                                      isg5320a_read_raw()
                                        isg5320a_get_sample()
                                          pm_runtime_resume_and_get(dev)
                                            isg5320a_runtime_resume()
                                              isg5320a_mode_normal(data)
                                                <-- chip left scanning

Calling pm_runtime_disable(dev) before checking
pm_runtime_status_suspended(dev) and pm_runtime_set_suspended(dev) after
isg5320a_mode_sleep(data), as in isg5320a_teardown(), would prevent
later runtime resumes and event enables.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117173333.1853986-1-tadilhusrev@gmail.com?part=2

      reply	other threads:[~2026-11-17 17:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  7:40 [PATCH v1 0/2] iio: proximity: add Imagis ISG5320A (Samsung Galaxy XCover5) Adil Hüsrev Tepe
2026-11-16  7:40 ` [PATCH v1 1/2] dt-bindings: iio: proximity: add Imagis ISG5320A Adil Hüsrev Tepe
2026-11-16  7:51   ` sashiko-bot
2026-11-16  7:40 ` [PATCH v1 2/2] iio: proximity: add Imagis ISG5320A SAR sensor driver Adil Hüsrev Tepe
2026-11-16  7:58   ` sashiko-bot
2026-11-16 10:53   ` Andy Shevchenko
2026-11-16 10:48 ` [PATCH v1 0/2] iio: proximity: add Imagis ISG5320A (Samsung Galaxy XCover5) Andy Shevchenko
2026-11-17 10:44 ` [PATCH v2 1/2] dt-bindings: iio: proximity: add Imagis ISG5320A Adil Hüsrev Tepe
2026-11-17 10:44   ` [PATCH v2 2/2] iio: proximity: add Imagis ISG5320A SAR sensor driver Adil Hüsrev Tepe
2026-11-17 11:08     ` sashiko-bot
2026-11-17 13:56     ` Andy Shevchenko
2026-11-17 10:54   ` [PATCH v2 1/2] dt-bindings: iio: proximity: add Imagis ISG5320A sashiko-bot
2026-11-17 17:33 ` [PATCH v3 0/2] iio: proximity: add Imagis ISG5320A (Samsung Galaxy XCover5) Adil Hüsrev Tepe
2026-11-17 17:33   ` [PATCH v3 1/2] dt-bindings: iio: proximity: add Imagis ISG5320A Adil Hüsrev Tepe
2026-11-17 17:33   ` [PATCH v3 2/2] iio: proximity: add Imagis ISG5320A SAR sensor driver Adil Hüsrev Tepe
2026-11-17 17:55     ` sashiko-bot [this message]

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=sashiko-outbox-219292@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tadilhusrev@gmail.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