From patchwork Thu Feb 7 03:32:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kumar, Anil" X-Patchwork-Id: 2109301 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by patchwork2.kernel.org (Postfix) with ESMTP id 34AAADF2A1 for ; Thu, 7 Feb 2013 03:34:47 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r173UuQ7027007; Wed, 6 Feb 2013 21:30:56 -0600 Received: from DLEE74.ent.ti.com (dlee74.ent.ti.com [157.170.170.8]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r173Uujv003738; Wed, 6 Feb 2013 21:30:56 -0600 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Wed, 6 Feb 2013 21:30:56 -0600 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r173Uuqn004791; Wed, 6 Feb 2013 21:30:56 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 00EBF80627; Wed, 6 Feb 2013 21:30:56 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dbdp20.itg.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by linux.omap.com (Postfix) with ESMTP id AC2A280626 for ; Wed, 6 Feb 2013 21:30:53 -0600 (CST) Received: from DBDE71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id r173UohK012405; Thu, 7 Feb 2013 09:00:51 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 14.1.323.3; Thu, 7 Feb 2013 09:00:50 +0530 Received: from ucmsshproxy.india.ext.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with SMTP id r173UmiC004111; Thu, 7 Feb 2013 09:00:49 +0530 Received: from symphony.india.ext.ti.com (unknown [192.168.247.13]) by ucmsshproxy.india.ext.ti.com (Postfix) with ESMTP id 36418158002; Thu, 7 Feb 2013 09:00:48 +0530 (IST) Received: from ubuntu-psp-linux.india.ext.ti.com (ubuntu-psp-linux [192.168.247.46]) by symphony.india.ext.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r173UkR29556; Thu, 7 Feb 2013 09:00:47 +0530 (IST) From: "Kumar, Anil" To: , , Subject: [PATCH] watchdog: davinci_wdt: update to devm_* API Date: Thu, 7 Feb 2013 09:02:15 +0530 Message-ID: <1360207935-24325-1-git-send-email-anilkumar.v@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 CC: X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com Update the code to use devm_* API so that driver core will manage resources. Signed-off-by: Kumar, Anil --- This patch applies on top of v3.8-rc6. Tested on da850 EVM. :100644 100644 e8e8724... 6ad76a3... M drivers/watchdog/davinci_wdt.c drivers/watchdog/davinci_wdt.c | 34 +++++++++------------------------- 1 files changed, 9 insertions(+), 25 deletions(-) diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c index e8e8724..6ad76a3 100644 --- a/drivers/watchdog/davinci_wdt.c +++ b/drivers/watchdog/davinci_wdt.c @@ -69,7 +69,6 @@ static unsigned long wdt_status; #define WDT_REGION_INITED 2 #define WDT_DEVICE_INITED 3 -static struct resource *wdt_mem; static void __iomem *wdt_base; struct clk *wdt_clk; @@ -201,10 +200,10 @@ static struct miscdevice davinci_wdt_miscdev = { static int davinci_wdt_probe(struct platform_device *pdev) { - int ret = 0, size; - struct device *dev = &pdev->dev; + int ret = 0; + static struct resource *wdt_mem; - wdt_clk = clk_get(dev, NULL); + wdt_clk = clk_get(&pdev->dev, NULL); if (WARN_ON(IS_ERR(wdt_clk))) return PTR_ERR(wdt_clk); @@ -213,49 +212,34 @@ static int davinci_wdt_probe(struct platform_device *pdev) if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) heartbeat = DEFAULT_HEARTBEAT; - dev_info(dev, "heartbeat %d sec\n", heartbeat); + dev_info(&pdev->dev, "heartbeat %d sec\n", heartbeat); wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (wdt_mem == NULL) { - dev_err(dev, "failed to get memory region resource\n"); + dev_err(&pdev->dev, "failed to get memory region resource\n"); return -ENOENT; } - size = resource_size(wdt_mem); - if (!request_mem_region(wdt_mem->start, size, pdev->name)) { - dev_err(dev, "failed to get memory region\n"); - return -ENOENT; - } - - wdt_base = ioremap(wdt_mem->start, size); + wdt_base = devm_request_and_ioremap(&pdev->dev, wdt_mem); if (!wdt_base) { - dev_err(dev, "failed to map memory region\n"); - release_mem_region(wdt_mem->start, size); - wdt_mem = NULL; + dev_err(&pdev->dev, "ioremap failed\n"); return -ENOMEM; } ret = misc_register(&davinci_wdt_miscdev); if (ret < 0) { - dev_err(dev, "cannot register misc device\n"); - release_mem_region(wdt_mem->start, size); - wdt_mem = NULL; + dev_err(&pdev->dev, "cannot register misc device\n"); } else { set_bit(WDT_DEVICE_INITED, &wdt_status); + return ret; } - iounmap(wdt_base); return ret; } static int davinci_wdt_remove(struct platform_device *pdev) { misc_deregister(&davinci_wdt_miscdev); - if (wdt_mem) { - release_mem_region(wdt_mem->start, resource_size(wdt_mem)); - wdt_mem = NULL; - } - clk_disable_unprepare(wdt_clk); clk_put(wdt_clk);