linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c-gpio: OF gpio code does not handle defered probe case
@ 2014-03-13 14:37 Ben Dooks
       [not found] ` <1394721458-23585-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Dooks @ 2014-03-13 14:37 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, Wolfram Sang,
	Haavard Skinnemoen, Ben Dooks

When using device-tree and the i2c-gpio driver is called before the
GPIO node has been probed then it needs to correctly defer the probe
instead of returning a permanent error that the gpio numbers are not
valid.

This fixes the following error:
	/i2c@2: invalid GPIO pins, sda=-517/scl=-517

Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
---
 drivers/i2c/busses/i2c-gpio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index d9f7e18..02d2d4a 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -94,6 +94,9 @@ static int of_i2c_gpio_get_pins(struct device_node *np,
 	*sda_pin = of_get_gpio(np, 0);
 	*scl_pin = of_get_gpio(np, 1);
 
+	if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+
 	if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) {
 		pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n",
 		       np->full_name, *sda_pin, *scl_pin);
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] i2c-gpio: OF gpio code does not handle defered probe case
       [not found] ` <1394721458-23585-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
@ 2014-03-13 21:17   ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2014-03-13 21:17 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-81qHHgoATdFT9dQujB1mzip2UmYkHbXO, Haavard Skinnemoen

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]

On Thu, Mar 13, 2014 at 02:37:38PM +0000, Ben Dooks wrote:
> When using device-tree and the i2c-gpio driver is called before the
> GPIO node has been probed then it needs to correctly defer the probe
> instead of returning a permanent error that the gpio numbers are not
> valid.
> 
> This fixes the following error:
> 	/i2c@2: invalid GPIO pins, sda=-517/scl=-517
> 
> Signed-off-by: Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>

Applied to for-next, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-13 21:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-13 14:37 [PATCH] i2c-gpio: OF gpio code does not handle defered probe case Ben Dooks
     [not found] ` <1394721458-23585-1-git-send-email-ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
2014-03-13 21:17   ` Wolfram Sang

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).