Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1240800
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 08/16] irqdomain: Add a fwnode_handle allocator |
| Date | 2015-10-06 19:40 +0200 |
| Message-ID | <qgEnz-4wt-65@gated-at.bofh.it> (permalink) |
| References | <qgEnv-4wt-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
In order to be able to reference an irqdomain from ACPI, we need
to be able to create an identifier, which is usually a struct
device_node.
This device node does't really fit the ACPI infrastructure, so
we cunningly allocate a new structure containing a fwnode_handle,
and return that.
This structure doesn't really point to a device (interrupt
controllers are not "real" devices in Linux), but as we cannot
really deny that they exist, we create them with a new fwnode_type
(FWNODE_IRQCHIP).
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
include/linux/fwnode.h | 1 +
include/linux/irqdomain.h | 2 ++
kernel/irq/irqdomain.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+)
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 0408545..37ec668 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -17,6 +17,7 @@ enum fwnode_type {
FWNODE_OF,
FWNODE_ACPI,
FWNODE_PDATA,
+ FWNODE_IRQCHIP,
};
struct fwnode_handle {
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 995d4c5..949caa7 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -188,6 +188,8 @@ static inline struct device_node *irq_domain_get_of_node(struct irq_domain *d)
}
#ifdef CONFIG_IRQ_DOMAIN
+struct fwnode_handle *irq_domain_alloc_fwnode(void *data);
+void irq_domain_free_fwnode(struct fwnode_handle *fwnode);
struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size,
irq_hw_number_t hwirq_max, int direct_max,
const struct irq_domain_ops *ops,
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index ea62f67..6fbecae 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -27,6 +27,57 @@ static int irq_domain_alloc_descs(int virq, unsigned int nr_irqs,
irq_hw_number_t hwirq, int node);
static void irq_domain_check_hierarchy(struct irq_domain *domain);
+struct irqchip_fwid {
+ struct fwnode_handle fwnode;
+ char *name;
+ void *data;
+};
+
+/**
+ * irq_domain_alloc_fwnode - Allocate a fwnode_handle suitable for
+ * identifying an irq domain
+ * @data: optional user-provided data
+ *
+ * Allocate a struct device_node, and return a poiner to the embedded
+ * fwnode_handle (or NULL on failure).
+ */
+struct fwnode_handle *irq_domain_alloc_fwnode(void *data)
+{
+ struct irqchip_fwid *fwid;
+ char *name;
+
+ fwid = kzalloc(sizeof(*fwid), GFP_KERNEL);
+ name = kasprintf(GFP_KERNEL, "irqchip@%p", data);
+
+ if (!fwid || !name) {
+ kfree(fwid);
+ kfree(name);
+ return NULL;
+ }
+
+ fwid->name = name;
+ fwid->data = data;
+ fwid->fwnode.type = FWNODE_IRQCHIP;
+ return &fwid->fwnode;
+}
+
+/**
+ * irq_domain_free_fwnode - Free a non-OF-backed fwnode_handle
+ *
+ * Free a fwnode_handle allocated with irq_domain_alloc_fwnode.
+ */
+void irq_domain_free_fwnode(struct fwnode_handle *fwnode)
+{
+ struct irqchip_fwid *fwid;
+
+ if (WARN_ON(fwnode->type != FWNODE_IRQCHIP))
+ return;
+
+ fwid = container_of(fwnode, struct irqchip_fwid, fwnode);
+ kfree(fwid->name);
+ kfree(fwid);
+}
+
/**
* __irq_domain_add() - Allocate a new irq_domain data structure
* @of_node: optional device-tree node of the interrupt controller
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/16] Divorcing irqdomain and device_node Marc Zyngier <marc.zyngier@arm.com> - 2015-10-06 19:40 +0200
[PATCH 12/16] irqchip/gic: Switch ACPI support to stacked domains Marc Zyngier <marc.zyngier@arm.com> - 2015-10-06 19:40 +0200
[PATCH 13/16] irqchip/gic: Kill the xlate method Marc Zyngier <marc.zyngier@arm.com> - 2015-10-06 19:40 +0200
[PATCH 08/16] irqdomain: Add a fwnode_handle allocator Marc Zyngier <marc.zyngier@arm.com> - 2015-10-06 19:40 +0200
Re: [PATCH 08/16] irqdomain: Add a fwnode_handle allocator "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-10-12 22:10 +0200
[PATCH 07/16] irqdomain: Introduce irq_domain_create_{linear,tree} Marc Zyngier <marc.zyngier@arm.com> - 2015-10-06 19:40 +0200
[PATCH 03/16] irqdomain: Allow irq domain lookup by fwnode Marc Zyngier <marc.zyngier@arm.com> - 2015-10-06 19:50 +0200
Re: [PATCH 03/16] irqdomain: Allow irq domain lookup by fwnode Marc Zyngier <marc.zyngier@arm.com> - 2015-10-13 09:40 +0200
[PATCH 05/16] irqchip: Convert all alloc/xlate users from of_node to fwnode Marc Zyngier <marc.zyngier@arm.com> - 2015-10-06 19:50 +0200
Re: [PATCH 05/16] irqchip: Convert all alloc/xlate users from of_node to fwnode Hanjun Guo <hanjun.guo@linaro.org> - 2015-10-12 08:50 +0200
[PATCH 06/16] irqdomain: Introduce irq_create_fwspec_mapping Marc Zyngier <marc.zyngier@arm.com> - 2015-10-06 19:50 +0200
[PATCH 01/16] irqdomain: Use an accessor for the of_node field Marc Zyngier <marc.zyngier@arm.com> - 2015-10-06 19:50 +0200
Re: [PATCH 01/16] irqdomain: Use an accessor for the of_node field Thomas Gleixner <tglx@linutronix.de> - 2015-10-09 16:30 +0200
Re: [PATCH 01/16] irqdomain: Use an accessor for the of_node field Marc Zyngier <marc.zyngier@arm.com> - 2015-10-09 16:40 +0200
Re: [PATCH 01/16] irqdomain: Use an accessor for the of_node field Hanjun Guo <hanjun.guo@linaro.org> - 2015-10-12 08:10 +0200
Re: [PATCH 01/16] irqdomain: Use an accessor for the of_node field Marc Zyngier <marc.zyngier@arm.com> - 2015-10-12 11:40 +0200
[PATCH 04/16] irqdomain: Introduce a firmware-specific IRQ specifier structure Marc Zyngier <marc.zyngier@arm.com> - 2015-10-06 19:50 +0200
Re: [PATCH 00/16] Divorcing irqdomain and device_node Thomas Gleixner <tglx@linutronix.de> - 2015-10-11 23:10 +0200
Re: [PATCH 00/16] Divorcing irqdomain and device_node Hanjun Guo <hanjun.guo@linaro.org> - 2015-10-12 04:50 +0200
Re: [PATCH 00/16] Divorcing irqdomain and device_node Hanjun Guo <hanjun.guo@linaro.org> - 2015-10-12 09:20 +0200
Re: [PATCH 00/16] Divorcing irqdomain and device_node Marc Zyngier <marc.zyngier@arm.com> - 2015-10-12 12:40 +0200
Re: [PATCH 00/16] Divorcing irqdomain and device_node "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-10-12 22:20 +0200
Re: [PATCH 00/16] Divorcing irqdomain and device_node Marc Zyngier <marc.zyngier@arm.com> - 2015-10-13 10:30 +0200
csiph-web