mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: LEROY Christophe <christophe.leroy@c-s.fr>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Vitaly Bordug <vitb@kernel.crashing.org>,
	Marcelo Tosatti <marcelo@kvack.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	<linuxppc-dev@lists.ozlabs.org>, <linux-kernel@vger.kernel.org>
Subject: Re: Handling of IRQ in MPC8xx GPIO
Date: Tue, 4 Jun 2013 16:59:46 -0500	[thread overview]
Message-ID: <20130604215946.GA21467@home.buserror.net> (raw)
In-Reply-To: <201302211632.r1LGWaRr025445@localhost.localdomain>

On Thu, Feb 21, 2013 at 06:32:36AM -0000, LEROY Christophe wrote:
> This patch allows the use IRQ to notify the change of GPIO status on the MPC8xx
> CPM IO ports. This then allows to associate IRQs to GPIOs in the Device Tree. Ex:
> 	CPM1_PIO_C: gpio-controller@960 {
> 		#gpio-cells = <2>;
> 		compatible = "fsl,cpm1-pario-bank-c";
> 		reg = <0x960 0x10>;
> 		interrupts = <255 255 255 255 1 2 6 9 10 11 14 15 23 24 26 31>;
> 		interrupt-parent = <&CPM_PIC>;
> 		gpio-controller;
> 	};
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
[snip]
> @@ -581,6 +588,30 @@
>  	spin_unlock_irqrestore(&cpm1_gc->lock, flags);
>  }
>  
> +static int __cpm1_gpio16_to_irq(struct of_mm_gpio_chip *mm_gc,
> +		unsigned int gpio)
> +{
> +	struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc);
> +
> +	return cpm1_gc->irq[gpio] ? cpm1_gc->irq[gpio] : -ENXIO;
> +}

If it's an internal function, why not just pass in cpm1_gc?

Or just open-code it, as it's a one-liner and you don't use it anywhere
else.

Or fix the gpio layer to use 0 to mean "no irq" rather than -ENXIO... :-)

> diff -ur linux-3.7.9/kernel/irq/irqdomain.c linux/kernel/irq/irqdomain.c
> --- linux-3.7.9/kernel/irq/irqdomain.c	2013-02-17 19:53:32.000000000 +0100
> +++ linux/kernel/irq/irqdomain.c	2012-12-13 19:52:38.000000000 +0100
> @@ -763,7 +763,8 @@
>  	BUG_ON(domain->revmap_type != IRQ_DOMAIN_MAP_LINEAR);
>  
>  	/* Check revmap bounds; complain if exceeded */
> -	if (WARN_ON(hwirq >= domain->revmap_data.linear.size))
> +	/* 255 is a trick to allow UNDEF value in DTS */
> +	if (hwirq == 255 || WARN_ON(hwirq >= domain->revmap_data.linear.size))
>  		return 0;

NACK.  Besides the hackishness of it, 255 is valid for some interrupt
controllers.

If you need for a way to leave holes in an "interrupts" property, propose
something non-hacky on devicetree-discuss@lists.ozlabs.org.

Or, do what some other devices do, and have a different property that
indicates which pins are connected, and only include those in the
"interrupts" property.  See
Documentation/devicetree/bindings/powerpc/fsl/mpic-msgr.txt and
mpic-msgr-receive-mask as an example.

-Scott


      reply	other threads:[~2013-06-04 22:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-21 16:32 [PATCH] " Christophe Leroy
2013-06-04 21:59 ` Scott Wood [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=20130604215946.GA21467@home.buserror.net \
    --to=scottwood@freescale.com \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=marcelo@kvack.org \
    --cc=paulus@samba.org \
    --cc=tglx@linutronix.de \
    --cc=vitb@kernel.crashing.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

all inboxes | Powered by JetHome®