[PATCH] iio: light: tsl2591: return actual error from probe IRQ failure

Stepan Ionichev posted 1 patch 1 week ago
There is a newer version of this series
drivers/iio/light/tsl2591.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[PATCH] iio: light: tsl2591: return actual error from probe IRQ failure
Posted by Stepan Ionichev 1 week ago
When devm_request_threaded_irq() fails, probe calls dev_err_probe()
but then returns -EINVAL, dropping the real error code and breaking
the deferred-probe flow that dev_err_probe() handles for -EPROBE_DEFER.

Return the value from dev_err_probe() instead.

Fixes: 2335f0d7c790 ("iio: light: Added AMS tsl2591 driver implementation")
Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
 drivers/iio/light/tsl2591.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/light/tsl2591.c b/drivers/iio/light/tsl2591.c
index c5557867e..4b0a2a302 100644
--- a/drivers/iio/light/tsl2591.c
+++ b/drivers/iio/light/tsl2591.c
@@ -1137,10 +1137,8 @@ static int tsl2591_probe(struct i2c_client *client)
 						NULL, tsl2591_event_handler,
 						IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 						"tsl2591_irq", indio_dev);
-		if (ret) {
-			dev_err_probe(&client->dev, ret, "IRQ request error\n");
-			return -EINVAL;
-		}
+		if (ret)
+			return dev_err_probe(&client->dev, ret, "IRQ request error\n");
 		indio_dev->info = &tsl2591_info;
 	} else {
 		indio_dev->info = &tsl2591_info_no_irq;
-- 
2.43.0
Re: [PATCH] iio: light: tsl2591: return actual error from probe IRQ failure
Posted by Andy Shevchenko 6 days, 22 hours ago
On Sun, May 17, 2026 at 11:10:42PM +0500, Stepan Ionichev wrote:
> When devm_request_threaded_irq() fails, probe calls dev_err_probe()
> but then returns -EINVAL, dropping the real error code and breaking
> the deferred-probe flow that dev_err_probe() handles for -EPROBE_DEFER.
> 
> Return the value from dev_err_probe() instead.

...

> -		if (ret) {
> -			dev_err_probe(&client->dev, ret, "IRQ request error\n");
> -			return -EINVAL;
> -		}
> +		if (ret)
> +			return dev_err_probe(&client->dev, ret, "IRQ request error\n");

Also remove dup message, at the end it should be

		if (ret)
			return ret;

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH] iio: light: tsl2591: return actual error from probe IRQ failure
Posted by Joshua Crofts 1 week ago
On Sun, 17 May 2026 at 20:15, Stepan Ionichev <sozdayvek@gmail.com> wrote:
>
> When devm_request_threaded_irq() fails, probe calls dev_err_probe()
> but then returns -EINVAL, dropping the real error code and breaking
> the deferred-probe flow that dev_err_probe() handles for -EPROBE_DEFER.
>
> Return the value from dev_err_probe() instead.
>
> Fixes: 2335f0d7c790 ("iio: light: Added AMS tsl2591 driver implementation")
> Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>

Fine by me. Maybe this could also get marked for stable? (Up to Jonathan
of course).

Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>

-- 
Kind regards

CJD
[PATCH v2] iio: light: tsl2591: return actual error from probe IRQ failure
Posted by Stepan Ionichev 6 days, 20 hours ago
When devm_request_threaded_irq() fails, probe logs the error and
then returns -EINVAL, dropping the real error code and breaking the
deferred-probe flow for -EPROBE_DEFER.

Return ret directly; the IRQ subsystem already prints on failure.

Fixes: 2335f0d7c790 ("iio: light: Added AMS tsl2591 driver implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
v2:
- Drop dev_err_probe(); just return ret (Andy)
- Add Cc: stable@ as suggested by Joshua

v1: https://lore.kernel.org/all/20260517181042.668-1-sozdayvek@gmail.com/

 drivers/iio/light/tsl2591.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/light/tsl2591.c b/drivers/iio/light/tsl2591.c
index c5557867e..c5ccd833d 100644
--- a/drivers/iio/light/tsl2591.c
+++ b/drivers/iio/light/tsl2591.c
@@ -1137,10 +1137,8 @@ static int tsl2591_probe(struct i2c_client *client)
 						NULL, tsl2591_event_handler,
 						IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 						"tsl2591_irq", indio_dev);
