Skip to contentSkip to conversation

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

PATCH Superseded Jonas Gorski 2 participants 6 messages Sep 7, 2015 – Sep 17, 2015 3 messages not in the archive Device tree

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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 shuffling the prototypes and dummy implementations around (adding one where necessary), and make the guard for irq_of_parse_and_map more specific.

Based on devicetree/next.

Jonas Gorski (3):
of/irq: add a dummy of_msi_configure if OF_IRQ=n of/irq: fix guards of of_irq_find_parent and of_msi_configure of/irq: fix guards for irq_of_parse_and_map prototype

 include/linux/of_irq.h | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 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 1/3 of/irq: add a dummy of_msi_configure if OF_IRQ=n

In reply to a message not in the archive

It is unconditionally called from of_platform_device_create_pdata, which does not depend on OF_IRQ, just OF_ADDRESS.

Fixes c706c239 ("of/platform: Assign MSI domain to platform device")
---
 include/linux/of_irq.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/of_irq.h +4 -0
index d884929..7b81771 100644
@@ -86,6 +86,10 @@ static inline void *of_irq_find_parent(struct device_node *child)
 {
 	return NULL;
 }
+
+static inline void of_msi_configure(struct device *dev, struct device_node *np)
+{
+}
 #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
#5 lore raw

PATCH 2/3 of/irq: fix guards of of_irq_find_parent and of_msi_configure

In reply to a message not in the archive

Only irq_of_parse_and_map is implemented differently on SPARC, so only that one should be protected by the CONFIG_OF guard.

---
 include/linux/of_irq.h | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
include/linux/of_irq.h +9 -10
index 7b81771..d6a6d2e 100644
@@ -46,6 +46,8 @@ 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 struct device_node *of_irq_find_parent(struct device_node *child);
+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 +66,13 @@ static inline int of_irq_to_resource_table(struct device_node *dev,
 {
 	return 0;
 }
+static inline void *of_irq_find_parent(struct device_node *child)
+{
+	return NULL;
+}
+static inline void of_msi_configure(struct device *dev, struct device_node *np)
+{
+}
 #endif
 
 #if defined(CONFIG_OF)
@@ -73,7 +82,6 @@ static inline int of_irq_to_resource_table(struct device_node *dev,
  * 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,
@@ -81,15 +89,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;
-}
-
-static inline void of_msi_configure(struct device *dev, struct device_node *np)
-{
-}
 #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
#8 lore raw

PATCH 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

---
 include/linux/of_irq.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/of_irq.h +2 -2
index d6a6d2e..3f92bf6 100644
@@ -75,7 +75,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,
@@ -83,7 +83,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
#4 lore raw

Re: [PATCH 1/3] of/irq: add a dummy of_msi_configure if OF_IRQ=n

In reply to a message not in the archive
Quoted 14 lines · Jonas Gorski

It is unconditionally called from of_platform_device_create_pdata, which does not depend on OF_IRQ, just OF_ADDRESS.

Fixes c706c239 ("of/platform: Assign MSI domain to platform device")
---
 include/linux/of_irq.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/of_irq.h +0 -0
index d884929..7b81771 100644

include/linux/of_irq.h static inline void *of_irq_find_parent(struct device_node *child) · line 92

Quoted 7 lines
include/linux/of_irq.h +4 -0
@@ -86,6 +86,10 @@ static inline void *of_irq_find_parent(struct device_node *child)
 {
        return NULL;
 }
+
+static inline void of_msi_configure(struct device *dev, struct device_node *np)
+{
+}

Why do you add it here and then move it in patch #2? Just do this in 1 patch.

Rob

Quoted 5 lines
include/linux/of_irq.h +0 -1
 #endif /* !CONFIG_OF */
 
 #endif /* __OF_IRQ_H */
--

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

#7 lore raw

Re: [PATCH 2/3] of/irq: fix guards of of_irq_find_parent and of_msi_configure

In reply to a message not in the archive
Quoted 2 lines · Jonas Gorski

Only irq_of_parse_and_map is implemented differently on SPARC, so only that one should be protected by the CONFIG_OF guard.

of_irq_find_parent is only used by of_irq.c, so just make it static.

Rob

Quoted 58 lines
---
 include/linux/of_irq.h | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
include/linux/of_irq.h +9 -11
index 7b81771..d6a6d2e 100644
@@ -46,6 +46,8 @@ 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 struct device_node *of_irq_find_parent(struct device_node *child);
+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 +66,13 @@ static inline int of_irq_to_resource_table(struct device_node *dev,
 {
        return 0;
 }
+static inline void *of_irq_find_parent(struct device_node *child)
+{
+       return NULL;
+}
+static inline void of_msi_configure(struct device *dev, struct device_node *np)
+{
+}
 #endif
 
 #if defined(CONFIG_OF)
@@ -73,7 +82,6 @@ static inline int of_irq_to_resource_table(struct device_node *dev,
  * 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,
@@ -81,15 +89,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;
-}
-
-static inline void of_msi_configure(struct device *dev, struct device_node *np)
-{
-}
 #endif /* !CONFIG_OF */
 
 #endif /* __OF_IRQ_H */
--
Quoted 1 line

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