From patchwork Wed Feb 12 13:34:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 3638101 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 2A080BF13A for ; Wed, 12 Feb 2014 13:37:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 33A4D20145 for ; Wed, 12 Feb 2014 13:37:51 +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 28AA420142 for ; Wed, 12 Feb 2014 13:37:50 +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 1WDZzH-0000io-Kg; Wed, 12 Feb 2014 13:36:28 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDZyx-0003DU-Mt; Wed, 12 Feb 2014 13:36:07 +0000 Received: from mail-ea0-f178.google.com ([209.85.215.178]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDZyb-00038q-1Q for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2014 13:35:46 +0000 Received: by mail-ea0-f178.google.com with SMTP id a15so4519355eae.9 for ; Wed, 12 Feb 2014 05:35:23 -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=5SrZ+h7jEaJSiIZjKU08h0Q/QpNk/a0tTunOnbqkHKU=; b=JzIKU36vZvGdNES5ACg9Gy1O1d14C016oAi5B4z5jJem7w4T0Kkp4MkemsHfz7HOv+ qsEqLCRxnh6gyqk2e6w+dQfDddW4DhpDMR/odg/XulZF1p7STDZAFy9taKD6JOp40ukv 2wXC6gSrMQk5l+LqDaAZRRJpH6+K/qRUSS79tBEyrOphaSwHJbvjjxDbfZw+5C3B2KTd Ne07g+dHY591AzciIOzPrVeUbQ+xZ3k+SxVQAAe7KLWoRMgnIExXJaYItr6hUpMuHc9a Y10FwJewPi50Yjl2/99eQaOFCWIdrHYViJzFy77OFvikChctEvcM+jkW6Xt24SeTD5pV Olrg== X-Gm-Message-State: ALoCoQmqgzszuAnMFXRfcvC1DMJQonWRImi5kCNtUraKab6Vs0VmM+iWBi9xxcJVktX9/eApaS59 X-Received: by 10.15.73.134 with SMTP id h6mr4042037eey.15.1392212123221; Wed, 12 Feb 2014 05:35:23 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id j42sm82802917eep.21.2014.02.12.05.35.19 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Wed, 12 Feb 2014 05:35:21 -0800 (PST) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Subject: [PATCH v3 03/11] watchdog: xilinx: Simplify probe and remove functions Date: Wed, 12 Feb 2014 14:34:34 +0100 Message-Id: <619599eff39de3551d53c75dd6c95678d9a81df1.1392212059.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-20140212_083545_254092_54CEAC23 X-CRM114-Status: GOOD ( 16.63 ) 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 v3: None 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; }