Skip to contentSkip to conversation

: sparc: Implement irq_of_parse_and_map() and irq_dispose_mapping().

PATCH In review David Miller 2 participants 3 messages Aug 21, 2008 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

PATCH 1/3 : sparc: Implement irq_of_parse_and_map() and irq_dispose_mapping().

sparc: Implement irq_of_parse_and_map() and irq_dispose_mapping().

This allows more OF layer code to be shared between powerpc and sparc.

---
 arch/sparc/include/asm/prom.h   |    8 ++++++++
 arch/sparc/kernel/of_device.c   |   11 +++++++++++
 arch/sparc64/kernel/of_device.c |   11 +++++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)
arch/sparc/include/asm/prom.h +8 -0
index b5efc4d..58b85fa 100644
@@ -96,6 +96,14 @@ static inline void of_node_put(struct device_node *node)
 {
 }
 
+/* These routines are here to provide compatibility with how powerpc
+ * handles IRQ mapping for OF device nodes.  We precompute and permanently
+ * register them in the of_device objects, whereas powerpc computes them
+ * on request.
+ */
+extern int irq_of_parse_and_map(struct device_node *node, int index);
+#define irq_dispose_mapping(irq) do { } while (0)
+
 /*
  * NB:  This is here while we transition from using asm/prom.h
  * to linux/of.h
arch/sparc/kernel/of_device.c +11 -0
index cc4c235..56e9a71 100644
@@ -29,6 +29,17 @@ struct of_device *of_find_device_by_node(struct device_node *dp)
 }
 EXPORT_SYMBOL(of_find_device_by_node);
 
+int irq_of_parse_and_map(struct device_node *node, int index)
+{
+	struct of_device *op = of_find_device_by_node(node);
+
+	if (!op || index >= op->num_irqs)
+		return 0xffffffff;
+
+	return op->irqs[index];
+}
+EXPORT_SYMBOL(irq_of_parse_and_map);
+
 #ifdef CONFIG_PCI
 struct bus_type ebus_bus_type;
 EXPORT_SYMBOL(ebus_bus_type);
arch/sparc64/kernel/of_device.c +11 -0
index f8b50cb..8a0d823 100644
@@ -55,6 +55,17 @@ struct of_device *of_find_device_by_node(struct device_node *dp)
 }
 EXPORT_SYMBOL(of_find_device_by_node);
 
+int irq_of_parse_and_map(struct device_node *node, int index)
+{
+	struct of_device *op = of_find_device_by_node(node);
+
+	if (!op || index >= op->num_irqs)
+		return 0xffffffff;
+
+	return op->irqs[index];
+}
+EXPORT_SYMBOL(irq_of_parse_and_map);
+
 #ifdef CONFIG_PCI
 struct bus_type ebus_bus_type;
 EXPORT_SYMBOL(ebus_bus_type);
Signature · 1 line
1.5.6.5.GIT
#1 lore raw
Quoted 18 lines · David Miller

sparc: Implement irq_of_parse_and_map() and irq_dispose_mapping().

This allows more OF layer code to be shared between powerpc and sparc.

---
 arch/sparc/include/asm/prom.h   |    8 ++++++++
 arch/sparc/kernel/of_device.c   |   11 +++++++++++
 arch/sparc64/kernel/of_device.c |   11 +++++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)
arch/sparc/include/asm/prom.h +0 -0
index b5efc4d..58b85fa 100644

arch/sparc/include/asm/prom.h static inline void of_node_put(struct device_node *node) · line 104

Quoted 9 lines
arch/sparc/include/asm/prom.h +6 -0
@@ -96,6 +96,14 @@ static inline void of_node_put(struct device_node *node)
 {
 }
 
+/* These routines are here to provide compatibility with how powerpc
+ * handles IRQ mapping for OF device nodes.  We precompute and permanently
+ * register them in the of_device objects, whereas powerpc computes them
+ * on request.
+ */
+extern int irq_of_parse_and_map(struct device_node *node, int index);

