Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754261AbaAaOSu (ORCPT ); Fri, 31 Jan 2014 09:18:50 -0500 Received: from mail-ea0-f180.google.com ([209.85.215.180]:34213 "EHLO mail-ea0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754181AbaAaOSm (ORCPT ); Fri, 31 Jan 2014 09:18:42 -0500 From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Cc: Wim Van Sebroeck , linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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: Content-Type: multipart/signed; boundary="=_mimegpg-monstr-desktop-23095-1391177916-0001"; micalg=pgp-sha1; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a MIME GnuPG-signed message. If you see this text, it means that your E-mail or Usenet software does not support MIME signed messages. The Internet standard for MIME PGP messages, RFC 2015, was published in 1996. To open this message correctly you will need to install E-mail or Usenet software that supports modern Internet standards. --=_mimegpg-monstr-desktop-23095-1391177916-0001 Use devm_ helper function to simplify probe and error path. Move ioremap to the beginning of probe function. Signed-off-by: Michal Simek --- drivers/watchdog/of_xilinx_wdt.c | 41 +++++++++------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) 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; } -- 1.8.2.3 --=_mimegpg-monstr-desktop-23095-1391177916-0001 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEABECAAYFAlLrsLwACgkQykllyylKDCExhgCcDMnoW/I/1WUKucny/filj8L1 mn0AoJMRHfQn+RCkOuMrnFsljIUxKXuu =D1Lq -----END PGP SIGNATURE----- --=_mimegpg-monstr-desktop-23095-1391177916-0001-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/