From patchwork Wed Jul 11 09:13:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tarun Kanti DebBarma X-Patchwork-Id: 1181081 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 1412EDF25A for ; Wed, 11 Jul 2012 09:20:49 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Sot2R-0003nk-QP; Wed, 11 Jul 2012 09:16:51 +0000 Received: from comal.ext.ti.com ([198.47.26.152]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Soszh-0003cb-N8 for linux-arm-kernel@lists.infradead.org; Wed, 11 Jul 2012 09:14:06 +0000 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id q6B9DaCo023251; Wed, 11 Jul 2012 04:13:37 -0500 Received: from DBDE70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6B9DL30022113; Wed, 11 Jul 2012 14:43:35 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by dbde70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 14.1.323.3; Wed, 11 Jul 2012 14:43:21 +0530 Received: from localhost.localdomain (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6B9DITL019016; Wed, 11 Jul 2012 14:43:21 +0530 From: Tarun Kanti DebBarma To: Subject: [PATCH 2/2] gpio/omap: add *remove* callback in platform_driver Date: Wed, 11 Jul 2012 14:43:15 +0530 Message-ID: <1341997995-14020-3-git-send-email-tarun.kanti@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1341997995-14020-1-git-send-email-tarun.kanti@ti.com> References: <1341997995-14020-1-git-send-email-tarun.kanti@ti.com> MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.152 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Kevin Hilman , Paul Walmsley , "Cousson, Benoit" , Rajendra Nayak , linux-kernel@vger.kernel.org, Santosh Shilimkar , Tarun Kanti DebBarma , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add *remove* callback so that necessary cleanup operations are performed when device is unregistered. The device is deleted from the list and associated clock handle is released by calling clk_put() and irq descriptor is released using the irq_free_desc() api. Signed-off-by: Tarun Kanti DebBarma Reported-by: Paul Walmsley Reviewed-by: Jon Hunter Cc: Kevin Hilman Cc: Rajendra Nayak Cc: Santosh Shilimkar Cc: Cousson, Benoit Cc: Paul Walmsley --- drivers/gpio/gpio-omap.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index afecdcc..08929d5 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -1140,6 +1140,35 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev) return ret; } +/** + * omap_gpio_remove - cleanup a registered gpio device + * @pdev: pointer to current gpio platform device + * + * Called by driver framework whenever a gpio device is unregistered. + * GPIO is deleted from the list and associated clock handle freed. + */ +static int __devexit omap_gpio_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct gpio_bank *bank; + unsigned long flags; + int ret = -EINVAL; + + list_for_each_entry(bank, &omap_gpio_list, node) { + spin_lock_irqsave(&bank->lock, flags); + if (bank->dev == dev) { + list_del(&bank->node); + clk_put(bank->dbck); + irq_free_desc(bank->irq_base); + ret = 0; + spin_unlock_irqrestore(&bank->lock, flags); + break; + } + spin_unlock_irqrestore(&bank->lock, flags); + } + return ret; +} + #ifdef CONFIG_ARCH_OMAP2PLUS #if defined(CONFIG_PM_RUNTIME) @@ -1466,6 +1495,7 @@ MODULE_DEVICE_TABLE(of, omap_gpio_match); static struct platform_driver omap_gpio_driver = { .probe = omap_gpio_probe, + .remove = __devexit_p(omap_gpio_remove), .driver = { .name = "omap_gpio", .pm = &gpio_pm_ops,