Skip to contentSkip to conversation

of/irq: fix guards and dummies for OF=y and OF_IRQ=n

PATCH In review Jonas Gorski 2 participants 5 messages Oct 12, 2015 – Oct 13, 2015 1 message not in the archive Device tree

lore
Share & tools
lore
#0 lore raw

v2 cover of/irq: fix guards and dummies for OF=y and OF_IRQ=n

Historically OF was only selectable by arch code, which usually also used IRQ_DOMAIN, thus making OF_IRQ and OF interchangeable for !SPARC.

Since OF is now a user selectable symbol, it is now easy to create a situation where OF=y and OF_IRQ=n, by not enabling IRQ_DOMAIN on e.g. x86.

This causes linking errors as for a few functions the prototype guard was OF, which is too broad and does not catch all combinations. Recently added of_msi_configure is even missing a dummy implementation.

The following three patches fix these issues by moving of_msi_configure to under the right guard and add a dummy implementation, make of_irq_find_parent static as there are no external users, and make the guard for irq_of_parse_and_map more specific.

Based on robh/linux.git#for-next, as the tree from MAINTAINERS haven't been updated for a while. I hope that is the right git to use.

Changes v1 -> v2:
* merge the of_msi_configure into one patch
* make of_irq_find_parent static and remove the prototype/dummy
* rebased onto robh/linux.git#for-next

Jonas Gorski (3):
of/irq: move of_msi_configure to the right guard and add a dummy of/irq: make of_irq_find_parent static
of/irq: fix guards for irq_of_parse_and_map prototype

 drivers/of/irq.c       |  2 +-
 include/linux/of_irq.h | 15 ++++++---------
 2 files changed, 7 insertions(+), 10 deletions(-)
Signature · 5 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

PATCH v2 1/3 of/irq: move of_msi_configure to the right guard and add a dummy

In reply to a message not in the archive

of_msi_configure is part of of_irq.c, which is compiled in when OF_IRQ is enabled, not just OF.
Also It is unconditionally called from of_platform_device_create_pdata, which does not depend on OF_IRQ, just OF_ADDRESS, so we need a dummy implementation in case of OF_ADDRESS=y but OF_IRQ=n.

Fixes c706c239 ("of/platform: Assign MSI domain to platform device")

---
v1 -> v2:
* fix both issues (guard and missing dummy) at once.

 include/linux/of_irq.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
include/linux/of_irq.h +4 -1
index 4bcbd58..0088038 100644
@@ -46,6 +46,7 @@ extern int of_irq_get(struct device_node *dev, int index);
 extern int of_irq_get_byname(struct device_node *dev, const char *name);
 extern int of_irq_to_resource_table(struct device_node *dev,
 		struct resource *res, int nr_irqs);
