* [PATCH v2 0/2] iio: light: vcnl4000: support shared IRQs
@ 2026-08-14 4:30 Tsz Shan Chan
2026-08-14 4:30 ` [PATCH v2 1/2] iio: light: vcnl4000: use correct channel array size Tsz Shan Chan
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Tsz Shan Chan @ 2026-08-14 4:30 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, Tsz Shan Chan
This series contains two changes for the vcnl4000 driver.
Patch 1 makes .num_channels match .channels for vcnl4200. vcnl4040 and
vcnl4000 channel arrays have the same size, so no functional change.
Patch 2 adds shared IRQ support. It changes the trigger type from
falling edge to low level and adds IRQF_SHARED. The IRQ handlers return
IRQ_NONE when the device did not generate the interrupt.
Signed-off-by: Tsz Shan Chan <tchan@jacques.com.au>
---
Changes in v2:
- 1/2: Clarify in the commit message that the channel arrays have the
same size.
- 2/2: Drop IRQ trigger type checking and use IRQF_TRIGGER_LOW directly.
- 2/2: Check the interrupt source bits handled by the driver.
- Link to v1: https://lore.kernel.org/r/20260811-vcnl4000-v1-0-50e7fb657692@jacques.com.au
---
Tsz Shan Chan (2):
iio: light: vcnl4000: use correct channel array size
iio: light: vcnl4000: add shared IRQ support
drivers/iio/light/vcnl4000.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
---
base-commit: 3d6d817622b0a9721e3cc404df3469171582be13
change-id: 20260810-vcnl4000-02e19f70e706
Best regards,
--
Tsz Shan Chan <tchan@jacques.com.au>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/2] iio: light: vcnl4000: use correct channel array size
2026-08-14 4:30 [PATCH v2 0/2] iio: light: vcnl4000: support shared IRQs Tsz Shan Chan
@ 2026-08-14 4:30 ` Tsz Shan Chan
2026-08-14 4:30 ` [PATCH v2 2/2] iio: light: vcnl4000: add shared IRQ support Tsz Shan Chan
2026-08-17 10:55 ` [PATCH v2 0/2] iio: light: vcnl4000: support shared IRQs Andy Shevchenko
2 siblings, 0 replies; 8+ messages in thread
From: Tsz Shan Chan @ 2026-08-14 4:30 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, Tsz Shan Chan
vcnl4200_spec sets .channel to vcnl4040_channels but .num_channels uses
ARRAY_SIZE(vcnl4000_channels). Use ARRAY_SIZE(vcnl4040_channels) so
num_channels matches .channels.
Both arrays have the same size. No behaviour change.
Signed-off-by: Tsz Shan Chan <tchan@jacques.com.au>
---
drivers/iio/light/vcnl4000.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 128ae3f94074..663e623da833 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -1874,7 +1874,7 @@ static const struct vcnl4000_chip_spec vcnl4200_spec = {
.measure_proximity = vcnl4200_measure_proximity,
.set_power_state = vcnl4200_set_power_state,
.channels = vcnl4040_channels,
- .num_channels = ARRAY_SIZE(vcnl4000_channels),
+ .num_channels = ARRAY_SIZE(vcnl4040_channels),
.info = &vcnl4040_info,
.irq_thread = vcnl4040_irq_thread,
.int_reg = VCNL4200_INT_FLAGS,
--
2.55.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/2] iio: light: vcnl4000: add shared IRQ support
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 ` Tsz Shan Chan
2026-08-22 2:25 ` Jonathan Cameron
2026-08-17 10:55 ` [PATCH v2 0/2] iio: light: vcnl4000: support shared IRQs Andy Shevchenko
2 siblings, 1 reply; 8+ messages in thread
From: Tsz Shan Chan @ 2026-08-14 4:30 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, Tsz Shan Chan
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.
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)
--
2.55.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] iio: light: vcnl4000: support shared IRQs
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-17 10:55 ` Andy Shevchenko
2026-08-22 2:29 ` Jonathan Cameron
2 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2026-08-17 10:55 UTC (permalink / raw)
To: Tsz Shan Chan
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel, Tsz Shan Chan
On Fri, Aug 14, 2026 at 02:30:41PM +1000, Tsz Shan Chan wrote:
> This series contains two changes for the vcnl4000 driver.
>
> Patch 1 makes .num_channels match .channels for vcnl4200. vcnl4040 and
> vcnl4000 channel arrays have the same size, so no functional change.
>
> Patch 2 adds shared IRQ support. It changes the trigger type from
> falling edge to low level and adds IRQF_SHARED. The IRQ handlers return
> IRQ_NONE when the device did not generate the interrupt.
LGTM,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] iio: light: vcnl4000: add shared IRQ support
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
2026-08-24 8:24 ` Andy Shevchenko
0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Cameron @ 2026-08-22 2:25 UTC (permalink / raw)
To: Tsz Shan Chan
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel, Tsz Shan Chan
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)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/2] iio: light: vcnl4000: support shared IRQs
2026-08-17 10:55 ` [PATCH v2 0/2] iio: light: vcnl4000: support shared IRQs Andy Shevchenko
@ 2026-08-22 2:29 ` Jonathan Cameron
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-08-22 2:29 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Tsz Shan Chan, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel, Tsz Shan Chan
On Mon, 17 Aug 2026 13:55:40 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Fri, Aug 14, 2026 at 02:30:41PM +1000, Tsz Shan Chan wrote:
> > This series contains two changes for the vcnl4000 driver.
> >
> > Patch 1 makes .num_channels match .channels for vcnl4200. vcnl4040 and
> > vcnl4000 channel arrays have the same size, so no functional change.
> >
> > Patch 2 adds shared IRQ support. It changes the trigger type from
> > falling edge to low level and adds IRQF_SHARED. The IRQ handlers return
> > IRQ_NONE when the device did not generate the interrupt.
>
> LGTM,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
>
See sashiko
https://sashiko.dev/#/patchset/20260814-vcnl4000-v2-0-9b771290cc1d%40jacques.com.au
It might be wrong and there isn't a race condition that ends you
with that condition of stuck level interrupt. If so just reply here to explain why.
The one about even disabling is a common issue - the IIO core has
not explicit tracking of what events are enabled so it is up to the
driver to quiesce anything necessary on the path down. I didn't look closely
at these reports though so they may or may not be correct!
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] iio: light: vcnl4000: add shared IRQ support
2026-08-22 2:25 ` Jonathan Cameron
@ 2026-08-24 8:24 ` Andy Shevchenko
2026-08-25 3:22 ` Tsz Shan Chan
0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2026-08-24 8:24 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Tsz Shan Chan, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel, Tsz Shan Chan
On Sat, Aug 22, 2026 at 03:25:50AM +0100, Jonathan Cameron wrote:
> 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
In another thread somebody mentioned a type of the signal that HW generates.
Having OD output doesn't prevent HW to behave like it does edge interrupts,
id est generating a pulse instead of keeping the level until it gets acked.
With that being said, I would ask the datasheet citation to clarify the case.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/2] iio: light: vcnl4000: add shared IRQ support
2026-08-24 8:24 ` Andy Shevchenko
@ 2026-08-25 3:22 ` Tsz Shan Chan
0 siblings, 0 replies; 8+ messages in thread
From: Tsz Shan Chan @ 2026-08-25 3:22 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel, Tsz Shan Chan
On Mon, Aug 24, 2026 at 11:24:26AM +0300, Andy Shevchenko wrote:
> On Sat, Aug 22, 2026 at 03:25:50AM +0100, Jonathan Cameron wrote:
> > 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
>
> In another thread somebody mentioned a type of the signal that HW generates.
> Having OD output doesn't prevent HW to behave like it does edge interrupts,
> id est generating a pulse instead of keeping the level until it gets acked.
> With that being said, I would ask the datasheet citation to clarify the case.
>
vcnl4010/4020 datasheet, Page 11 Table 15 Notes:
"Once an interrupt is generated the corresponding status bit goes to 1
and stays there unless it is cleared by writing a 1 in the
corresponding bit. The int pad will be pulled down while at least one
of the status bit is 1."
vcnl4040/4200 datasheet, Page 13 Section Interrupt Flag:
"INT_Flag represents all of the interrupt trigger statuses for ALS and
PS. If any of these flags trigger from "0" to "1", the INT pin will be
pulled low. Once the host reads INT_Flag register, all the flags are
cleared (reset to "0"), and the INT pin is reset to high."
The interrupt is latched. The line stays low until the driver clears it.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-08-25 3:22 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2026-08-24 8:24 ` Andy Shevchenko
2026-08-25 3:22 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®