On powerpc irq_of_parse_and_map() returns unsigned type.

arch/sparc/include/asm/prom.h static inline void of_node_put(struct device_node *node) · line 105

Quoted 1 line
arch/sparc/include/asm/prom.h +1 -0
+#define irq_dispose_mapping(irq) do { } while (0)

I'd rather write it as a static inline function, for type checking, plus, I think with this macros gcc may generate warnings about defined but unused variables.

Quoted 9 lines
arch/sparc/include/asm/prom.h +1 -0
+
 /*
  * NB:  This is here while we transition from using asm/prom.h
  * to linux/of.h
arch/sparc/kernel/of_device.c +0 -0
index cc4c235..56e9a71 100644

arch/sparc/kernel/of_device.c struct of_device *of_find_device_by_node(struct device_node *dp) · line 37

Quoted 9 lines
arch/sparc/kernel/of_device.c +6 -0
@@ -29,6 +29,17 @@ struct of_device *of_find_device_by_node(struct device_node *dp)
 }
 EXPORT_SYMBOL(of_find_device_by_node);
 
+int irq_of_parse_and_map(struct device_node *node, int index)
+{
+	struct of_device *op = of_find_device_by_node(node);
+
+	if (!op || index >= op->num_irqs)
+		return 0xffffffff;

This is valid virq, unfortunately. There is only one invalid virq: 0. With this most drivers will fail to identify 'there is no irq' case. Does virq0 has special meaning on sparc?

Thanks,

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
author maintainer
#2 lore raw

From: Anton Vorontsov <[email protected]>
Date: Fri, 22 Aug 2008 01:56:11 +0400

Quoted 14 lines · David Miller

arch/sparc/include/asm/prom.h static inline void of_node_put(struct device_node *node) · line 104

Quoted 10 lines
arch/sparc/include/asm/prom.h +6 -0
@@ -96,6 +96,14 @@ static inline void of_node_put(struct device_node *node)
 {
 }
 
+/* These routines are here to provide compatibility with how powerpc
+ * handles IRQ mapping for OF device nodes.  We precompute and permanently
+ * register them in the of_device objects, whereas powerpc computes them
+ * on request.
+ */
+extern int irq_of_parse_and_map(struct device_node *node, int index);

On powerpc irq_of_parse_and_map() returns unsigned type.

Quoted 5 lines

arch/sparc/include/asm/prom.h static inline void of_node_put(struct device_node *node) · line 105

Quoted 1 line
arch/sparc/include/asm/prom.h +1 -0
+#define irq_dispose_mapping(irq) do { } while (0)

I'd rather write it as a static inline function, for type checking, plus, I think with this macros gcc may generate warnings about defined but unused variables.

Thanks, I'll fix that.

Quoted 12 lines
Quoted 12 lines
arch/sparc/include/asm/prom.h +1 -0
+
 /*
  * NB:  This is here while we transition from using asm/prom.h
  * to linux/of.h
arch/sparc/kernel/of_device.c +0 -0
index cc4c235..56e9a71 100644
@@ -29,6 +29,17 @@ struct of_device *of_find_device_by_node(struct device_node *dp)
 }
 EXPORT_SYMBOL(of_find_device_by_node);
 
Quoted 10 lines

arch/sparc/kernel/of_device.c struct of_device *of_find_device_by_node(struct device_node *dp) · line 37

Quoted 6 lines
arch/sparc/kernel/of_device.c +6 -0
+int irq_of_parse_and_map(struct device_node *node, int index)
+{
+	struct of_device *op = of_find_device_by_node(node);
+
+	if (!op || index >= op->num_irqs)
+		return 0xffffffff;

This is valid virq, unfortunately. There is only one invalid virq: 0. With this most drivers will fail to identify 'there is no irq' case. Does virq0 has special meaning on sparc?

No, I'll fix this up, thanks.