All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] cpm2_pic: Allow correct flow_types for port C interrupts
@ 2009-12-09  0:48 Mark Ware
  2009-12-09 20:43 ` Kumar Gala
  2009-12-09 21:53 ` Anton Vorontsov
  0 siblings, 2 replies; 5+ messages in thread
From: Mark Ware @ 2009-12-09  0:48 UTC (permalink / raw)
  To: Linuxppc-dev Development; +Cc: Scott Wood

Port C interrupts can be either falling edge, or either edge.
Other external interrupts are either falling edge or active low.

Signed-Off-By: Mark Ware <mware@elphinstone.net>
---
Changed in v2:
- Disallow rising edge only on Port C 

 arch/powerpc/sysdev/cpm2_pic.c |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/sysdev/cpm2_pic.c b/arch/powerpc/sysdev/cpm2_pic.c
index 78f1f7c..eba5f24 100644
--- a/arch/powerpc/sysdev/cpm2_pic.c
+++ b/arch/powerpc/sysdev/cpm2_pic.c
@@ -141,13 +141,29 @@ static int cpm2_set_irq_type(unsigned int virq, unsigned int flow_type)
 	struct irq_desc *desc = get_irq_desc(virq);
 	unsigned int vold, vnew, edibit;
 
-	if (flow_type == IRQ_TYPE_NONE)
-		flow_type = IRQ_TYPE_LEVEL_LOW;
-
-	if (flow_type & IRQ_TYPE_EDGE_RISING) {
-		printk(KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n",
-			flow_type);
-		return -EINVAL;
+	/* Port C interrupts are either IRQ_TYPE_EDGE_FALLING or
+	 * IRQ_TYPE_EDGE_BOTH (default).  All others are IRQ_TYPE_EDGE_FALLING
+	 * or IRQ_TYPE_LEVEL_LOW (default)
+	 */
+	if (src >= CPM2_IRQ_PORTC15 && src <= CPM2_IRQ_PORTC0) {
+		if (flow_type == IRQ_TYPE_NONE)
+			flow_type = IRQ_TYPE_EDGE_BOTH;
+
+		if ((flow_type != IRQ_TYPE_EDGE_BOTH) && 
+			(flow_type != IRQ_TYPE_EDGE_FALLING)) {
+			printk(KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n",
+				flow_type);
+			return -EINVAL;
+		}
+	} else {
+		if (flow_type == IRQ_TYPE_NONE)
+			flow_type = IRQ_TYPE_LEVEL_LOW;
+
+		if (flow_type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH)) {
+			printk(KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n",
+				flow_type);
+			return -EINVAL;
+		}
 	}
 
 	desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] cpm2_pic: Allow correct flow_types for port C interrupts
  2009-12-09  0:48 [PATCH v2] cpm2_pic: Allow correct flow_types for port C interrupts Mark Ware
@ 2009-12-09 20:43 ` Kumar Gala
  2009-12-09 21:53 ` Anton Vorontsov
  1 sibling, 0 replies; 5+ messages in thread
From: Kumar Gala @ 2009-12-09 20:43 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Scott Wood, Linuxppc-dev Development, Mark Ware


On Dec 8, 2009, at 6:48 PM, Mark Ware wrote:

> Port C interrupts can be either falling edge, or either edge.
> Other external interrupts are either falling edge or active low.
>=20
> Signed-Off-By: Mark Ware <mware@elphinstone.net>
> ---
> Changed in v2:
> - Disallow rising edge only on Port C=20
>=20
> arch/powerpc/sysdev/cpm2_pic.c |   30 +++++++++++++++++++++++-------
> 1 files changed, 23 insertions(+), 7 deletions(-)

Anton, mind taking a look at this for me.

- k

