From patchwork Fri Jan 31 14:18:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 3561741 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BDCE99F382 for ; Fri, 31 Jan 2014 14:20:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B217620222 for ; Fri, 31 Jan 2014 14:20:02 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 637202022A for ; Fri, 31 Jan 2014 14:20:00 +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 1W9EwN-00012w-Sa; Fri, 31 Jan 2014 14:19:32 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W9EwF-00012F-ME; Fri, 31 Jan 2014 14:19:23 +0000 Received: from mail-ee0-f42.google.com ([74.125.83.42]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W9Evu-0000wj-Uo for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2014 14:19:04 +0000 Received: by mail-ee0-f42.google.com with SMTP id b15so481321eek.1 for ; Fri, 31 Jan 2014 06:18:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references:content-type; bh=M9+CyuXpAne1dUMrGHRdciTlv4L69CvcwWio9BbT/7c=; b=E51nGXe2gdT84dyjo0CGOgdTUCtHBt+D1vbzyIKs7HXM4oUBNFQffw+wkMDD9sHdo+ o/cie+V4Dzz53iYeJww7kXzfr8wLs8ujjzF4pV25N8BjDIl0FBGFHOfMXKF8Zwg49tHB jYXIXv1A43QHhtFLH/r3et2+x5wjgCAZL8b8FPqNJ0uH4keu5vgaR9UO5WTJDXiTjh7n G0RaM9bPXUmoHzokdZHG+Cw5P51gYDCPLZ95E0syjMPdlCpswROSfxcF0+EZaUkskJd7 vcXU1o/6e0u8ak3TV/FDsGV8+XV8EF4xQg3gxetTiC5dEtlRvUni7ugbwYddTMGhzU8q aReQ== X-Gm-Message-State: ALoCoQnkAZy9XEWD7i/moGAFg+EWjoCmx81Mdn/Z860kmAyJuCKa7TqaD81YzEJ3K1ahe51NhNIk X-Received: by 10.15.31.71 with SMTP id x47mr135391eeu.114.1391177919100; Fri, 31 Jan 2014 06:18:39 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id d9sm10661186eei.9.2014.01.31.06.18.37 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Fri, 31 Jan 2014 06:18:38 -0800 (PST) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Subject: [PATCH 03/10] watchdog: xilinx: Simplify probe and remove functions Date: Fri, 31 Jan 2014 15:18:12 +0100 Message-Id: <578455fd630e70b5de8bae6091568f05e7769057.1391177880.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140131_091903_087147_E7582AA9 X-CRM114-Status: GOOD ( 16.01 ) X-Spam-Score: -1.9 (-) Cc: Wim Van Sebroeck , linux-watchdog@vger.kernel.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=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS, UNPARSEABLE_RELAY autolearn=unavailable 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 Use devm_ helper function to simplify probe and error path. Move ioremap to the beginning of probe function. Signed-off-by: Michal Simek Reviewed-by: Guenter Roeck --- drivers/watchdog/of_xilinx_wdt.c | 41 +++++++++------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) -- 1.8.2.3 diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c index aca9bab..7f371ed 100644 --- a/drivers/watchdog/of_xilinx_wdt.c +++ b/drivers/watchdog/of_xilinx_wdt.c @@ -12,6 +12,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -44,7 +45,6 @@ #define PFX WATCHDOG_NAME ": " struct xwdt_device { - struct resource res; void __iomem *base; u32 wdt_interval; }; @@ -159,9 +159,15 @@ static int xwdt_probe(struct platform_device *pdev) int rc; u32 *tmptr; u32 *pfreq; + struct resource *res; no_timeout = 0; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + xdev.base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(xdev.base)) + return PTR_ERR(xdev.base); + pfreq = (u32 *)of_get_property(pdev->dev.of_node, "clock-frequency", NULL); @@ -170,12 +176,6 @@ static int xwdt_probe(struct platform_device *pdev) no_timeout = 1; } - rc = of_address_to_resource(pdev->dev.of_node, 0, &xdev.res); - if (rc) { - pr_warn("invalid address!\n"); - return rc; - } - tmptr = (u32 *)of_get_property(pdev->dev.of_node, "xlnx,wdt-interval", NULL); if (tmptr == NULL) { @@ -199,50 +199,27 @@ static int xwdt_probe(struct platform_device *pdev) if (!no_timeout) timeout = 2 * ((1<dev, "Xilinx Watchdog Timer at %p with timeout %ds\n", xdev.base, timeout); return 0; - -unmap_io: - iounmap(xdev.base); -release_mem: - release_mem_region(xdev.res.start, resource_size(&xdev.res)); -err_out: - return rc; } static int xwdt_remove(struct platform_device *dev) { watchdog_unregister_device(&xilinx_wdt_wdd); - iounmap(xdev.base); - release_mem_region(xdev.res.start, resource_size(&xdev.res)); return 0; }