All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Rob Herring <rob.herring@calxeda.com>,
	Grant Likely <grant.likely@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Russell King <linux@arm.linux.org.uk>,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-mips@linux-mips.org, linuxppc-dev@lists.ozlabs.org,
	sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 09/10] of/i2c: Resolve interrupt references at probe time
Date: Wed, 18 Sep 2013 15:24:51 +0200	[thread overview]
Message-ID: <1379510692-32435-10-git-send-email-treding@nvidia.com> (raw)
In-Reply-To: <1379510692-32435-1-git-send-email-treding@nvidia.com>

Instead of resolving interrupt references at device creation time, delay
resolution until probe time. At device creation time, there is nothing
that can be done if an interrupt parent isn't ready yet, and the device
will end up with an invalid interrupt number (0).

If the interrupt reference is resolved at probe time, the device's probe
can be deferred, so that it's interrupt resolution can be retried after
more devices (possibly including its interrupt parent) have been probed.

However, individual drivers shouldn't be required to do that themselves,
over and over again, so this commit implements this functionality within
the I2C core.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Changes in v2:
- use __irq_of_parse_and_map() instead of of_irq_get()

 drivers/i2c/i2c-core.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 29d3f04..5b4f289 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -236,6 +236,22 @@ int i2c_recover_bus(struct i2c_adapter *adap)
 	return adap->bus_recovery_info->recover_bus(adap);
 }
 
+static int of_i2c_probe(struct i2c_client *client)
+{
+	struct device_node *np = client->dev.of_node;
+	int ret;
+
+	/* skip if the device node specifies no interrupts */
+	if (of_get_property(np, "interrupts", NULL)) {
+		ret = __irq_of_parse_and_map(client->dev.of_node, 0,
+					     &client->irq);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
 static int i2c_device_probe(struct device *dev)
 {
 	struct i2c_client	*client = i2c_verify_client(dev);
@@ -254,6 +270,12 @@ static int i2c_device_probe(struct device *dev)
 					client->flags & I2C_CLIENT_WAKE);
 	dev_dbg(dev, "probe\n");
 
+	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
+		status = of_i2c_probe(client);
+		if (status)
+			return status;
+	}
+
 	status = driver->probe(client, i2c_match_id(driver->id_table, client));
 	if (status) {
 		client->driver = NULL;
@@ -1002,7 +1024,6 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 			continue;
 		}
 
-		info.irq = irq_of_parse_and_map(node, 0);
 		info.of_node = of_node_get(node);
 		info.archdata = &dev_ad;
 
@@ -1016,7 +1037,6 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 			dev_err(&adap->dev, "of_i2c: Failure registering %s\n",
 				node->full_name);
 			of_node_put(node);
-			irq_dispose_mapping(info.irq);
 			continue;
 		}
 	}
-- 
1.8.4


WARNING: multiple messages have this Message-ID (diff)
From: Thierry Reding <thierry.reding@gmail.com>
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 09/10] of/i2c: Resolve interrupt references at probe time
Date: Wed, 18 Sep 2013 13:24:51 +0000	[thread overview]
Message-ID: <1379510692-32435-10-git-send-email-treding@nvidia.com> (raw)
In-Reply-To: <1379510692-32435-1-git-send-email-treding@nvidia.com>

Instead of resolving interrupt references at device creation time, delay
resolution until probe time. At device creation time, there is nothing
that can be done if an interrupt parent isn't ready yet, and the device
will end up with an invalid interrupt number (0).

If the interrupt reference is resolved at probe time, the device's probe
can be deferred, so that it's interrupt resolution can be retried after
more devices (possibly including its interrupt parent) have been probed.

However, individual drivers shouldn't be required to do that themselves,
over and over again, so this commit implements this functionality within
the I2C core.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Changes in v2:
- use __irq_of_parse_and_map() instead of of_irq_get()

 drivers/i2c/i2c-core.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 29d3f04..5b4f289 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -236,6 +236,22 @@ int i2c_recover_bus(struct i2c_adapter *adap)
 	return adap->bus_recovery_info->recover_bus(adap);
 }
 
