public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Mundt <lethal@linux-sh.org>
To: linux-arch@vger.kernel.org
Subject: Re: [PATCH] generic hardirq type setting
Date: Thu, 19 Jan 2006 03:32:57 +0200	[thread overview]
Message-ID: <20060119013257.GA18181@linux-sh.org> (raw)
In-Reply-To: <20060119011737.GA18038@linux-sh.org>

[-- Attachment #1: Type: text/plain, Size: 3585 bytes --]

On Thu, Jan 19, 2006 at 03:17:37AM +0200, Paul Mundt wrote:
> Now that Russell's SA_TRIGGER_* changes went in, I've been updating some
> of the SH code to support it. ARM supports a ->set_type() through its
> struct irqchip so doesn't have to deal with this, but this requires a bit
> more work for architectures that are using generic hardirqs.
> 
> I've added a ->set_type() to struct hw_interrupt_type to deal with this,
> which seems like the least invasive solution. dhowells made a note about
> handling and returning errors for invalid type configurations when
> Russell's initial patch was posted, so I've implemented this as well.
> 
And here's the right patch without the misplaced ).. Sorry for the noise.

---

 arch/sh/kernel/cpu/irq/pint.c |   19 +++++++++++++++++++
 include/linux/irq.h           |    1 +
 kernel/irq/manage.c           |   19 +++++++++++++++++--
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/arch/sh/kernel/cpu/irq/pint.c b/arch/sh/kernel/cpu/irq/pint.c
index 95d6024..ca4bb94 100644
--- a/arch/sh/kernel/cpu/irq/pint.c
+++ b/arch/sh/kernel/cpu/irq/pint.c
@@ -37,9 +37,28 @@ static unsigned int startup_pint_irq(uns
 	return 0; /* never anything pending */
 }
 
+static int set_type_pint_irq(unsigned int irq, unsigned int type)
+{
+	unsigned int val;
+
+	/* Only level detection is possible */
+	if (unlikely(!(type & (SA_TRIGGER_HIGH | SA_TRIGGER_LOW))))
+		return -EINVAL;
+
+	val = ctrl_inw(INTC_ICR2);
+	if (type & SA_TRIGGER_HIGH)
+		val |= (1 << (irq - PINT_IRQ_BASE));
+	else
+		val &= ~(1 << (irq - PINT_IRQ_BASE));
+	ctrl_outw(val, INTC_ICR2);
+
+	return 0;
+}
+
 static struct hw_interrupt_type pint_irq_type = {
 	.typename = "PINT-IRQ",
 	.startup = startup_pint_irq,
+	.set_type = set_type_pint_irq,
 	.shutdown = shutdown_pint_irq,
 	.enable = enable_pint_irq,
 	.disable = disable_pint_irq,
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 6c5d4c8..904cffa 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -53,6 +53,7 @@ struct hw_interrupt_type {
 	void (*ack)(unsigned int irq);
 	void (*end)(unsigned int irq);
 	void (*set_affinity)(unsigned int irq, cpumask_t dest);
+	int (*set_type)(unsigned int irq, unsigned int type);
 	/* Currently used only by UML, might disappear one day.*/
 #ifdef CONFIG_IRQ_RELEASE_METHOD
 	void (*release)(unsigned int irq, void *dev_id);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 97d5559..4ec7c9a 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -203,8 +203,12 @@ int setup_irq(unsigned int irq, struct i
 	spin_lock_irqsave(&desc->lock,flags);
 	p = &desc->action;
 	if ((old = *p) != NULL) {
-		/* Can't share interrupts unless both agree to */
-		if (!(old->flags & new->flags & SA_SHIRQ)) {
+		/*
+		 * Can't share interrupts unless both agree to and are
+		 * the same type.
+		 */
+		if (!(old->flags & new->flags & SA_SHIRQ) ||
+		    (~old->flags & new->flags) & SA_TRIGGER_MASK) {
 			spin_unlock_irqrestore(&desc->lock,flags);
 			return -EBUSY;
 		}
@@ -220,6 +224,17 @@ int setup_irq(unsigned int irq, struct i
 	*p = new;
 
 	if (!shared) {
+		if (desc->handler->set_type) {
+			unsigned int type = new->flags & SA_TRIGGER_MASK;
+			int ret;
+
+			ret = desc->handler->set_type(irq, type);
+			if (unlikely(ret != 0)) {
+				spin_unlock_irqrestore(&desc->lock, flags);
+				return ret;
+			}
+		}
+
 		desc->depth = 0;
 		desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT |
 				  IRQ_WAITING | IRQ_INPROGRESS);

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

      reply	other threads:[~2006-01-19  1:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-19  1:17 [PATCH] generic hardirq type setting Paul Mundt
2006-01-19  1:32 ` Paul Mundt [this message]

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=20060119013257.GA18181@linux-sh.org \
    --to=lethal@linux-sh.org \
    --cc=linux-arch@vger.kernel.org \
    /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