>=20
> diff --git a/arch/powerpc/sysdev/cpm2_pic.c =
b/arch/powerpc/sysdev/cpm2_pic.c
> index 78f1f7c..eba5f24 100644
> --- a/arch/powerpc/sysdev/cpm2_pic.c
> +++ b/arch/powerpc/sysdev/cpm2_pic.c
> @@ -141,13 +141,29 @@ static int cpm2_set_irq_type(unsigned int virq, =
unsigned int flow_type)
> 	struct irq_desc *desc =3D get_irq_desc(virq);
> 	unsigned int vold, vnew, edibit;
>=20
> -	if (flow_type =3D=3D IRQ_TYPE_NONE)
> -		flow_type =3D IRQ_TYPE_LEVEL_LOW;
> -
> -	if (flow_type & IRQ_TYPE_EDGE_RISING) {
> -		printk(KERN_ERR "CPM2 PIC: sense type 0x%x not =
supported\n",
> -			flow_type);
> -		return -EINVAL;
> +	/* Port C interrupts are either IRQ_TYPE_EDGE_FALLING or
> +	 * IRQ_TYPE_EDGE_BOTH (default).  All others are =
IRQ_TYPE_EDGE_FALLING
> +	 * or IRQ_TYPE_LEVEL_LOW (default)
> +	 */
> +	if (src >=3D CPM2_IRQ_PORTC15 && src <=3D CPM2_IRQ_PORTC0) {
> +		if (flow_type =3D=3D IRQ_TYPE_NONE)
> +			flow_type =3D IRQ_TYPE_EDGE_BOTH;
> +
> +		if ((flow_type !=3D IRQ_TYPE_EDGE_BOTH) &&=20
> +			(flow_type !=3D IRQ_TYPE_EDGE_FALLING)) {
> +			printk(KERN_ERR "CPM2 PIC: sense type 0x%x not =
supported\n",
> +				flow_type);
> +			return -EINVAL;
> +		}
> +	} else {
> +		if (flow_type =3D=3D IRQ_TYPE_NONE)
> +			flow_type =3D IRQ_TYPE_LEVEL_LOW;
> +
> +		if (flow_type & (IRQ_TYPE_EDGE_RISING | =
IRQ_TYPE_LEVEL_HIGH)) {
> +			printk(KERN_ERR "CPM2 PIC: sense type 0x%x not =
supported\n",
> +				flow_type);
> +			return -EINVAL;
> +		}
> 	}
>=20
> 	desc->status &=3D ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
> --=20
> 1.5.6.5

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] cpm2_pic: Allow correct flow_types for port C interrupts
  2009-12-09  0:48 [PATCH v2] cpm2_pic: Allow correct flow_types for port C interrupts Mark Ware
  2009-12-09 20:43 ` Kumar Gala
@ 2009-12-09 21:53 ` Anton Vorontsov
  2009-12-09 21:57   ` Scott Wood
  1 sibling, 1 reply; 5+ messages in thread
From: Anton Vorontsov @ 2009-12-09 21:53 UTC (permalink / raw)
  To: Mark Ware; +Cc: Scott Wood, Linuxppc-dev Development

On Wed, Dec 09, 2009 at 11:48:41AM +1100, Mark Ware wrote:
> Port C interrupts can be either falling edge, or either edge.
> Other external interrupts are either falling edge or active low.
> 
> Signed-Off-By: Mark Ware <mware@elphinstone.net>

Looks correct (checked with 8272 and 8555 specs).

Reviewed-by: Anton Vorontsov <avorontsov@ru.mvista.com>


Cosmetic nitpicks below. I tend to think they don't desire
another resend, but I couldn't resist making them anyway. ;-)

[...]
> +	if (src >= CPM2_IRQ_PORTC15 && src <= CPM2_IRQ_PORTC0) {
> +		if (flow_type == IRQ_TYPE_NONE)
> +			flow_type = IRQ_TYPE_EDGE_BOTH;
> +
> +		if ((flow_type != IRQ_TYPE_EDGE_BOTH) && 
> +			(flow_type != IRQ_TYPE_EDGE_FALLING)) {

I'd place one more tab here. And parenthesis aren't actually needed.

> +			printk(KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n",
> +				flow_type);
> +			return -EINVAL;
> +		}
> +	} else {
> +		if (flow_type == IRQ_TYPE_NONE)
> +			flow_type = IRQ_TYPE_LEVEL_LOW;
> +
> +		if (flow_type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH)) {
> +			printk(KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n",
> +				flow_type);

pr_err is shorter. Also, this message is duplicated. Would be better
to do something like:

	if (somethingwrong)
		goto err_sense;
	...
	return 0;

err_sense:
	pr_err("CPM2 PIC: sense type 0x%x not supported\n", flow_type);
	return -EINVAL;
}

Or we may don't print any errors at all. For internal interrupts
we don't print them anyway, i.e. the current code has just

	return (flow_type & IRQ_TYPE_LEVEL_LOW) ? 0 : -EINVAL;

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] cpm2_pic: Allow correct flow_types for port C interrupts
  2009-12-09 21:53 ` Anton Vorontsov
@ 2009-12-09 21:57   ` Scott Wood
  2009-12-10 11:10     ` Mark Ware
  0 siblings, 1 reply; 5+ messages in thread
From: Scott Wood @ 2009-12-09 21:57 UTC (permalink / raw)
  To: avorontsov; +Cc: Linuxppc-dev Development, Mark Ware

Anton Vorontsov wrote:
>> +		if ((flow_type != IRQ_TYPE_EDGE_BOTH) && 
>> +			(flow_type != IRQ_TYPE_EDGE_FALLING)) {
> 
> I'd place one more tab here.

Or better, align one "flow_type" with the other.

-Scott

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] cpm2_pic: Allow correct flow_types for port C interrupts
  2009-12-09 21:57   ` Scott Wood
@ 2009-12-10 11:10     ` Mark Ware
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Ware @ 2009-12-10 11:10 UTC (permalink / raw)
  To: Scott Wood; +Cc: Linuxppc-dev Development, avorontsov

Scott Wood wrote:
> Anton Vorontsov wrote:
>>> +        if ((flow_type != IRQ_TYPE_EDGE_BOTH) && +           
>>> (flow_type != IRQ_TYPE_EDGE_FALLING)) {
>>
>> I'd place one more tab here.
> 
> Or better, align one "flow_type" with the other.
> 
> -Scott
> 

Thanks Anton and Scott.

Scott's suggestion is also my preferred style, but a (brief) search through the source didn't reveal much support.

I'll send a new version shortly including you suggestions.

- Mark

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-12-10 11:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-09  0:48 [PATCH v2] cpm2_pic: Allow correct flow_types for port C interrupts Mark Ware
2009-12-09 20:43 ` Kumar Gala
2009-12-09 21:53 ` Anton Vorontsov
2009-12-09 21:57   ` Scott Wood
2009-12-10 11:10     ` Mark Ware

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.