+static int of_i2c_probe(struct i2c_client *client)
+{
+	struct device_node *np = client->dev.of_node;
+	int ret;
+
+	/* skip if the device node specifies no interrupts */
+	if (of_get_property(np, "interrupts", NULL)) {
+		ret = __irq_of_parse_and_map(client->dev.of_node, 0,
+					     &client->irq);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
 static int i2c_device_probe(struct device *dev)
 {
 	struct i2c_client	*client = i2c_verify_client(dev);
@@ -254,6 +270,12 @@ static int i2c_device_probe(struct device *dev)
 					client->flags & I2C_CLIENT_WAKE);
 	dev_dbg(dev, "probe\n");
 
+	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
+		status = of_i2c_probe(client);
+		if (status)
+			return status;
+	}
+
 	status = driver->probe(client, i2c_match_id(driver->id_table, client));
 	if (status) {
 		client->driver = NULL;
@@ -1002,7 +1024,6 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 			continue;
 		}
 
-		info.irq = irq_of_parse_and_map(node, 0);
 		info.of_node = of_node_get(node);
 		info.archdata = &dev_ad;
 
@@ -1016,7 +1037,6 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 			dev_err(&adap->dev, "of_i2c: Failure registering %s\n",
 				node->full_name);
 			of_node_put(node);
-			irq_dispose_mapping(info.irq);
 			continue;
 		}
 	}
-- 
1.8.4


WARNING: multiple messages have this Message-ID (diff)
From: Thierry Reding <thierry.reding@gmail.com>
To: Rob Herring <rob.herring@calxeda.com>,
	Grant Likely <grant.likely@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: linux-mips@linux-mips.org, Russell King <linux@arm.linux.org.uk>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ralf Baechle <ralf@linux-mips.org>,
	sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 09/10] of/i2c: Resolve interrupt references at probe time
Date: Wed, 18 Sep 2013 15:24:51 +0200	[thread overview]
Message-ID: <1379510692-32435-10-git-send-email-treding@nvidia.com> (raw)
In-Reply-To: <1379510692-32435-1-git-send-email-treding@nvidia.com>

Instead of resolving interrupt references at device creation time, delay
resolution until probe time. At device creation time, there is nothing
that can be done if an interrupt parent isn't ready yet, and the device
will end up with an invalid interrupt number (0).

If the interrupt reference is resolved at probe time, the device's probe
can be deferred, so that it's interrupt resolution can be retried after
more devices (possibly including its interrupt parent) have been probed.

However, individual drivers shouldn't be required to do that themselves,
over and over again, so this commit implements this functionality within
the I2C core.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Changes in v2:
- use __irq_of_parse_and_map() instead of of_irq_get()

 drivers/i2c/i2c-core.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 29d3f04..5b4f289 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -236,6 +236,22 @@ int i2c_recover_bus(struct i2c_adapter *adap)
 	return adap->bus_recovery_info->recover_bus(adap);
 }
 
+static int of_i2c_probe(struct i2c_client *client)
+{
+	struct device_node *np = client->dev.of_node;
+	int ret;
+
+	/* skip if the device node specifies no interrupts */
+	if (of_get_property(np, "interrupts", NULL)) {
+		ret = __irq_of_parse_and_map(client->dev.of_node, 0,
+					     &client->irq);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
 static int i2c_device_probe(struct device *dev)
 {
 	struct i2c_client	*client = i2c_verify_client(dev);
@@ -254,6 +270,12 @@ static int i2c_device_probe(struct device *dev)
 					client->flags & I2C_CLIENT_WAKE);
 	dev_dbg(dev, "probe\n");
 
+	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
+		status = of_i2c_probe(client);
+		if (status)
+			return status;
+	}
+
 	status = driver->probe(client, i2c_match_id(driver->id_table, client));
 	if (status) {
 		client->driver = NULL;
@@ -1002,7 +1024,6 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 			continue;
 		}
 
-		info.irq = irq_of_parse_and_map(node, 0);
 		info.of_node = of_node_get(node);
 		info.archdata = &dev_ad;
 
@@ -1016,7 +1037,6 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 			dev_err(&adap->dev, "of_i2c: Failure registering %s\n",
 				node->full_name);
 			of_node_put(node);
-			irq_dispose_mapping(info.irq);
 			continue;
 		}
 	}