-		if (ret) {
-			dev_err_probe(&client->dev, ret, "IRQ request error\n");
-			return -EINVAL;
-		}
+		if (ret)
+			return ret;
 		indio_dev->info = &tsl2591_info;
 	} else {
 		indio_dev->info = &tsl2591_info_no_irq;
-- 
2.43.0
Re: [PATCH v2] iio: light: tsl2591: return actual error from probe IRQ failure
Posted by Jonathan Cameron 6 days, 14 hours ago
On Mon, 18 May 2026 14:43:11 +0500
Stepan Ionichev <sozdayvek@gmail.com> wrote:

> When devm_request_threaded_irq() fails, probe logs the error and
> then returns -EINVAL, dropping the real error code and breaking the
> deferred-probe flow for -EPROBE_DEFER.
> 
> Return ret directly; the IRQ subsystem already prints on failure.
> 
> Fixes: 2335f0d7c790 ("iio: light: Added AMS tsl2591 driver implementation")

Hmm. To me borderline on whether it's a fix.  In theory a board may exist
where the defer is a possibility.  In practice probably not given I don't
think we've ever had a report of this.

Meh, it's harmless enough and maybe helps someone.

> Cc: stable@vger.kernel.org
> Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
New series versions should never be in reply to older series.

It tends to hide them in people's inboxes and brings little nor no benefit.
> ---
> v2:
> - Drop dev_err_probe(); just return ret (Andy)
> - Add Cc: stable@ as suggested by Joshua
Mostly for IIO I add those to patches that I think need it but don't object
if people feel strongly enough and add them themselves.

Applied to the iio-fixes branch of iio.git.

> 
> v1: https://lore.kernel.org/all/20260517181042.668-1-sozdayvek@gmail.com/
> 
>  drivers/iio/light/tsl2591.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/light/tsl2591.c b/drivers/iio/light/tsl2591.c
> index c5557867e..c5ccd833d 100644
> --- a/drivers/iio/light/tsl2591.c
> +++ b/drivers/iio/light/tsl2591.c
> @@ -1137,10 +1137,8 @@ static int tsl2591_probe(struct i2c_client *client)
>  						NULL, tsl2591_event_handler,
>  						IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
>  						"tsl2591_irq", indio_dev);
> -		if (ret) {
> -			dev_err_probe(&client->dev, ret, "IRQ request error\n");
> -			return -EINVAL;
> -		}
> +		if (ret)
> +			return ret;
>  		indio_dev->info = &tsl2591_info;
>  	} else {
>  		indio_dev->info = &tsl2591_info_no_irq;
Re: [PATCH v2] iio: light: tsl2591: return actual error from probe IRQ failure
Posted by Jonathan Cameron 6 days, 14 hours ago
On Mon, 18 May 2026 16:40:48 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Mon, 18 May 2026 14:43:11 +0500
> Stepan Ionichev <sozdayvek@gmail.com> wrote:
> 
> > When devm_request_threaded_irq() fails, probe logs the error and
> > then returns -EINVAL, dropping the real error code and breaking the
> > deferred-probe flow for -EPROBE_DEFER.
> > 
> > Return ret directly; the IRQ subsystem already prints on failure.
> > 
> > Fixes: 2335f0d7c790 ("iio: light: Added AMS tsl2591 driver implementation")  
> 
> Hmm. To me borderline on whether it's a fix.  In theory a board may exist
> where the defer is a possibility.  In practice probably not given I don't
> think we've ever had a report of this.
> 
> Meh, it's harmless enough and maybe helps someone.
> 
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>  
> New series versions should never be in reply to older series.
> 
> It tends to hide them in people's inboxes and brings little nor no benefit.
> > ---
> > v2:
> > - Drop dev_err_probe(); just return ret (Andy)
> > - Add Cc: stable@ as suggested by Joshua  
> Mostly for IIO I add those to patches that I think need it but don't object
> if people feel strongly enough and add them themselves.
> 
> Applied to the iio-fixes branch of iio.git.
> 
Actually dropped again.  I forgot to check sashiko and it raises a reasonable
question:
https://sashiko.dev/#/patchset/20260518094311.2000-1-sozdayvek%40gmail.com

Does completely removing dev_err_probe() here drop the deferred probe reason
tracking?
While this patch successfully fixes the return code, dev_err_probe() also
records the deferral reason in debugfs via device_set_deferred_probe_reason()
when ret is -EPROBE_DEFER.
Could we keep the diagnostic tracking by returning the result of
dev_err_probe() directly instead?
        if (ret)
                return dev_err_probe(&client->dev, ret, "IRQ request error\n");

Andy, what do you think?

> > 
> > v1: https://lore.kernel.org/all/20260517181042.668-1-sozdayvek@gmail.com/
> > 
> >  drivers/iio/light/tsl2591.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/iio/light/tsl2591.c b/drivers/iio/light/tsl2591.c
> > index c5557867e..c5ccd833d 100644
> > --- a/drivers/iio/light/tsl2591.c
> > +++ b/drivers/iio/light/tsl2591.c
> > @@ -1137,10 +1137,8 @@ static int tsl2591_probe(struct i2c_client *client)
> >  						NULL, tsl2591_event_handler,
> >  						IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> >  						"tsl2591_irq", indio_dev);
> > -		if (ret) {
> > -			dev_err_probe(&client->dev, ret, "IRQ request error\n");
> > -			return -EINVAL;
> > -		}
> > +		if (ret)
> > +			return ret;
> >  		indio_dev->info = &tsl2591_info;
> >  	} else {
> >  		indio_dev->info = &tsl2591_info_no_irq;  
>