From patchwork Tue Sep 14 08:30:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 178882 X-Patchwork-Delegate: tony@atomide.com 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 o8E8UZiN025303 for ; Tue, 14 Sep 2010 08:30:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753006Ab0INIaa (ORCPT ); Tue, 14 Sep 2010 04:30:30 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:46589 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752062Ab0INIa3 (ORCPT ); Tue, 14 Sep 2010 04:30:29 -0400 Received: from dlep34.itg.ti.com ([157.170.170.115]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o8E8UR4V022843 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 14 Sep 2010 03:30:27 -0500 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id o8E8UQfL001286; Tue, 14 Sep 2010 03:30:26 -0500 (CDT) Received: from localhost (wsp000207077wss.emea.dhcp.ti.com [137.167.41.187]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id o8E8UPf16010; Tue, 14 Sep 2010 03:30:25 -0500 (CDT) From: Felipe Balbi To: Linux OMAP Mailing List Cc: Jarkko Nikula , Tony Lindgren , Felipe Balbi Subject: [RFT/PATCH 3/8] cbus: retu: pass irq number via struct resource Date: Tue, 14 Sep 2010 11:30:11 +0300 Message-Id: <1284453016-8295-4-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.7.3.rc0.35.g8ac8c In-Reply-To: <1284453016-8295-1-git-send-email-balbi@ti.com> References: <1284453016-8295-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]); Tue, 14 Sep 2010 08:30:37 +0000 (UTC) diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c index 15368dc..67b663e 100644 --- a/drivers/cbus/retu.c +++ b/drivers/cbus/retu.c @@ -398,32 +398,12 @@ static int retu_allocate_children(struct device *parent) static int __devinit retu_probe(struct platform_device *pdev) { int rev, ret; + int irq; /* Prepare tasklet */ tasklet_init(&retu_tasklet, retu_tasklet_handler, 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 { - dev_err(&pdev->dev, "cbus: Unsupported board for tahvo\n"); - return -ENODEV; - } - - ret = gpio_request(retu_irq_pin, "RETU irq"); - if (ret < 0) { - dev_err(&pdev->dev, "Unable to reserve IRQ GPIO\n"); - return ret; - } - - /* Set the pin as input */ - gpio_direction_input(retu_irq_pin); - - /* Rising edge triggers the IRQ */ - set_irq_type(gpio_to_irq(retu_irq_pin), IRQ_TYPE_EDGE_RISING); + irq = platform_get_irq(pdev, 0); retu_initialized = 1; @@ -437,14 +417,14 @@ static int __devinit retu_probe(struct platform_device *pdev) /* Mask all RETU interrupts */ retu_write_reg(RETU_REG_IMR, 0xffff); - ret = request_irq(gpio_to_irq(retu_irq_pin), retu_irq_handler, 0, + ret = request_irq(irq, retu_irq_handler, 0, "retu", 0); if (ret < 0) { dev_err(&pdev->dev, "Unable to register IRQ handler\n"); - gpio_free(retu_irq_pin); return ret; } - set_irq_wake(gpio_to_irq(retu_irq_pin), 1); + + set_irq_wake(irq, 1); /* Register power off function */ pm_power_off = retu_power_off; @@ -453,8 +433,7 @@ static int __devinit retu_probe(struct platform_device *pdev) /* Initialize user-space interface */ if (retu_user_init() < 0) { dev_err(&pdev->dev, "Unable to initialize driver\n"); - free_irq(gpio_to_irq(retu_irq_pin), 0); - gpio_free(retu_irq_pin); + free_irq(irq, 0); return ret; } #endif @@ -466,8 +445,7 @@ static int __devinit retu_probe(struct platform_device *pdev) retu_user_cleanup(); #endif retu_write_reg(RETU_REG_IMR, 0xffff); - free_irq(gpio_to_irq(retu_irq_pin), 0); - gpio_free(retu_irq_pin); + free_irq(irq, 0); tasklet_kill(&retu_tasklet); return ret; } @@ -477,13 +455,16 @@ static int __devinit retu_probe(struct platform_device *pdev) static int __devexit retu_remove(struct platform_device *pdev) { + int irq; + + irq = platform_get_irq(pdev, 0); + #ifdef CONFIG_CBUS_RETU_USER retu_user_cleanup(); #endif /* Mask all RETU interrupts */ retu_write_reg(RETU_REG_IMR, 0xffff); - free_irq(gpio_to_irq(retu_irq_pin), 0); - gpio_free(retu_irq_pin); + free_irq(irq, 0); tasklet_kill(&retu_tasklet); return 0; @@ -497,9 +478,18 @@ 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), }; /** @@ -511,21 +501,55 @@ static int __init retu_init(void) { int ret = 0; - if (!(machine_is_nokia770() || machine_is_nokia_n800() || - machine_is_nokia_n810() || machine_is_nokia_n810_wimax())) - return -ENODEV; + /* 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_driver_register(&retu_driver); if (ret < 0) - return ret; + goto err1; ret = platform_device_register(&retu_device); - if (ret < 0) { - platform_driver_unregister(&retu_driver); - return ret; - } + if (ret < 0) + goto err2; return 0; + +err2: + platform_driver_unregister(&retu_driver); + +err1: + gpio_free(retu_irq_pin); + +err0: + return ret; } /* @@ -535,6 +559,7 @@ 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);