-- 
1.8.4

WARNING: multiple messages have this Message-ID (diff)
From: thierry.reding@gmail.com (Thierry Reding)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 09/10] of/i2c: Resolve interrupt references at probe time
Date: Wed, 18 Sep 2013 15:24:51 +0200	[thread overview]
Message-ID: <1379510692-32435-10-git-send-email-treding@nvidia.com> (raw)
In-Reply-To: <1379510692-32435-1-git-send-email-treding@nvidia.com>

Instead of resolving interrupt references at device creation time, delay
resolution until probe time. At device creation time, there is nothing
that can be done if an interrupt parent isn't ready yet, and the device
will end up with an invalid interrupt number (0).

If the interrupt reference is resolved at probe time, the device's probe
can be deferred, so that it's interrupt resolution can be retried after
more devices (possibly including its interrupt parent) have been probed.

However, individual drivers shouldn't be required to do that themselves,
over and over again, so this commit implements this functionality within
the I2C core.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
Changes in v2:
- use __irq_of_parse_and_map() instead of of_irq_get()

 drivers/i2c/i2c-core.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 29d3f04..5b4f289 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -236,6 +236,22 @@ int i2c_recover_bus(struct i2c_adapter *adap)
 	return adap->bus_recovery_info->recover_bus(adap);
 }
 
+static int of_i2c_probe(struct i2c_client *client)
+{
+	struct device_node *np = client->dev.of_node;
+	int ret;
+
+	/* skip if the device node specifies no interrupts */
+	if (of_get_property(np, "interrupts", NULL)) {
+		ret = __irq_of_parse_and_map(client->dev.of_node, 0,
+					     &client->irq);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
 static int i2c_device_probe(struct device *dev)
 {
 	struct i2c_client	*client = i2c_verify_client(dev);
@@ -254,6 +270,12 @@ static int i2c_device_probe(struct device *dev)
 					client->flags & I2C_CLIENT_WAKE);
 	dev_dbg(dev, "probe\n");
 
+	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
+		status = of_i2c_probe(client);
+		if (status)
+			return status;
+	}
+
 	status = driver->probe(client, i2c_match_id(driver->id_table, client));
 	if (status) {
 		client->driver = NULL;
@@ -1002,7 +1024,6 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 			continue;
 		}
 
-		info.irq = irq_of_parse_and_map(node, 0);
 		info.of_node = of_node_get(node);
 		info.archdata = &dev_ad;
 
@@ -1016,7 +1037,6 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
 			dev_err(&adap->dev, "of_i2c: Failure registering %s\n",
 				node->full_name);
 			of_node_put(node);
-			irq_dispose_mapping(info.irq);
 			continue;
 		}
 	}
-- 
1.8.4

  parent reply	other threads:[~2013-09-18 13:26 UTC|newest]

