From patchwork Mon Sep 16 08:32:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 275158 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 0B3632C00E2 for ; Mon, 16 Sep 2013 18:34:46 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756802Ab3IPId1 (ORCPT ); Mon, 16 Sep 2013 04:33:27 -0400 Received: from mail-bk0-f49.google.com ([209.85.214.49]:44184 "EHLO mail-bk0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756625Ab3IPIdY (ORCPT ); Mon, 16 Sep 2013 04:33:24 -0400 Received: by mail-bk0-f49.google.com with SMTP id r7so1327137bkg.22 for ; Mon, 16 Sep 2013 01:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ngA3WXeZQUOGOZRbowj4DJZCTqe020xK6rHuxKYXaEk=; b=u25VAJmDtBvzisk1eEdBaBSCaF4d09eiTT64H/YB7c8y+DJ4he3Io9rpT9B8rKWKed CCjXb3EkIbmjIG4jokq6muM/0vWLCj1abeBgVDWpZZlnrtDxci+Gqc4yDF9/R3kGR4Sg FMf4z47419Z7ubVqTEPPoct3XhR9fyYbwqpsZAGiQfvSzWuN1+fGTGyCLr+RArzcQOjG okkWcvpuIUpsFzUGN7vM8xUi1a52hczO/35XK8aQXvYOmS8m1VgvaDqApJOXdULOQN2X o4c5T3s02i77B7i6OpJf5hIe0rzs20yk6ypEvRdFmRDKEFg6TxiZvk3f8AG273fWrj6r iiiA== X-Received: by 10.204.99.132 with SMTP id u4mr421200bkn.42.1379320402464; Mon, 16 Sep 2013 01:33:22 -0700 (PDT) Received: from localhost (port-49886.pppoe.wtnet.de. [46.59.195.122]) by mx.google.com with ESMTPSA id qg7sm6841896bkb.6.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 16 Sep 2013 01:33:21 -0700 (PDT) From: Thierry Reding To: Greg Kroah-Hartman , Linus Walleij , Stephen Warren , Wolfram Sang , Grant Likely , Rob Herring , Benjamin Herrenschmidt , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 4/9] of/irq: Introduce of_irq_get() Date: Mon, 16 Sep 2013 10:32:01 +0200 Message-Id: <1379320326-13241-5-git-send-email-treding@nvidia.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1379320326-13241-1-git-send-email-treding@nvidia.com> References: <1379320326-13241-1-git-send-email-treding@nvidia.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This is a version of irq_of_parse_and_map() that propagates the precise error code instead of returning 0 for all errors. It will be used in subsequent patches to allow further propagation of error codes. To avoid code duplication, implement irq_of_parse_and_map() as a wrapper around the new of_irq_get(). Signed-off-by: Thierry Reding --- drivers/of/irq.c | 21 +++++++++++++++++---- include/linux/of_irq.h | 3 +++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 5f44388..8225289 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -26,6 +26,20 @@ #include #include +int of_irq_get(struct device_node *dev, unsigned int index, unsigned int *virqp) +{ + struct of_irq oirq; + int ret; + + ret = of_irq_map_one(dev, index, &oirq); + if (ret) + return ret; + + return __irq_create_of_mapping(oirq.controller, oirq.specifier, + oirq.size, virqp); +} +EXPORT_SYMBOL_GPL(of_irq_get); + /** * irq_of_parse_and_map - Parse and map an interrupt into linux virq space * @dev: Device node of the device whose interrupt is to be mapped @@ -36,13 +50,12 @@ */ unsigned int irq_of_parse_and_map(struct device_node *dev, int index) { - struct of_irq oirq; + unsigned int virq; - if (of_irq_map_one(dev, index, &oirq)) + if (of_irq_get(dev, index, &virq)) return 0; - return irq_create_of_mapping(oirq.controller, oirq.specifier, - oirq.size); + return virq; } EXPORT_SYMBOL_GPL(irq_of_parse_and_map); diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index c383dd1..cac15d7 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -17,6 +17,9 @@ struct of_irq; */ extern unsigned int irq_of_parse_and_map(struct device_node *node, int index); +extern int of_irq_get(struct device_node *node, unsigned int index, + unsigned int *virqp); + #if defined(CONFIG_OF_IRQ) /** * of_irq - container for device_node/irq_specifier pair for an irq controller