From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Stepan Ionichev <sozdayvek@gmail.com>
Cc: jic23@kernel.org, songqiang1304521@gmail.com,
dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: proximity: vl53l0x: notify trigger and clear IRQ on error paths
Date: Thu, 14 May 2026 00:01:49 +0300 [thread overview]
Message-ID: <agTmvRc__VChBPLt@ashevche-desk.local> (raw)
In-Reply-To: <20260513193119.17884-1-sozdayvek@gmail.com>
On Thu, May 14, 2026 at 12:31:19AM +0500, Stepan Ionichev wrote:
> vl53l0x_trigger_handler() returns directly on the I2C read failure
> paths without calling iio_trigger_notify_done() or
> vl53l0x_clear_irq():
> ret = i2c_smbus_read_i2c_block_data(...);
> if (ret < 0)
> return ret;
> else if (ret != 12)
> return -EREMOTEIO;
Unneeded citation of the code which is visible from the change.
> A single transient i2c_smbus_read_i2c_block_data() failure (negative
> errno or a short read) therefore leaves two pieces of state behind:
>
> - iio_trigger_notify_done() never decrements the trigger's use_count,
> so iio_trigger_poll_nested() silently drops further dispatches
> (see industrialio-trigger.c, the !atomic_read(&trig->use_count)
> guard);
> - vl53l0x_clear_irq() never writes SYSTEM_INTERRUPT_CLEAR, so the
> chip keeps the DRDY interrupt asserted.
>
> The sensor's buffer mode stays wedged from then on, recoverable only
> by re-binding the driver. The sibling driver vl53l1x-i2c.c handles
> exactly the same case correctly by jumping to a "notify_and_clear_irq"
> label that always calls both helpers; mirror that here.
>
> The bogus negative-int return value cast to irqreturn_t also goes
> away as a side effect.
...
> - else if (ret != 12)
> - return -EREMOTEIO;
> + if (ret < 0 || ret != 12)
> + goto done;
While this magic 12 is in the original code, perhaps a patch on top to make it
use sizeof() instead.
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-05-13 21:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 19:31 [PATCH] iio: proximity: vl53l0x: notify trigger and clear IRQ on error paths Stepan Ionichev
2026-05-13 21:01 ` Andy Shevchenko [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=agTmvRc__VChBPLt@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=songqiang1304521@gmail.com \
--cc=sozdayvek@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