From: Yinghai Lu <yinghai@kernel.org>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: linux-kernel@vger.kernel.org, Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH 08/10] genericirq: add set_irq_desc_chip/data ...
Date: Sun, 21 Mar 2010 18:36:08 -0700 [thread overview]
Message-ID: <1269221770-9667-9-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1269221770-9667-1-git-send-email-yinghai@kernel.org>
with set_irq_chip/data...
to take desc instead of irq
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
arch/x86/kernel/apic/io_apic.c | 4 +-
include/linux/irq.h | 10 +++-
include/linux/irqnr.h | 1 +
kernel/irq/chip.c | 127 +++++++++++++++++++++++-----------------
4 files changed, 85 insertions(+), 57 deletions(-)
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index f908af5..432bea1 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3302,7 +3302,7 @@ unsigned int create_irq_nr(unsigned int irq_want, int node)
raw_spin_unlock_irqrestore(&vector_lock, flags);
if (irq > 0)
- dynamic_irq_init_keep_chip_data(irq);
+ dynamic_irq_init_keep_chip_data(irq_to_desc(irq));
return irq;
}
@@ -3328,7 +3328,7 @@ void destroy_irq(unsigned int irq)
struct irq_desc *desc;
struct irq_cfg *cfg;
- dynamic_irq_cleanup_keep_chip_data(irq);
+ dynamic_irq_cleanup_keep_chip_data(irq_to_desc(irq));
free_irte(irq);
raw_spin_lock_irqsave(&vector_lock, flags);
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 36ea6ac..1f5d112 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -420,9 +420,9 @@ static inline int irq_has_action(unsigned int irq)
/* Dynamic irq helper functions */
extern void dynamic_irq_init(unsigned int irq);
-void dynamic_irq_init_keep_chip_data(unsigned int irq);
+void dynamic_irq_init_keep_chip_data(struct irq_desc *desc);
extern void dynamic_irq_cleanup(unsigned int irq);
-void dynamic_irq_cleanup_keep_chip_data(unsigned int irq);
+void dynamic_irq_cleanup_keep_chip_data(struct irq_desc *desc);
/* Set/get chip/data for an IRQ: */
extern int set_irq_chip(unsigned int irq, struct irq_chip *chip);
@@ -431,6 +431,12 @@ extern int set_irq_chip_data(unsigned int irq, void *data);
extern int set_irq_type(unsigned int irq, unsigned int type);
extern int set_irq_msi(unsigned int irq, struct msi_desc *entry);
+int set_irq_desc_chip(struct irq_desc *desc, struct irq_chip *chip);
+int set_irq_desc_data(struct irq_desc *desc, void *data);
+int set_irq_desc_chip_data(struct irq_desc *desc, void *data);
+int set_irq_desc_type(struct irq_desc *desc, unsigned int type);
+int set_irq_desc_msi(struct irq_desc *desc, struct msi_desc *entry);
+
#define get_irq_chip(irq) (irq_to_desc(irq)->chip)
#define get_irq_chip_data(irq) (irq_to_desc(irq)->chip_data)
#define get_irq_data(irq) (irq_to_desc(irq)->handler_data)
diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index 7bf89bc..dee8f2b 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -43,6 +43,7 @@ extern struct irq_desc *irq_to_desc(unsigned int irq);
#ifdef CONFIG_SMP
#define irq_node(irq) (irq_to_desc(irq)->node)
+#define irq_desc_node(desc) ((desc)->node)
#else
#define irq_node(irq) 0
#endif
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 190360d..6725334 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -18,17 +18,10 @@
#include "internals.h"
-static void dynamic_irq_init_x(unsigned int irq, bool keep_chip_data)
+static void dynamic_irq_init_x(struct irq_desc *desc, bool keep_chip_data)
{
- struct irq_desc *desc;
unsigned long flags;
- desc = irq_to_desc(irq);
- if (!desc) {
- WARN(1, KERN_ERR "Trying to initialize invalid IRQ%d\n", irq);
- return;
- }
-
/* Ensure we don't have left over values from a previous use of this irq */
raw_spin_lock_irqsave(&desc->lock, flags);
desc->status = IRQ_DISABLED;
@@ -57,7 +50,15 @@ static void dynamic_irq_init_x(unsigned int irq, bool keep_chip_data)
*/
void dynamic_irq_init(unsigned int irq)
{
- dynamic_irq_init_x(irq, false);
+ struct irq_desc *desc;
+
+ desc = irq_to_desc(irq);
+ if (!desc) {
+ WARN(1, KERN_ERR "Trying to initialize invalid IRQ%d\n", irq);
+ return;
+ }
+
+ dynamic_irq_init_x(desc, false);
}
/**
@@ -66,26 +67,20 @@ void dynamic_irq_init(unsigned int irq)
*
* does not set irq_to_desc(irq)->chip_data to NULL
*/
-void dynamic_irq_init_keep_chip_data(unsigned int irq)
+void dynamic_irq_init_keep_chip_data(struct irq_desc *desc)
{
- dynamic_irq_init_x(irq, true);
+ dynamic_irq_init_x(desc, true);
}
-static void dynamic_irq_cleanup_x(unsigned int irq, bool keep_chip_data)
+static void dynamic_irq_cleanup_x(struct irq_desc *desc, bool keep_chip_data)
{
- struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags;
- if (!desc) {
- WARN(1, KERN_ERR "Trying to cleanup invalid IRQ%d\n", irq);
- return;
- }
-
raw_spin_lock_irqsave(&desc->lock, flags);
if (desc->action) {
raw_spin_unlock_irqrestore(&desc->lock, flags);
WARN(1, KERN_ERR "Destroying IRQ%d without calling free_irq\n",
- irq);
+ desc->irq);
return;
}
desc->msi_desc = NULL;
@@ -105,7 +100,14 @@ static void dynamic_irq_cleanup_x(unsigned int irq, bool keep_chip_data)
*/
void dynamic_irq_cleanup(unsigned int irq)
{
- dynamic_irq_cleanup_x(irq, false);
+ struct irq_desc *desc = irq_to_desc(irq);
+
+ if (!desc) {
+ WARN(1, KERN_ERR "Trying to cleanup invalid IRQ%d\n", irq);
+ return;
+ }
+
+ dynamic_irq_cleanup_x(desc, false);
}
/**
@@ -114,9 +116,9 @@ void dynamic_irq_cleanup(unsigned int irq)
*
* does not set irq_to_desc(irq)->chip_data to NULL
*/
-void dynamic_irq_cleanup_keep_chip_data(unsigned int irq)
+void dynamic_irq_cleanup_keep_chip_data(struct irq_desc *desc)
{
- dynamic_irq_cleanup_x(irq, true);
+ dynamic_irq_cleanup_x(desc, true);
}
@@ -152,26 +154,31 @@ EXPORT_SYMBOL(set_irq_chip);
* @irq: irq number
* @type: IRQ_TYPE_{LEVEL,EDGE}_* value - see include/linux/irq.h
*/
-int set_irq_type(unsigned int irq, unsigned int type)
+int set_irq_desc_type(struct irq_desc *desc, unsigned int type)
{
- struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags;
int ret = -ENXIO;
- if (!desc) {
- printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq);
- return -ENODEV;
- }
-
type &= IRQ_TYPE_SENSE_MASK;
if (type == IRQ_TYPE_NONE)
return 0;
raw_spin_lock_irqsave(&desc->lock, flags);
- ret = __irq_set_trigger(desc, irq, type);
+ ret = __irq_set_trigger(desc, desc->irq, type);
raw_spin_unlock_irqrestore(&desc->lock, flags);
return ret;
}
+int set_irq_type(unsigned int irq, unsigned int type)
+{
+ struct irq_desc *desc = irq_to_desc(irq);
+
+ if (!desc) {
+ printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq);
+ return -ENODEV;
+ }
+
+ return set_irq_desc_type(desc, type);
+}
EXPORT_SYMBOL(set_irq_type);
/**
@@ -181,10 +188,18 @@ EXPORT_SYMBOL(set_irq_type);
*
* Set the hardware irq controller data for an irq
*/
+int set_irq_desc_data(struct irq_desc *desc, void *data)
+{
+ unsigned long flags;
+
+ raw_spin_lock_irqsave(&desc->lock, flags);
+ desc->handler_data = data;
+ raw_spin_unlock_irqrestore(&desc->lock, flags);
+ return 0;
+}
int set_irq_data(unsigned int irq, void *data)
{
struct irq_desc *desc = irq_to_desc(irq);
- unsigned long flags;
if (!desc) {
printk(KERN_ERR
@@ -192,10 +207,7 @@ int set_irq_data(unsigned int irq, void *data)
return -EINVAL;
}
- raw_spin_lock_irqsave(&desc->lock, flags);
- desc->handler_data = data;
- raw_spin_unlock_irqrestore(&desc->lock, flags);
- return 0;
+ return set_irq_desc_data(desc, data);
}
EXPORT_SYMBOL(set_irq_data);
@@ -206,24 +218,28 @@ EXPORT_SYMBOL(set_irq_data);
*
* Set the MSI descriptor entry for an irq
*/
-int set_irq_msi(unsigned int irq, struct msi_desc *entry)
+int set_irq_desc_msi(struct irq_desc *desc, struct msi_desc *entry)
{
- struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags;
- if (!desc) {
- printk(KERN_ERR
- "Trying to install msi data for IRQ%d\n", irq);
- return -EINVAL;
- }
-
raw_spin_lock_irqsave(&desc->lock, flags);
desc->msi_desc = entry;
if (entry)
- entry->irq = irq;
+ entry->irq = desc->irq;
raw_spin_unlock_irqrestore(&desc->lock, flags);
return 0;
}
+int set_irq_msi(unsigned int irq, struct msi_desc *entry)
+{
+ struct irq_desc *desc = irq_to_desc(irq);
+ if (!desc) {
+ printk(KERN_ERR
+ "Trying to install msi data for IRQ%d\n", desc->irq);
+ return -EINVAL;
+ }
+
+ return set_irq_desc_msi(desc, entry);
+}
/**
* set_irq_chip_data - set irq chip data for an irq
@@ -232,19 +248,12 @@ int set_irq_msi(unsigned int irq, struct msi_desc *entry)
*
* Set the hardware irq chip data for an irq
*/
-int set_irq_chip_data(unsigned int irq, void *data)
+int set_irq_desc_chip_data(struct irq_desc *desc, void *data)
{
- struct irq_desc *desc = irq_to_desc(irq);
unsigned long flags;
- if (!desc) {
- printk(KERN_ERR
- "Trying to install chip data for IRQ%d\n", irq);
- return -EINVAL;
- }
-
if (!desc->chip) {
- printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq);
+ printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", desc->irq);
return -EINVAL;
}
@@ -254,6 +263,18 @@ int set_irq_chip_data(unsigned int irq, void *data)
return 0;
}
+int set_irq_chip_data(unsigned int irq, void *data)
+{
+ struct irq_desc *desc = irq_to_desc(irq);
+
+ if (!desc) {
+ printk(KERN_ERR
+ "Trying to install chip data for IRQ%d\n", irq);
+ return -EINVAL;
+ }
+
+ return set_irq_desc_chip_data(desc, data);
+}
EXPORT_SYMBOL(set_irq_chip_data);
/**
--
1.6.4.2
next prev parent reply other threads:[~2010-03-22 1:39 UTC|newest]
Thread overview: 93+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-22 1:36 [PATCH 00/10] x86/irq Yinghai Lu
2010-03-22 1:36 ` [PATCH 01/10] irq: move some interrupt arch_* functions into struct irq_chip Yinghai Lu
2010-03-22 1:56 ` Michael Ellerman
2010-03-22 3:32 ` Yinghai Lu
2010-03-23 7:10 ` Paul Mundt
2010-03-24 13:33 ` Ian Campbell
2010-03-22 10:19 ` Thomas Gleixner
2010-03-24 13:32 ` Ian Campbell
2010-03-24 17:44 ` Thomas Gleixner
2010-03-24 19:16 ` Ian Campbell
2010-03-24 21:25 ` Thomas Gleixner
2010-03-22 1:36 ` [PATCH 02/10] x86: fix out of order of gsi - full Yinghai Lu
2010-03-22 11:14 ` Thomas Gleixner
2010-03-22 19:45 ` Yinghai Lu
2010-03-29 13:40 ` Eric W. Biederman
2010-03-29 17:57 ` H. Peter Anvin
2010-03-29 23:19 ` [PATCH 0/14] Start coping gsis < 16 that are not isa irqs Eric W. Biederman
2010-03-29 23:20 ` [PATCH 01/14] x86 acpi/irq: Introduce apci_isa_irq_to_gsi Eric W. Biederman
2010-03-29 23:20 ` [PATCH 02/14] x86 acpi/irq: Teach acpi_get_override_irq to take a gsi not an isa_irq Eric W. Biederman
2010-03-29 23:20 ` [PATCH 03/14] x86 acpi/irq: pci device dev->irq is an isa irq not a gsi Eric W. Biederman
2010-03-29 23:20 ` [PATCH 04/14] x86 acpi/irq: Fix acpi_sci_ioapic_setup so it has both bus_irq and gsi Eric W. Biederman
2010-03-29 23:20 ` [PATCH 05/14] x86 acpi/irq: Generalize mp_config_acpi_legacy_irqs Eric W. Biederman
2010-03-29 23:20 ` [PATCH 06/14] x86 ioapic: Only export mp_find_ioapic and mp_find_ioapic_pin in io_apic.h Eric W. Biederman
2010-03-29 23:20 ` [PATCH 07/14] x86 ioapic: Fix the types of gsi values Eric W. Biederman
2010-03-29 23:20 ` [PATCH 08/14] x86 ioapic: Teach mp_register_ioapic to compute a global gsi_end Eric W. Biederman
2010-03-29 23:20 ` [PATCH 09/14] x86 ioapic: In mpparse use mp_register_ioapic Eric W. Biederman
2010-03-29 23:20 ` [PATCH 10/14] x86 ioapic: Move nr_ioapic_registers calculation to mp_register_ioapic Eric W. Biederman
2010-03-29 23:20 ` [PATCH 11/14] x86 ioapic: Optimize pin_2_irq Eric W. Biederman
2010-03-29 23:20 ` [PATCH 12/14] x86 ioapic: Simplify probe_nr_irqs_gsi Eric W. Biederman
2010-03-30 2:16 ` Yinghai Lu
2010-03-30 4:43 ` Eric W. Biederman
2010-03-30 4:55 ` Yinghai Lu
2010-03-30 5:41 ` Eric W. Biederman
2010-03-29 23:20 ` [PATCH 13/14] x86 acpi/irq: Handle isa irqs that are not identity mapped to gsi's Eric W. Biederman
2010-03-29 23:20 ` [PATCH 14/14] x86 irq: Kill io_apic_renumber_irq Eric W. Biederman
2010-03-30 8:06 ` [PATCH 0/15] Start coping gsis < 16 that are not isa irqs. v2 Eric W. Biederman
2010-03-30 8:07 ` [PATCH 01/15] x86 acpi/irq: Introduce apci_isa_irq_to_gsi Eric W. Biederman
2010-05-05 2:06 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 02/15] x86 acpi/irq: Teach acpi_get_override_irq to take a gsi not an isa_irq Eric W. Biederman
2010-05-05 2:07 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 03/15] x86 acpi/irq: pci device dev->irq is an isa irq not a gsi Eric W. Biederman
2010-05-05 2:07 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 04/15] x86 acpi/irq: Fix acpi_sci_ioapic_setup so it has both bus_irq and gsi Eric W. Biederman
2010-05-05 2:07 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 05/15] x86 acpi/irq: Generalize mp_config_acpi_legacy_irqs Eric W. Biederman
2010-05-05 2:07 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 06/15] x86 ioapic: Only export mp_find_ioapic and mp_find_ioapic_pin in io_apic.h Eric W. Biederman
2010-05-05 2:08 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 07/15] x86 ioapic: Fix io_apic_redir_entries to return the number of entries Eric W. Biederman
2010-05-05 2:08 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 08/15] x86 ioapic: Fix the types of gsi values Eric W. Biederman
2010-05-05 2:08 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 09/15] x86 ioapic: Teach mp_register_ioapic to compute a global gsi_end Eric W. Biederman
2010-05-05 2:09 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 10/15] x86 ioapic: In mpparse use mp_register_ioapic Eric W. Biederman
2010-05-05 2:09 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 11/15] x86 ioapic: Move nr_ioapic_registers calculation to mp_register_ioapic Eric W. Biederman
2010-05-05 2:09 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 12/15] x86 ioapic: Optimize pin_2_irq Eric W. Biederman
2010-05-05 2:09 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 13/15] x86 ioapic: Simplify probe_nr_irqs_gsi Eric W. Biederman
2010-05-05 2:10 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 14/15] x86 acpi/irq: Handle isa irqs that are not identity mapped to gsi's Eric W. Biederman
2010-05-05 2:10 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-05-05 7:49 ` Yinghai
2010-05-05 8:53 ` [PATCH] x86 acpi/irq: Fix harmless typo Eric W. Biederman
2010-05-05 8:58 ` Ingo Molnar
2010-05-05 9:32 ` [tip:x86/irq] x86, acpi/irq: Handle isa irqs that are not identity mapped to gsi's Eric W. Biederman
2010-06-07 21:05 ` H. Peter Anvin
2010-06-08 22:20 ` Yinghai Lu
2010-05-05 8:56 ` Ingo Molnar
2010-05-05 9:36 ` Eric Biederman
2010-05-05 10:05 ` Ingo Molnar
2010-05-05 20:22 ` [PATCH] x86 acpi/irq: Define gsi_end when X86_IO_APIC is undefined Eric W. Biederman
2010-05-06 6:18 ` Ingo Molnar
2010-05-06 10:07 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-03-30 8:07 ` [PATCH 15/15] x86 irq: Kill io_apic_renumber_irq Eric W. Biederman
2010-05-05 2:10 ` [tip:x86/irq] x86, " tip-bot for Eric W. Biederman
2010-05-03 23:21 ` [PATCH 0/15] Start coping gsis < 16 that are not isa irqs. v2 Eric W. Biederman
2010-04-01 2:02 ` [PATCH 0/14] Start coping gsis < 16 that are not isa irqs Len Brown
2010-04-01 3:31 ` Eric W. Biederman
2010-03-22 1:36 ` [PATCH 03/10] x86: set nr_irqs_gsi only in probe_nr_irqs_gsi Yinghai Lu
2010-03-22 1:36 ` [PATCH 04/10] x86: kill smpboot_hooks.h Yinghai Lu
2010-03-22 13:34 ` Thomas Gleixner
2010-03-22 1:36 ` [PATCH 05/10] x86: use vector_desc instead of vector_irq Yinghai Lu
2010-03-22 13:58 ` Thomas Gleixner
2010-03-22 14:04 ` Eric W. Biederman
2010-03-22 14:16 ` Thomas Gleixner
2010-03-22 1:36 ` [PATCH 06/10] irq: Start the transition of irq_chip methods taking a desc Yinghai Lu
2010-03-22 1:36 ` [PATCH 07/10] x86/irq: use irq_desc *desc with irq_chip Yinghai Lu
2010-03-22 1:36 ` Yinghai Lu [this message]
2010-03-22 1:36 ` [PATCH 09/10] x86/iommu/dmar: update iommu/inter_remapping to use desc Yinghai Lu
2010-03-22 1:36 ` [PATCH 10/10] x86: remove arch_probe_nr_irqs Yinghai Lu
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=1269221770-9667-9-git-send-email-yinghai@kernel.org \
--to=yinghai@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=hpa@zytor.com \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).