Thread overview: 121+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-18 13:24 [PATCH v2 00/10] of/irq: Defer interrupt reference resolution Thierry Reding
2013-09-18 13:24 ` Thierry Reding
2013-09-18 13:24 ` Thierry Reding
2013-09-18 13:24 ` Thierry Reding
2013-09-18 13:24 ` [PATCH v2 01/10] of/irq: Rework of_irq_count() Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-22 21:19   ` Rob Herring
2013-09-22 21:19     ` Rob Herring
2013-09-22 21:19     ` Rob Herring
2013-09-22 21:19     ` Rob Herring
2013-09-22 21:19     ` Rob Herring
2013-09-22 21:19     ` Rob Herring
2013-10-15 22:42     ` Grant Likely
2013-10-15 22:42       ` Grant Likely
2013-10-15 22:42       ` Grant Likely
2013-10-15 22:42       ` Grant Likely
2013-10-15 22:42       ` Grant Likely
2013-10-15 22:55     ` Grant Likely
2013-10-15 22:55       ` Grant Likely
2013-10-15 22:55       ` Grant Likely
2013-10-15 22:55       ` Grant Likely
2013-10-15 22:55       ` Grant Likely
2013-09-18 13:24 ` [PATCH v2 02/10] of/irq: Use irq_of_parse_and_map() Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-22 21:17   ` Rob Herring
2013-09-22 21:17     ` Rob Herring
2013-09-22 21:17     ` Rob Herring
2013-09-22 21:17     ` Rob Herring
2013-09-22 21:17     ` Rob Herring
2013-09-22 21:17     ` Rob Herring
2013-09-18 13:24 ` [PATCH v2 03/10] irqdomain: Introduce __irq_create_mapping() Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24 ` [PATCH v2 04/10] irqdomain: Return errors from irq_create_of_mapping() Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 14:23   ` Ralf Baechle
2013-09-18 14:23     ` Ralf Baechle
2013-09-18 14:23     ` Ralf Baechle
2013-09-18 14:23     ` Ralf Baechle
2013-09-18 14:23     ` Ralf Baechle
2013-09-22 21:14   ` Rob Herring
2013-09-22 21:14     ` Rob Herring
2013-09-22 21:14     ` Rob Herring
2013-09-22 21:14     ` Rob Herring
2013-09-22 21:14     ` Rob Herring
2013-09-23  8:13     ` Thierry Reding
2013-09-23  8:13       ` Thierry Reding
2013-09-23  8:13       ` Thierry Reding
2013-09-23  8:13       ` Thierry Reding
2013-09-23  8:13       ` Thierry Reding
2013-10-15 23:01       ` Grant Likely
2013-10-15 23:01         ` Grant Likely
2013-10-15 23:01         ` Grant Likely
2013-10-15 23:01         ` Grant Likely
2013-10-15 23:01         ` Grant Likely
2013-09-18 13:24 ` [PATCH v2 05/10] of/irq: Introduce __irq_of_parse_and_map() Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24 ` [PATCH v2 06/10] of/irq: Return errors from of_irq_to_resource() Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24 ` [PATCH v2 07/10] of/irq: Propagate errors in of_irq_to_resource_table() Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 14:23   ` Ralf Baechle
2013-09-18 14:23     ` Ralf Baechle
2013-09-18 14:23     ` Ralf Baechle
2013-09-18 14:23     ` Ralf Baechle
2013-09-18 14:23     ` Ralf Baechle
2013-09-22 21:08   ` Rob Herring
2013-09-22 21:08     ` Rob Herring
2013-09-22 21:08     ` Rob Herring
2013-09-22 21:08     ` Rob Herring
2013-09-22 21:08     ` Rob Herring
2013-09-22 21:08     ` Rob Herring
2013-09-23  8:36     ` Thierry Reding
2013-09-23  8:36       ` Thierry Reding
2013-09-23  8:36       ` Thierry Reding
2013-09-23  8:36       ` Thierry Reding
2013-09-23  8:36       ` Thierry Reding
2013-09-18 13:24 ` [PATCH v2 08/10] of/platform: Resolve interrupt references at probe time Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-10-15 23:24   ` Grant Likely
2013-10-15 23:24     ` Grant Likely
2013-10-15 23:24     ` Grant Likely
2013-10-15 23:24     ` Grant Likely
2013-10-16  8:20     ` Thierry Reding
2013-10-16  8:20       ` Thierry Reding
2013-10-16  8:20       ` Thierry Reding
2013-10-16  8:20       ` Thierry Reding
2013-10-24 16:37     ` Grant Likely
2013-10-24 16:37       ` Grant Likely
2013-10-24 16:37       ` Grant Likely
2013-10-24 16:37       ` Grant Likely
2013-10-24 16:37       ` Grant Likely
2013-10-25  7:35       ` Thierry Reding
2013-10-25  7:35         ` Thierry Reding
2013-10-25  7:35         ` Thierry Reding
2013-10-25  7:35         ` Thierry Reding
2013-09-18 13:24 ` Thierry Reding [this message]
2013-09-18 13:24   ` [PATCH v2 09/10] of/i2c: " Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24 ` [PATCH v2 10/10] gpio: tegra: Use module_platform_driver() Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding
2013-09-18 13:24   ` Thierry Reding

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=1379510692-32435-10-git-send-email-treding@nvidia.com \
    --to=thierry.reding@gmail.com \
    --cc=benh@kernel.crashing.org \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux@arm.linux.org.uk \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=ralf@linux-mips.org \
    --cc=rob.herring@calxeda.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.