From patchwork Fri Oct 1 07:47:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 222962 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o917lOW1010514 for ; Fri, 1 Oct 2010 07:47:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754587Ab0JAHrY (ORCPT ); Fri, 1 Oct 2010 03:47:24 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:57796 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754211Ab0JAHrX (ORCPT ); Fri, 1 Oct 2010 03:47:23 -0400 Received: from dlep35.itg.ti.com ([157.170.170.118]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o917lMMk010680 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 1 Oct 2010 02:47:22 -0500 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id o917lMs8029843; Fri, 1 Oct 2010 02:47:22 -0500 (CDT) Received: from localhost (h0-156.vpn.ti.com [172.24.0.156]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id o917lLf02174; Fri, 1 Oct 2010 02:47:21 -0500 (CDT) From: Felipe Balbi To: Tony Lindgren Cc: Linux OMAP Mailing List , Felipe Balbi Subject: [PATCH 2/4] cbus: retu: move platform_device to board file Date: Fri, 1 Oct 2010 10:47:16 +0300 Message-Id: <1285919238-26555-3-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.7.3.rc0.35.g8ac8c In-Reply-To: <1285919238-26555-1-git-send-email-balbi@ti.com> References: <1285919238-26555-1-git-send-email-balbi@ti.com> Organization: Texas Instruments\n Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 01 Oct 2010 07:47:25 +0000 (UTC) diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c index c14d398..82c9880 100644 --- a/arch/arm/mach-omap2/board-n8x0.c +++ b/arch/arm/mach-omap2/board-n8x0.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -221,9 +222,53 @@ static struct platform_device n8x0_cbus_device = { }, }; +static struct resource retu_resource[] = { + { + .start = -EINVAL, /* set later */ + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device retu_device = { + .name = "retu", + .id = -1, + .resource = retu_resource, + .num_resources = ARRAY_SIZE(retu_resource), +}; + static void __init n8x0_cbus_init(void) { + int retu_irq_pin; + int ret; + platform_device_register(&n8x0_cbus_device); + + if (machine_is_nokia770()) { + retu_irq_pin = 62; + } else if (machine_is_nokia_n800() || machine_is_nokia_n810() || + machine_is_nokia_n810_wimax()) { + retu_irq_pin = 108; + } else { + pr_err("retu: Unsupported board for retu\n"); + return; + } + + ret = gpio_request(retu_irq_pin, "RETU irq"); + if (ret < 0) { + pr_err("retu: Unable to reserve IRQ GPIO\n"); + return; + } + + ret = gpio_direction_input(retu_irq_pin); + if (ret < 0) { + pr_err("retu: Unable to change gpio direction\n"); + gpio_free(retu_irq_pin); + return; + } + + set_irq_type(gpio_to_irq(retu_irq_pin), IRQ_TYPE_EDGE_RISING); + retu_resource[0].start = gpio_to_irq(retu_irq_pin); + platform_device_register(&retu_device); } #else diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c index 4a072da..a2977c9 100644 --- a/drivers/cbus/retu.c +++ b/drivers/cbus/retu.c @@ -50,7 +50,6 @@ #define PFX "retu: " static int retu_initialized; -static int retu_irq_pin; static int retu_is_vilma; static struct tasklet_struct retu_tasklet; @@ -477,20 +476,6 @@ static struct platform_driver retu_driver = { }, }; -static struct resource retu_resource[] = { - { - .start = -EINVAL, /* set later */ - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device retu_device = { - .name = "retu", - .id = -1, - .resource = retu_resource, - .num_resources = ARRAY_SIZE(retu_resource), -}; - /** * retu_init - initialise Retu driver * @@ -498,57 +483,7 @@ static struct platform_device retu_device = { */ static int __init retu_init(void) { - int ret = 0; - - /* REVISIT: Pass these from board-*.c files in platform_data */ - if (machine_is_nokia770()) { - retu_irq_pin = 62; - } else if (machine_is_nokia_n800() || machine_is_nokia_n810() || - machine_is_nokia_n810_wimax()) { - retu_irq_pin = 108; - } else { - pr_err("retu: Unsupported board for retu\n"); - ret = -ENODEV; - goto err0; - } - - ret = gpio_request(retu_irq_pin, "RETU irq"); - if (ret < 0) { - pr_err("retu: Unable to reserve IRQ GPIO\n"); - goto err0; - } - - /* Set the pin as input */ - ret = gpio_direction_input(retu_irq_pin); - if (ret < 0) { - pr_err("retu: Unable to change gpio direction\n"); - goto err1; - } - - /* Rising edge triggers the IRQ */ - set_irq_type(gpio_to_irq(retu_irq_pin), IRQ_TYPE_EDGE_RISING); - - /* Set up correct gpio number on struct resource */ - retu_resource[0].start = gpio_to_irq(retu_irq_pin); - - ret = platform_device_register(&retu_device); - if (ret < 0) - goto err1; - - ret = platform_driver_probe(&retu_driver, retu_probe); - if (ret < 0) - goto err2; - - return 0; - -err2: - platform_driver_unregister(&retu_driver); - -err1: - gpio_free(retu_irq_pin); - -err0: - return ret; + return platform_driver_probe(&retu_driver, retu_probe); } /* @@ -556,9 +491,7 @@ err0: */ static void __exit retu_exit(void) { - platform_device_unregister(&retu_device); platform_driver_unregister(&retu_driver); - gpio_free(retu_irq_pin); } subsys_initcall(retu_init);