From patchwork Tue Feb 25 16:28:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 3717901 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E4CF6BF13A for ; Tue, 25 Feb 2014 16:34:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A7C520166 for ; Tue, 25 Feb 2014 16:34:39 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0CB1C201CD for ; Tue, 25 Feb 2014 16:34:38 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIKxg-000221-Jq; Tue, 25 Feb 2014 16:34:28 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIKxe-0007hg-9S; Tue, 25 Feb 2014 16:34:26 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WIKxb-0007ez-BI for linux-arm-kernel@lists.infradead.org; Tue, 25 Feb 2014 16:34:24 +0000 Received: by mail-wi0-f177.google.com with SMTP id e4so980579wiv.10 for ; Tue, 25 Feb 2014 08:32:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id; bh=T9PWiSYJw8r4cIs08SxI1qjafNjvRyFhX11xcM6TPrE=; b=DfGqUyvGinXl9iBntZSeRkS2p0Z4pgOsL+6p2nfDOz2l8guCf9G7+8O7Dav6xb92N/ Of4R3eg064uYssChWPQ1kKq1mUtzwz/VbZVEkUMPNFzxLIUY75VQLWDlcbN7iqmjMhcB HYvcmAZPxLo3KrKch9sgAZ+z9dWb3lrKiYyuW+TJA1YXsqMe/PEZHHc2BBDjAkywO3GI 3IyIvKY7nQanaJrtDiSwIBjSS/mMMOnTw6Ritl3nGAaC2QN184H8NiP94EOfBzGE0tpx qnxWgF0lr5TLYry+MtgW98AHSSej/FpkycPeFDlnxMWg+42IU/fjbG8ZLRwLZTQIw3Q+ icZg== X-Received: by 10.194.90.144 with SMTP id bw16mr25173197wjb.1.1393345918320; Tue, 25 Feb 2014 08:31:58 -0800 (PST) Received: from stedf17-labo202.ds.jdsu.net. (4-161.80-90.static-ip.oleane.fr. [90.80.161.4]) by mx.google.com with ESMTPSA id di9sm1630795wid.6.2014.02.25.08.31.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Feb 2014 08:31:57 -0800 (PST) From: Jean-Jacques Hiblot To: tglx@linutronix.de, linus.walleij@linaro.org Subject: [PATCH] irq: Consider a negative return value of irq_startup() as an error Date: Tue, 25 Feb 2014 17:28:39 +0100 Message-Id: <1393345719-3707-1-git-send-email-jjhiblot@traphandler.com> X-Mailer: git-send-email 1.9.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140225_113423_492230_0BB61462 X-CRM114-Status: GOOD ( 13.52 ) X-Spam-Score: -2.6 (--) Cc: grant.likely@linaro.org, Jean-Jacques Hiblot , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The irq_startup() function returns the return value of the irq_startup callback of the underlying irq_chip. Currently this value only tells if the interrupt is pending, but we can make it also return an error code when it fails. Signed-off-by: Jean-Jacques Hiblot --- Hi Thomas, This patch updates the semantic of the return value of the irq_startup() callback of an irq_chip : a negative value indicates an error. The purpose is to make __setup_irq() fail if the irq_chip can't startup the interrupt. I checked in the kernel for drivers impacted by this. It turns out that most of the implementation of irq_startup() return 0. The only drivers that return non-zero values are: * arch/x86/kernel/apic/io_apic.c: returns 1 when an interrupt is pending * drivers/pinctrl/pinctrl-adi2.c: may return -ENODEV. GPIO-based irq_chip could use this feature because an output gpio can't be used as an interrupt, and thus a call to irq_startup() is likely to fail. You can check out http://www.spinics.net/lists/arm-kernel/msg302713.html for a reference. Regards, Jean-Jacques include/linux/irq.h | 2 ++ kernel/irq/autoprobe.c | 2 +- kernel/irq/manage.c | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index 7dc1003..d566855 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -282,6 +282,8 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d) * * @name: name for /proc/interrupts * @irq_startup: start up the interrupt (defaults to ->enable if NULL) + * negative return values indicate an error, otherwise the + * return values indicates if an interrupt is pending * @irq_shutdown: shut down the interrupt (defaults to ->disable if NULL) * @irq_enable: enable the interrupt (defaults to chip->unmask if NULL) * @irq_disable: disable the interrupt diff --git a/kernel/irq/autoprobe.c b/kernel/irq/autoprobe.c index 0119b9d..64794fa 100644 --- a/kernel/irq/autoprobe.c +++ b/kernel/irq/autoprobe.c @@ -70,7 +70,7 @@ unsigned long probe_irq_on(void) raw_spin_lock_irq(&desc->lock); if (!desc->action && irq_settings_can_probe(desc)) { desc->istate |= IRQS_AUTODETECT | IRQS_WAITING; - if (irq_startup(desc, false)) + if (irq_startup(desc, false) > 0) desc->istate |= IRQS_PENDING; } raw_spin_unlock_irq(&desc->lock); diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 481a13c..58c6be0 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1116,7 +1116,9 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) desc->istate |= IRQS_ONESHOT; if (irq_settings_can_autoenable(desc)) - irq_startup(desc, true); + ret = irq_startup(desc, true); + if (ret < 0) + goto out_mask; else /* Undo nested disables: */ desc->depth = 1;