From patchwork Tue Feb 11 06:55:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 3625161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 563E3BF418 for ; Tue, 11 Feb 2014 06:57:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B2D220171 for ; Tue, 11 Feb 2014 06:57:53 +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 840A7201F7 for ; Tue, 11 Feb 2014 06:57:52 +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 1WD7HD-0007Fh-44; Tue, 11 Feb 2014 06:57:03 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WD7H4-0000Rw-3m; Tue, 11 Feb 2014 06:56:54 +0000 Received: from mail-ea0-f173.google.com ([209.85.215.173]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WD7Gd-0000Ls-76 for linux-arm-kernel@lists.infradead.org; Tue, 11 Feb 2014 06:56:30 +0000 Received: by mail-ea0-f173.google.com with SMTP id d10so3385264eaj.18 for ; Mon, 10 Feb 2014 22:56:05 -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=XnCs+z9kLC+gMS3q5cZKweNltv81O+jMy60RHfKDQok=; b=k0AdSDuq/9WT1p4VUYZsEUKsXhdvUigZL1YRo6I+dzUL6PYRRn+NqGd3i1NLYTYXiw 8n8yMKhDXtzsAhLTiSYPFthNs/j05K4LCeJxRa5bylLK5J1LmXxwrb/jQFC1MvNYFasx Ai+mgUSYUV2taTigJXUzhr1u5hnc0cx+eGN4eg3cNJ1l1GVwWHqXFoV87SAS36N7NOes 04jTOUZ+IVMsFSR5fh557QSjAau2rbnUQ/nTKBi1ZF7JWz7caEQ707gFs0rhz42ZvY7B IPgfjaaPvKZM//FVDDgl7JUg3E435SwB4yJ3wv5fRhgFPsqmWazPNHwgVsRq01BelIjW 4o3A== X-Gm-Message-State: ALoCoQmJaQEPqPqdiau6URLEgVx3Lvu2CdjlViz8Lzqkr5nIlsXuYMFbLJ6/Ctc4DGq8w20AwijU X-Received: by 10.14.105.200 with SMTP id k48mr41207776eeg.44.1392101765210; Mon, 10 Feb 2014 22:56:05 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id n41sm33972837eeg.16.2014.02.10.22.56.03 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 10 Feb 2014 22:56:04 -0800 (PST) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Subject: [PATCH v2 03/11] watchdog: xilinx: Simplify probe and remove functions Date: Tue, 11 Feb 2014 07:55:46 +0100 Message-Id: <619599eff39de3551d53c75dd6c95678d9a81df1.1392101734.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-20140211_015627_453171_DAF95357 X-CRM114-Status: GOOD ( 16.50 ) X-Spam-Score: -1.9 (-) Cc: linux-arm-kernel@lists.infradead.org, Wim Van Sebroeck , linux-watchdog@vger.kernel.org, Guenter Roeck 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 --- Changes in v2: None 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; }