Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Tsz Shan Chan <tsz.chan.dev@gmail.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Tsz Shan Chan" <tchan@jacques.com.au>
Subject: Re: [PATCH v2 2/2] iio: light: vcnl4000: add shared IRQ support
Date: Sat, 22 Aug 2026 03:25:50 +0100	[thread overview]
Message-ID: <20260822032550.31a0fa9e@jic23-huawei> (raw)
In-Reply-To: <20260814-vcnl4000-v2-2-9b771290cc1d@jacques.com.au>

On Fri, 14 Aug 2026 14:30:43 +1000
Tsz Shan Chan <tsz.chan.dev@gmail.com> wrote:

> The INT output of vcnl4010/4020 and vcnl4040/4200 is open drain active
> low which can be shared with other devices.
> Add IRQF_SHARED and switch the trigger type from IRQF_TRIGGER_FALLING to
> IRQF_TRIGGER_LOW. Edge triggering can miss interrupts on a shared line.
Fairly low risk change but I guess we'll see.

It used to be annoyingly common for interrupt controllers to support
only edge based interrupts, but hopefully that silliness is a thing
of the past.

So crossed fingers, I'll apply this and see if we get anyone shouting.
I think we'll get away with it

Thanks,

Jonathan

> 
> Return IRQ_NONE from the irq handler when read fails or when none of the
> interrupt source bits handled by the driver are set. This prevents
> claiming interrupts from other devices on a shared line.
> 
> Signed-off-by: Tsz Shan Chan <tchan@jacques.com.au>
> ---
>  drivers/iio/light/vcnl4000.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index 663e623da833..8a723eaadbb6 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -1470,7 +1470,11 @@ static irqreturn_t vcnl4040_irq_thread(int irq, void *p)
>  
>  	ret = i2c_smbus_read_word_data(data->client, data->chip_spec->int_reg);
>  	if (ret < 0)
> -		return IRQ_HANDLED;
> +		return IRQ_NONE;
> +
> +	if (!(ret & (VCNL4040_PS_IF_CLOSE | VCNL4040_PS_IF_AWAY |
> +		     VCNL4040_ALS_FALLING | VCNL4040_ALS_RISING)))
> +		return IRQ_NONE;
>  
>  	if (ret & VCNL4040_PS_IF_CLOSE) {
>  		iio_push_event(indio_dev,
> @@ -1526,7 +1530,10 @@ static irqreturn_t vcnl4010_irq_thread(int irq, void *p)
>  
>  	ret = i2c_smbus_read_byte_data(data->client, VCNL4010_ISR);
>  	if (ret < 0)
> -		goto end;
> +		return IRQ_NONE;
> +
> +	if (!(ret & (VCNL4010_INT_THR | VCNL4010_INT_DRDY)))
> +		return IRQ_NONE;
>  
>  	isr = ret;
>  
> @@ -1558,7 +1565,6 @@ static irqreturn_t vcnl4010_irq_thread(int irq, void *p)
>  	if (isr & VCNL4010_INT_DRDY && iio_buffer_enabled(indio_dev))
>  		iio_trigger_poll_nested(indio_dev->trig);
>  
> -end:
>  	return IRQ_HANDLED;
>  }
>  
> @@ -1981,8 +1987,8 @@ static int vcnl4000_probe(struct i2c_client *client)
>  	if (client->irq && data->chip_spec->irq_thread) {
>  		ret = devm_request_threaded_irq(dev, client->irq, NULL,
>  						data->chip_spec->irq_thread,
> -						IRQF_TRIGGER_FALLING |
> -						IRQF_ONESHOT,
> +						IRQF_TRIGGER_LOW |
> +						IRQF_ONESHOT | IRQF_SHARED,
>  						"vcnl4000_irq",
>  						indio_dev);
>  		if (ret < 0)
> 


  reply	other threads:[~2026-08-22  2:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14  4:30 [PATCH v2 0/2] iio: light: vcnl4000: support shared IRQs Tsz Shan Chan
2026-08-14  4:30 ` [PATCH v2 1/2] iio: light: vcnl4000: use correct channel array size Tsz Shan Chan
2026-08-14  4:30 ` [PATCH v2 2/2] iio: light: vcnl4000: add shared IRQ support Tsz Shan Chan
2026-08-22  2:25   ` Jonathan Cameron [this message]
2026-08-24  8:24     ` Andy Shevchenko
2026-08-25  3:22       ` Tsz Shan Chan
2026-08-25  8:48         ` Andy Shevchenko
2026-08-28  8:09           ` Tsz Shan Chan
2026-08-17 10:55 ` [PATCH v2 0/2] iio: light: vcnl4000: support shared IRQs Andy Shevchenko
2026-08-22  2:29   ` Jonathan Cameron
2026-08-28  8:13     ` Tsz Shan Chan

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=20260822032550.31a0fa9e@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=tchan@jacques.com.au \
    --cc=tsz.chan.dev@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