+extern void of_msi_configure(struct device *dev, struct device_node *np);
 #else
 static inline int of_irq_count(struct device_node *dev)
 {
@@ -64,6 +65,9 @@ static inline int of_irq_to_resource_table(struct device_node *dev,
 {
 	return 0;
 }
+static inline void of_msi_configure(struct device *dev, struct device_node *np)
+{
+}
 #endif
 
 #if defined(CONFIG_OF)
@@ -74,7 +78,6 @@ static inline int of_irq_to_resource_table(struct device_node *dev,
  */
 extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
 extern struct device_node *of_irq_find_parent(struct device_node *child);
-extern void of_msi_configure(struct device *dev, struct device_node *np);
 
 #else /* !CONFIG_OF */
 static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
Signature · 5 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

PATCH v2 2/3 of/irq: make of_irq_find_parent static

In reply to a message not in the archive

of_irq_find_parent has no users outside of of_irq.c, so it does not make sense to expose it in of_irq.h. Therefore remove the prototype and dummy implmeentation and make the function static instead.

---
v1 -> v2:
* just drop the prototype and the dummy and make it static

 drivers/of/irq.c       | 2 +-
 include/linux/of_irq.h | 6 ------
 2 files changed, 1 insertion(+), 7 deletions(-)
drivers/of/irq.c +1 -1
index 55317fa..0c7f4cb 100644
@@ -53,7 +53,7 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
  * Returns a pointer to the interrupt parent node, or NULL if the interrupt
  * parent could not be determined.
  */
-struct device_node *of_irq_find_parent(struct device_node *child)
+static struct device_node *of_irq_find_parent(struct device_node *child)
 {
 	struct device_node *p;
 	const __be32 *parp;
include/linux/of_irq.h +0 -6
index 0088038..a58e2e5 100644
@@ -77,7 +77,6 @@ static inline void of_msi_configure(struct device *dev, struct device_node *np)
  * so declare it here regardless of the CONFIG_OF_IRQ setting.
  */
 extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
-extern struct device_node *of_irq_find_parent(struct device_node *child);
 
 #else /* !CONFIG_OF */
 static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
@@ -85,11 +84,6 @@ static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
 {
 	return 0;
 }
-
-static inline void *of_irq_find_parent(struct device_node *child)
-{
-	return NULL;
-}
 #endif /* !CONFIG_OF */
 
 #endif /* __OF_IRQ_H */
Signature · 5 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

PATCH v2 3/3 of/irq: fix guards for irq_of_parse_and_map prototype

In reply to a message not in the archive

Since OF is now a userselectable config symbol, having OF=y but OF_IRQ=n is a valid combination for non-OF platforms, and OF=y does not guarantee anymore that OF_IRQ is enabled (or we are building for SPARC).

Fixes the following build error with OF=y, IRQ_DOMAIN=n and SPI=y:

drivers/built-in.o: In function `spi_register_master':
(.text+0xc3ae): undefined reference to `irq_of_parse_and_map' Makefile:935: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

---
v1 -> v2:
* no changes

 include/linux/of_irq.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/of_irq.h +2 -2
index a58e2e5..580818d 100644
@@ -70,7 +70,7 @@ static inline void of_msi_configure(struct device *dev, struct device_node *np)
 }
 #endif
 
-#if defined(CONFIG_OF)
+#if defined(CONFIG_OF_IRQ) || defined(CONFIG_SPARC)
 /*
  * irq_of_parse_and_map() is used by all OF enabled platforms; but SPARC
  * implements it differently.  However, the prototype is the same for all,
@@ -78,7 +78,7 @@ static inline void of_msi_configure(struct device *dev, struct device_node *np)
  */
 extern unsigned int irq_of_parse_and_map(struct device_node *node, int index);
 
-#else /* !CONFIG_OF */
+#else /* !CONFIG_OF && !CONFIG_SPARC */
 static inline unsigned int irq_of_parse_and_map(struct device_node *dev,
 						int index)
 {
Signature · 5 lines
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
In reply to a message not in the archive
Quoted 24 lines · Jonas Gorski

Historically OF was only selectable by arch code, which usually also used IRQ_DOMAIN, thus making OF_IRQ and OF interchangeable for !SPARC.

Since OF is now a user selectable symbol, it is now easy to create a situation where OF=y and OF_IRQ=n, by not enabling IRQ_DOMAIN on e.g. x86.

This causes linking errors as for a few functions the prototype guard was OF, which is too broad and does not catch all combinations. Recently added of_msi_configure is even missing a dummy implementation.

The following three patches fix these issues by moving of_msi_configure to under the right guard and add a dummy implementation, make of_irq_find_parent static as there are no external users, and make the guard for irq_of_parse_and_map more specific.

Based on robh/linux.git#for-next, as the tree from MAINTAINERS haven't been updated for a while. I hope that is the right git to use.

Changes v1 -> v2:
* merge the of_msi_configure into one patch
* make of_irq_find_parent static and remove the prototype/dummy
* rebased onto robh/linux.git#for-next

Quoted 8 lines

Jonas Gorski (3):
of/irq: move of_msi_configure to the right guard and add a dummy of/irq: make of_irq_find_parent static
of/irq: fix guards for irq_of_parse_and_map prototype

 drivers/of/irq.c       |  2 +-
 include/linux/of_irq.h | 15 ++++++---------
 2 files changed, 7 insertions(+), 10 deletions(-)

Series applied, thanks.

Rob

Quoted 3 lines

--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html