* [PATCH] i2c: core: Fix probing of i2c slaves without interrupts
@ 2014-11-17 11:43 Geert Uytterhoeven
2014-11-17 17:08 ` Fabio Estevam
2014-11-26 0:22 ` Laurent Pinchart
0 siblings, 2 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2014-11-17 11:43 UTC (permalink / raw)
To: Laurent Pinchart, Wolfram Sang
Cc: linux-i2c, devicetree, linux-kernel, linux-sh, Geert Uytterhoeven
Since commit 2fd36c55264926e2 ("i2c: core: Map OF IRQ at probe time"),
i2c slaves without interrupts (e.g. da9210 and at24 on r8a7791/koelsch)
fail to probe:
at24: probe of 2-0050 failed with error -22
da9210: probe of 6-0068 failed with error -22
This happens because the call to of_irq_get() in i2c_device_probe()
returns -EINVAL.
If a device node does not have an "interrupts" property,
of_irq_parse_one() fails. Unlike irq_of_parse_and_map(), of_irq_get()
does not ignore errors from of_irq_parse_one(), but forwards them.
Make i2c_device_probe() ignore all errors but -EPROBE_DEFER to fix this,
just like platform_get_irq() and platform_get_irq_byname() already do.
Fixes: 2fd36c55264926e2 ("i2c: core: Map OF IRQ at probe time")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/i2c/i2c-core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index a0768d6dffc28aae..cf830915713b387a 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -629,8 +629,10 @@ static int i2c_device_probe(struct device *dev)
if (!client->irq && dev->of_node) {
int irq = of_irq_get(dev->of_node, 0);
- if (irq < 0)
+ if (irq == -EPROBE_DEFER)
return irq;
+ if (irq < 0)
+ irq = 0;
client->irq = irq;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: core: Fix probing of i2c slaves without interrupts
2014-11-17 11:43 [PATCH] i2c: core: Fix probing of i2c slaves without interrupts Geert Uytterhoeven
@ 2014-11-17 17:08 ` Fabio Estevam
2014-11-17 18:12 ` Wolfram Sang
2014-11-26 0:22 ` Laurent Pinchart
1 sibling, 1 reply; 4+ messages in thread
From: Fabio Estevam @ 2014-11-17 17:08 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Laurent Pinchart, Wolfram Sang, linux-i2c, devicetree,
linux-kernel, linux-sh
On Mon, Nov 17, 2014 at 9:43 AM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> Since commit 2fd36c55264926e2 ("i2c: core: Map OF IRQ at probe time"),
> i2c slaves without interrupts (e.g. da9210 and at24 on r8a7791/koelsch)
> fail to probe:
>
> at24: probe of 2-0050 failed with error -22
>
> da9210: probe of 6-0068 failed with error -22
>
> This happens because the call to of_irq_get() in i2c_device_probe()
> returns -EINVAL.
>
> If a device node does not have an "interrupts" property,
> of_irq_parse_one() fails. Unlike irq_of_parse_and_map(), of_irq_get()
> does not ignore errors from of_irq_parse_one(), but forwards them.
>
> Make i2c_device_probe() ignore all errors but -EPROBE_DEFER to fix this,
> just like platform_get_irq() and platform_get_irq_byname() already do.
>
> Fixes: 2fd36c55264926e2 ("i2c: core: Map OF IRQ at probe time")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
With this patch applied my codec and PMIC can be probed again:
Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: core: Fix probing of i2c slaves without interrupts
2014-11-17 17:08 ` Fabio Estevam
@ 2014-11-17 18:12 ` Wolfram Sang
0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2014-11-17 18:12 UTC (permalink / raw)
To: Fabio Estevam
Cc: Geert Uytterhoeven, Laurent Pinchart, linux-i2c, devicetree,
linux-kernel, linux-sh
[-- Attachment #1: Type: text/plain, Size: 1224 bytes --]
On Mon, Nov 17, 2014 at 03:08:25PM -0200, Fabio Estevam wrote:
> On Mon, Nov 17, 2014 at 9:43 AM, Geert Uytterhoeven
> <geert+renesas@glider.be> wrote:
> > Since commit 2fd36c55264926e2 ("i2c: core: Map OF IRQ at probe time"),
> > i2c slaves without interrupts (e.g. da9210 and at24 on r8a7791/koelsch)
> > fail to probe:
> >
> > at24: probe of 2-0050 failed with error -22
> >
> > da9210: probe of 6-0068 failed with error -22
> >
> > This happens because the call to of_irq_get() in i2c_device_probe()
> > returns -EINVAL.
> >
> > If a device node does not have an "interrupts" property,
> > of_irq_parse_one() fails. Unlike irq_of_parse_and_map(), of_irq_get()
> > does not ignore errors from of_irq_parse_one(), but forwards them.
> >
> > Make i2c_device_probe() ignore all errors but -EPROBE_DEFER to fix this,
> > just like platform_get_irq() and platform_get_irq_byname() already do.
> >
> > Fixes: 2fd36c55264926e2 ("i2c: core: Map OF IRQ at probe time")
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> With this patch applied my codec and PMIC can be probed again:
>
> Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
Applied to for-next, thanks!
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: core: Fix probing of i2c slaves without interrupts
2014-11-17 11:43 [PATCH] i2c: core: Fix probing of i2c slaves without interrupts Geert Uytterhoeven
2014-11-17 17:08 ` Fabio Estevam
@ 2014-11-26 0:22 ` Laurent Pinchart
1 sibling, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2014-11-26 0:22 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Laurent Pinchart, Wolfram Sang, linux-i2c, devicetree,
linux-kernel, linux-sh
Hi Geert,
On Monday 17 November 2014 12:43:00 Geert Uytterhoeven wrote:
> Since commit 2fd36c55264926e2 ("i2c: core: Map OF IRQ at probe time"),
> i2c slaves without interrupts (e.g. da9210 and at24 on r8a7791/koelsch)
> fail to probe:
>
> at24: probe of 2-0050 failed with error -22
>
> da9210: probe of 6-0068 failed with error -22
>
> This happens because the call to of_irq_get() in i2c_device_probe()
> returns -EINVAL.
>
> If a device node does not have an "interrupts" property,
> of_irq_parse_one() fails. Unlike irq_of_parse_and_map(), of_irq_get()
> does not ignore errors from of_irq_parse_one(), but forwards them.
>
> Make i2c_device_probe() ignore all errors but -EPROBE_DEFER to fix this,
> just like platform_get_irq() and platform_get_irq_byname() already do.
Thank you for fixing my mistake.
> Fixes: 2fd36c55264926e2 ("i2c: core: Map OF IRQ at probe time")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Just for the record, even if it's too late,
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/i2c/i2c-core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index a0768d6dffc28aae..cf830915713b387a 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -629,8 +629,10 @@ static int i2c_device_probe(struct device *dev)
> if (!client->irq && dev->of_node) {
> int irq = of_irq_get(dev->of_node, 0);
>
> - if (irq < 0)
> + if (irq == -EPROBE_DEFER)
> return irq;
> + if (irq < 0)
> + irq = 0;
>
> client->irq = irq;
> }
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-26 0:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-17 11:43 [PATCH] i2c: core: Fix probing of i2c slaves without interrupts Geert Uytterhoeven
2014-11-17 17:08 ` Fabio Estevam
2014-11-17 18:12 ` Wolfram Sang
2014-11-26 0:22 ` Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).