From patchwork Thu Nov 10 15:25:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 124906 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 354721007D1 for ; Fri, 11 Nov 2011 02:26:06 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935057Ab1KJPZr (ORCPT ); Thu, 10 Nov 2011 10:25:47 -0500 Received: from mail-ww0-f44.google.com ([74.125.82.44]:61738 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934229Ab1KJPZq (ORCPT ); Thu, 10 Nov 2011 10:25:46 -0500 Received: by wwh12 with SMTP id 12so2524243wwh.1 for ; Thu, 10 Nov 2011 07:25:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=9sy9pn94va5aMnMO6+i3LPtPndI+Fzq4JkhPmCwsmRY=; b=IYKOFjZd52EkoXB/pXfxTRGkHXbbAJzAXUJdNisKYskVUNggEgAiNWu3Bz7StqHNW5 LURD8ewTZ8+TD+m0qx3gRCPQm4P7QzziH1U9HNH9FJ3Hun/b61pTX7ikgM7ihPekkud6 rAnmmkjfIRZ8zHgNpvPY21YufYFUh5cpbIlI0= Received: by 10.227.60.85 with SMTP id o21mr4992186wbh.0.1320938744522; Thu, 10 Nov 2011 07:25:44 -0800 (PST) Received: from localhost (mail.dev.rtsoft.ru. [213.79.90.226]) by mx.google.com with ESMTPS id fi11sm9921410wbb.9.2011.11.10.07.25.42 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 Nov 2011 07:25:43 -0800 (PST) Date: Thu, 10 Nov 2011 19:25:41 +0400 From: Anton Vorontsov To: Ingo Molnar , Jeff Garzik , Grant Likely Cc: Randy Dunlap , Stephen Rothwell , linux-next@vger.kernel.org, LKML , linux-ide@vger.kernel.org, Linus Torvalds , Andrew Morton , devicetree-discuss@lists.ozlabs.org, Alan Cox Subject: [PATCH 1/2] of/irq: Get rid of NO_IRQ usage Message-ID: <20111110152541.GA3207@oksana.dev.rtsoft.ru> References: <20111110151852.GA7465@oksana.dev.rtsoft.ru> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20111110151852.GA7465@oksana.dev.rtsoft.ru> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org PPC32/64 defines NO_IRQ to zero, so no problems expected. ARM defines NO_IRQ to -1, but OF code relies on IRQ domains support, which returns correct ('0') value in 'no irq' case. So everything should be fine. Other arches might break if some of their OF drivers rely on NO_IRQ being not 0. If so, the drivers must be fixed, finally. Signed-off-by: Anton Vorontsov --- drivers/of/irq.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 6d3dd39..2dd4937 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -26,11 +26,6 @@ #include #include -/* For archs that don't support NO_IRQ (such as x86), provide a dummy value */ -#ifndef NO_IRQ -#define NO_IRQ 0 -#endif - /** * irq_of_parse_and_map - Parse and map an interrupt into linux virq space * @device: Device node of the device whose interrupt is to be mapped @@ -42,12 +37,23 @@ unsigned int irq_of_parse_and_map(struct device_node *dev, int index) { struct of_irq oirq; + int ret = 0; if (of_irq_map_one(dev, index, &oirq)) - return NO_IRQ; - - return irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); + goto no_irq; + + ret = irq_create_of_mapping(oirq.controller, oirq.specifier, + oirq.size); +no_irq: +#ifdef NO_IRQ +#if NO_IRQ != 0 + if (ret == NO_IRQ) + pr_warn("Hit NO_IRQ case for your arch. Drivers might expect " + "NO_IRQ, but we return 0. If anything breaks, driver " + "have to be fixed.\n"); +#endif +#endif + return ret; } EXPORT_SYMBOL_GPL(irq_of_parse_and_map); @@ -345,7 +351,7 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) /* Only dereference the resource if both the * resource and the irq are valid. */ - if (r && irq != NO_IRQ) { + if (r && irq) { r->start = r->end = irq; r->flags = IORESOURCE_IRQ; r->name = dev->full_name; @@ -363,7 +369,7 @@ int of_irq_count(struct device_node *dev) { int nr = 0; - while (of_irq_to_resource(dev, nr, NULL) != NO_IRQ) + while (of_irq_to_resource(dev, nr, NULL)) nr++; return nr; @@ -383,7 +389,7 @@ int of_irq_to_resource_table(struct device_node *dev, struct resource *res, int i; for (i = 0; i < nr_irqs; i++, res++) - if (of_irq_to_resource(dev, i, res) == NO_IRQ) + if (!of_irq_to_resource(dev, i, res)) break; return i;