From patchwork Mon Sep 16 08:32:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 275160 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 DDE982C00E2 for ; Mon, 16 Sep 2013 18:35:03 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757381Ab3IPIet (ORCPT ); Mon, 16 Sep 2013 04:34:49 -0400 Received: from mail-bk0-f44.google.com ([209.85.214.44]:39252 "EHLO mail-bk0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755946Ab3IPId0 (ORCPT ); Mon, 16 Sep 2013 04:33:26 -0400 Received: by mail-bk0-f44.google.com with SMTP id mz10so1340815bkb.17 for ; Mon, 16 Sep 2013 01:33:24 -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=ULGgdwdAxwrIGsXunLyTWahT7LRd5lWA72k2p9oeNv4=; b=oPzu4JvQM2yyh6ZnQIIOPpW1AKNQTAR3vVlTdlIrsoXrPcmzTWYUQael4/gTUeVtNL E20Sazu9h7iMPcrj3LBZ7hYCSwBgl+WmRAkYQSQGun4DoaOwVn0R5ZlMbqDKCQmh+e8Z zoWGfZRd2y7H+SCUA4Auj9qIHbMHtHBsDEPtuIEMxesHOqUNcnGCxX9ObT7bDeSzq/jR XuWhdXPaagjZt/SkNxHqCHo0J5kbyzYj6SJHo6a3Nq6tXUT+D+SkgcPg3rp4G+2j7nCQ fuG2pgq73xv30WePgwZYIVtMgLav9YPg3lBrMshNU2LjJwV+d3SLZzehHgtmeLMJrpR6 WEXg== X-Received: by 10.204.70.194 with SMTP id e2mr78263bkj.55.1379320404463; Mon, 16 Sep 2013 01:33:24 -0700 (PDT) Received: from localhost (port-49886.pppoe.wtnet.de. [46.59.195.122]) by mx.google.com with ESMTPSA id on10sm6843851bkb.13.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 16 Sep 2013 01:33:23 -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 5/9] of/irq: Introduce __of_irq_to_resource() Date: Mon, 16 Sep 2013 10:32:02 +0200 Message-Id: <1379320326-13241-6-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 of_irq_to_resource() 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 of_irq_to_resource() as a wrapper around the new __of_irq_to_resource(). Signed-off-by: Thierry Reding --- drivers/of/irq.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 8225289..57396fd 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -343,15 +343,15 @@ int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq } EXPORT_SYMBOL_GPL(of_irq_map_one); -/** - * of_irq_to_resource - Decode a node's IRQ and return it as a resource - * @dev: pointer to device tree node - * @index: zero-based index of the irq - * @r: pointer to resource structure to return result into. - */ -int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) +static int __of_irq_to_resource(struct device_node *dev, unsigned int index, + struct resource *r) { - int irq = irq_of_parse_and_map(dev, index); + unsigned int irq; + int ret; + + ret = of_irq_get(dev, index, &irq); + if (ret) + return ret; /* Only dereference the resource if both the * resource and the irq are valid. */ @@ -373,6 +373,23 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) return irq; } + +/** + * of_irq_to_resource - Decode a node's IRQ and return it as a resource + * @dev: pointer to device tree node + * @index: zero-based index of the irq + * @r: pointer to resource structure to return result into. + */ +int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) +{ + int ret; + + ret = __of_irq_to_resource(dev, index, r); + if (ret < 0) + return 0; + + return ret; +} EXPORT_SYMBOL_GPL(of_irq_to_resource); /**