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 v2 2/2] iio: proximity: add Imagis ISG5320A SAR sensor driver
Date: Tue, 17 Nov 2026 11:08:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-218694@kernel.org> (raw)
In-Reply-To: <20261117104414.1182364-2-tadilhusrev@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] iio: proximity: isg5320a: inverted INT polarity in
isg5320a_reset()
- [Medium] iio: proximity: isg5320a: free_irq() runs before
isg5320a_teardown()
- [Medium] iio: proximity: isg5320a: broken wakeup handling in
isg5320a_events_on()
- [Low] iio: proximity: isg5320a: unchecked enable_irq_wake() in
isg5320a_events_on()
--
commit b880374f416c9c620d39544cb088cc6a533d446b
Author: Adil Hüsrev Tepe <tadilhusrev@gmail.com>
iio: proximity: add Imagis ISG5320A SAR sensor driver
This commit adds an IIO proximity driver for the Imagis ISG5320A I2C
capacitive SAR/grip sensor, exposing a raw proximity channel and
rising/falling threshold events.
> diff --git a/drivers/iio/proximity/isg5320a.c b/drivers/iio/proximity/isg5320a.c
> new file mode 100644
> index 0000000000000..baa8d07ecfd7f
> --- /dev/null
> +++ b/drivers/iio/proximity/isg5320a.c
> @@ -0,0 +1,880 @@
[ ... ]
> +/* Wait for the INT line to reach @level: up to 10 x 5 ms (vendor :262, :281). */
> +static int isg5320a_wait_int(struct isg5320a_data *data, int level)
> +{
> + int cnt, val;
> +
> + if (!data->int_gpio) {
> + msleep(50);
> + return 0;
> + }
> +
> + for (cnt = 0; cnt < 10; cnt++) {
> + /* Logical, not raw: honours the GPIO's DT polarity. */
> + val = gpiod_get_value_cansleep(data->int_gpio);
> + if (val < 0)
> + return val;
> + if (val == level)
> + return cnt;
> + usleep_range(5000, 5100);
> + }
> +
> + return -ETIMEDOUT;
> +}
> +
> +/* vendor isg5320a_reset(), :247-292, plus a CHIPID read the vendor never does */
> +static int isg5320a_reset(struct isg5320a_data *data)
> +{
[ ... ]
> + if (isg5320a_wait_int(data, 1) < 0) /* :262-266 */
> + dev_warn(dev, "INT did not go high before reset\n");
> +
> + ret = regmap_write(data->regmap, ISG5320A_REG_PROTECT, /* :268-271 */
> + ISG5320A_PROTECT_UNLOCK);
> + if (ret)
> + return dev_err_probe(dev, ret, "unlock protect failed\n");
> +
> + ret = regmap_write(data->regmap, ISG5320A_REG_SOFTRESET, /* :273-276 */
> + ISG5320A_SOFTRESET_VAL);
> + if (ret)
> + return dev_err_probe(dev, ret, "soft reset write failed\n");
> +
> + usleep_range(1000, 1100); /* :278 */
> +
> + ret = isg5320a_wait_int(data, 0); /* :280-289 */
> + if (ret < 0)
> + return dev_err_probe(dev, -EIO, "INT not asserted after soft reset\n");
[Severity: High]
Are the @level arguments passed to isg5320a_wait_int() inverted for an
active-low interrupt GPIO?
gpiod_get_value_cansleep() returns the logical state (0 when deasserted,
1 when asserted), whereas the callers here still pass the physical line
levels (1 for released/high before reset, 0 for asserted/low after soft
reset). When int-gpios is described as GPIO_ACTIVE_LOW in Device Tree,
isg5320a_wait_int(data, 0) waits for INT to be deasserted after soft
reset, timing out and failing probe.
Also, dev_err_probe() overwrites ret with -EIO instead of propagating the
error returned by isg5320a_wait_int().
[ ... ]
> +static int isg5320a_events_on(struct isg5320a_data *data)
> +{
[ ... ]
> + WRITE_ONCE(data->ev_enabled, true);
> + enable_irq(data->irq); /* :721 */
> + /* Cache the decision: device_may_wakeup(dev) may change before events_off(). */
> + data->irq_wake_enabled = device_may_wakeup(dev);
> + if (data->irq_wake_enabled)
> + enable_irq_wake(data->irq); /* :722 */
[Severity: Low]
What happens if enable_irq_wake(data->irq) fails here?
data->irq_wake_enabled remains true while desc->wake_depth stays at 0, so
isg5320a_events_off() will later call disable_irq_wake(data->irq) and
trigger an unbalanced IRQ wake disable warning.
[Severity: Medium]
Does arming enable_irq_wake() in isg5320a_events_on() respect changes to
/sys/.../power/wakeup while events are enabled?
If userspace disables wakeup via sysfs after enabling proximity events,
IRQD_WAKEUP_STATE remains set on data->irq and isg5320a_pm_ops has no
system sleep callbacks to stop the sensor, so the interrupt still wakes
the system from suspend. Conversely, on Device Tree systems with
wakeup-source, i2c_device_probe() registers client->irq via
dev_pm_set_wake_irq() (which also makes the device_init_wakeup() call in
isg5320a_probe() redundant), arming the wake IRQ on every suspend even
when data->ev_enabled is false.
Wakeup arming and sensor sleep/resume state across system suspend should
be handled in system sleep PM callbacks instead of isg5320a_events_on()
and isg5320a_events_off().
[ ... ]
> +static void isg5320a_events_off(struct isg5320a_data *data)
> +{
> + struct device *dev = data->dev;
> + int ret = 0;
> +
> + scoped_guard(mutex, &data->lock)
> + ret = regmap_write(data->regmap, ISG5320A_REG_IRQFUNC, /* :726 */
> + ISG5320A_IRQFUNC_DISABLE);
> + if (ret)
> + dev_warn(dev, "IRQFUNC disable failed: %d\n", ret);
> +
> + WRITE_ONCE(data->ev_enabled, false);
> + disable_irq(data->irq); /* :728 */
> + if (data->irq_wake_enabled) {
> + disable_irq_wake(data->irq); /* :729 */
> + data->irq_wake_enabled = false;
> + }
> +}
[ ... ]
> +/* vendor isg5320a_remove(), :2030-2033 */
> +static void isg5320a_teardown(void *arg)
> +{
> + struct isg5320a_data *data = arg;
> + struct device *dev = data->dev;
> +
> + pm_runtime_disable(dev);
> +
> + if (data->ev_enabled) {
> + isg5320a_events_off(data);
> + pm_runtime_put_noidle(dev);
> + }
> +
> + if (!pm_runtime_status_suspended(dev))
> + isg5320a_mode_sleep(data);
> +
> + pm_runtime_set_suspended(dev);
> + pm_runtime_dont_use_autosuspend(dev);
> +}
> +
> +static int isg5320a_probe(struct i2c_client *client)
> +{
[ ... ]
> + ret = devm_add_action_or_reset(dev, isg5320a_teardown, data);
> + if (ret)
> + return ret;
> +
> + 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);
> + }
> +
> + indio_dev->name = "isg5320a";
> + indio_dev->modes = INDIO_DIRECT_MODE;
> + if (data->irq > 0) {
> + indio_dev->info = &isg5320a_info;
> + indio_dev->channels = isg5320a_channels;
> + indio_dev->num_channels = ARRAY_SIZE(isg5320a_channels);
> + } else {
> + indio_dev->info = &isg5320a_info_noirq;
> + indio_dev->channels = isg5320a_channels_noirq;
> + indio_dev->num_channels = ARRAY_SIZE(isg5320a_channels_noirq);
> + }
> +
> + return devm_iio_device_register(dev, indio_dev);
> +}
[Severity: Medium]
Doesn't registering isg5320a_teardown() before devm_request_threaded_irq()
and devm_iio_device_register() cause devres to free data->irq before
isg5320a_teardown() runs?
If the driver is unbound while proximity events are enabled, devres
unregisters indio_dev and calls free_irq(data->irq, indio_dev) while
ISG5320A_REG_IRQFUNC and IRQ wake are still active, and
isg5320a_teardown() -> isg5320a_events_off() then calls disable_irq() and
disable_irq_wake() on an IRQ that has already been shut down and
released.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117104414.1182364-1-tadilhusrev@gmail.com?part=2
next prev parent reply other threads:[~2026-11-17 11:08 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 [this message]
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
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-218694@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 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.