From patchwork Wed Sep 18 13:24:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 2906941 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 2CE35BFF05 for ; Wed, 18 Sep 2013 13:30:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0942C2034F for ; Wed, 18 Sep 2013 13:30:00 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D91720340 for ; Wed, 18 Sep 2013 13:29:55 +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 1VMHno-00060c-Nz; Wed, 18 Sep 2013 13:28:22 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VMHnI-0002Xg-4Z; Wed, 18 Sep 2013 13:27:48 +0000 Received: from mail-bk0-f50.google.com ([209.85.214.50]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VMHma-0002P2-3C for linux-arm-kernel@lists.infradead.org; Wed, 18 Sep 2013 13:27:05 +0000 Received: by mail-bk0-f50.google.com with SMTP id mz11so2793278bkb.37 for ; Wed, 18 Sep 2013 06:26:28 -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=jik3sAsp1sMyKr3OxWe14XQ2Dm5HZIE3JMP7NpjBhLI=; b=W/WisCu4T5NtBPDQrI3Iqeyi+Spye8x+eOOSWwpwF0H8oC+6GjWT/efJFBAV/lEtHF 8qJCFgcO5Jsb08hVuC9tcLFPWFAoU0Jm+ii8nNzICBt7Sov9f5/EQLS6rKwnYWhy4IsY Z3y8UgZDR0eokNEAF4tie7rV2d0haLvwjPz9sXgzbb/eynNybJZsC/mPg2dqvs1Gh5Ys Li0/Yk3mhRxAVAijK2SUWtTzOmGAXvB5BvkwaFTtltfdoay6PnEtajFprErLqHpmM+0t SX/V/aPhXzLFx0b1tv561A0RZ+SZJiJz5eW6UcnoPRLZ8VgtX99923VBAfpkjO8RIrfR N6pA== X-Received: by 10.204.60.66 with SMTP id o2mr34703161bkh.22.1379510786987; Wed, 18 Sep 2013 06:26:26 -0700 (PDT) Received: from localhost (port-55509.pppoe.wtnet.de. [46.59.217.135]) by mx.google.com with ESMTPSA id kk2sm899764bkb.10.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 18 Sep 2013 06:26:26 -0700 (PDT) From: Thierry Reding To: Rob Herring , Grant Likely , Greg Kroah-Hartman , Thomas Gleixner Subject: [PATCH v2 06/10] of/irq: Return errors from of_irq_to_resource() Date: Wed, 18 Sep 2013 15:24:48 +0200 Message-Id: <1379510692-32435-7-git-send-email-treding@nvidia.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1379510692-32435-1-git-send-email-treding@nvidia.com> References: <1379510692-32435-1-git-send-email-treding@nvidia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130918_092704_295592_BEDB9139 X-CRM114-Status: GOOD ( 16.19 ) X-Spam-Score: 0.9 (/) Cc: linux-mips@linux-mips.org, Russell King , devicetree@vger.kernel.org, Benjamin Herrenschmidt , linux-kernel@vger.kernel.org, Ralf Baechle , sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.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=-1.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no 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 Update of_irq_to_resource() to return 0 on success and a negative error code on failure. This allows the precise nature of the failure to be determined in the caller and errors to be propagated appropriately. While at it, make the index parameter unsigned. Accessing negative indices is invalid, so we might as well enforce that by using the right data type. Signed-off-by: Thierry Reding --- Changes in v2: - convert existing callers instead of using compatible wrapper arch/powerpc/platforms/83xx/mpc832x_rdb.c | 2 +- drivers/net/ethernet/marvell/mv643xx_eth.c | 5 +++-- drivers/of/irq.c | 14 +++++++++++--- include/linux/of_irq.h | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/platforms/83xx/mpc832x_rdb.c b/arch/powerpc/platforms/83xx/mpc832x_rdb.c index eff5baa..b198e73 100644 --- a/arch/powerpc/platforms/83xx/mpc832x_rdb.c +++ b/arch/powerpc/platforms/83xx/mpc832x_rdb.c @@ -89,7 +89,7 @@ static int __init of_fsl_spi_probe(char *type, char *compatible, u32 sysclk, goto err; ret = of_irq_to_resource(np, 0, &res[1]); - if (ret == NO_IRQ) + if (ret) goto err; pdev = platform_device_alloc("mpc83xx_spi", i); diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index 7fb5677..bd713bd 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -2489,9 +2489,10 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev, ppd.shared = pdev; memset(&res, 0, sizeof(res)); - if (!of_irq_to_resource(pnp, 0, &res)) { + ret = of_irq_to_resource(pnp, 0, &res); + if (ret) { dev_err(&pdev->dev, "missing interrupt on %s\n", pnp->name); - return -EINVAL; + return ret; } if (of_property_read_u32(pnp, "reg", &ppd.port_number)) { diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 6ad46fd..e4f38c0 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -341,10 +341,18 @@ EXPORT_SYMBOL_GPL(of_irq_map_one); * @dev: pointer to device tree node * @index: zero-based index of the irq * @r: pointer to resource structure to return result into. + * + * Returns zero on success or a negative error code on failure. */ -int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) +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 = __irq_of_parse_and_map(dev, index, &irq); + if (ret) + return ret; /* Only dereference the resource if both the * resource and the irq are valid. */ @@ -364,7 +372,7 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) r->name = name ? name : dev->full_name; } - return irq; + return 0; } EXPORT_SYMBOL_GPL(of_irq_to_resource); diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h index 11da949..6d62b73 100644 --- a/include/linux/of_irq.h +++ b/include/linux/of_irq.h @@ -67,7 +67,7 @@ extern int of_irq_map_one(struct device_node *device, int index, extern int irq_create_of_mapping(struct device_node *controller, const u32 *intspec, unsigned int intsize, unsigned int *virqp); -extern int of_irq_to_resource(struct device_node *dev, int index, +extern int of_irq_to_resource(struct device_node *dev, unsigned int index, struct resource *r); extern int of_irq_count(struct device_node *dev); extern int of_irq_to_resource_table(struct device_node *dev,