From patchwork Tue Feb 11 06:55:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 3625221 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 34D62BF418 for ; Tue, 11 Feb 2014 07:00:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F738201F4 for ; Tue, 11 Feb 2014 07:00:04 +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 7B25120171 for ; Tue, 11 Feb 2014 07:00:03 +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 1WD7IC-0007n4-Vv; Tue, 11 Feb 2014 06:58:06 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WD7Hj-0000VF-J9; Tue, 11 Feb 2014 06:57:35 +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 1WD7Go-0000MG-AW for linux-arm-kernel@lists.infradead.org; Tue, 11 Feb 2014 06:56:39 +0000 Received: by mail-ee0-f42.google.com with SMTP id b15so3384191eek.1 for ; Mon, 10 Feb 2014 22:56:16 -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=qAbeG9/jX6pRdIcw9ZMuqzC4I4lmv3QvJkf+UiK3JKs=; b=VCFrwkyuzojlfxvUWcVv2r8gy8uvZKgS7RtFyin8SCGuILTv7dr0UvNXdy+lkmw6gt 46lbb7e7SAbG3wPYxmMRziNo3SVbexsqaLoZEYre/fJjgEN/VVrbanshFcCDXZbcrKmd pGITYN5Rk1rxpYPYaNtZAyYtWrw3qpYdCzAATmHSZ/YyGO/+x8PWcQIV9XBl73elLLql ah4GVeG7arkBloAIEXhpDp+wHUj9Tl+K+j+qZgXYScVpBACXbYucqwsY44qbFx27FD5L S6KAQNdtajA7l8GH/NgdcOh7pzEMBp+z6tusqj/CL0PeuAXlJiEI9K+WX17gMRaghz++ rhYg== X-Gm-Message-State: ALoCoQkAfFBQoEAEctpN7+e1y6jb8z+5q+ex63CApk6O81Q60sdFpL63rTaJEkgMLOnDNs9UcNGR X-Received: by 10.14.183.132 with SMTP id q4mr739179eem.91.1392101776366; Mon, 10 Feb 2014 22:56:16 -0800 (PST) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id j41sm63625854eeg.10.2014.02.10.22.56.14 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 10 Feb 2014 22:56:15 -0800 (PST) From: Michal Simek To: linux-kernel@vger.kernel.org, monstr@monstr.eu Subject: [PATCH v2 07/11] watchdog: xilinx: Use of_property_read_u32 Date: Tue, 11 Feb 2014 07:55:50 +0100 Message-Id: <7aa6e41032ebad0ffb2e1df20beb4f00e38d29e2.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_015638_536715_AACD399B X-CRM114-Status: GOOD ( 14.63 ) X-Spam-Score: -1.9 (-) Cc: devicetree@vger.kernel.org, linux-watchdog@vger.kernel.org, Wim Van Sebroeck , Rob Herring , linux-arm-kernel@lists.infradead.org, Grant Likely , 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 of_property_read_u32 functions to clean probe function. Signed-off-by: Michal Simek Reviewed-by: Guenter Roeck --- Changes in v2: - Fix enable_once logic - Change patch subject drivers/watchdog/of_xilinx_wdt.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) -- 1.8.2.3 diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c index c229cc4..bb03e5b 100644 --- a/drivers/watchdog/of_xilinx_wdt.c +++ b/drivers/watchdog/of_xilinx_wdt.c @@ -147,8 +147,7 @@ static u32 xwdt_selftest(struct xwdt_device *xdev) static int xwdt_probe(struct platform_device *pdev) { int rc; - u32 *tmptr; - u32 *pfreq; + u32 pfreq, enable_once = 0; struct resource *res; struct xwdt_device *xdev; bool no_timeout = false; @@ -168,32 +167,29 @@ static int xwdt_probe(struct platform_device *pdev) if (IS_ERR(xdev->base)) return PTR_ERR(xdev->base); - pfreq = (u32 *)of_get_property(pdev->dev.of_node, - "clock-frequency", NULL); - - if (pfreq == NULL) { + rc = of_property_read_u32(pdev->dev.of_node, "clock-frequency", &pfreq); + if (rc) { dev_warn(&pdev->dev, "The watchdog clock frequency cannot be obtained\n"); no_timeout = true; } - tmptr = (u32 *)of_get_property(pdev->dev.of_node, - "xlnx,wdt-interval", NULL); - if (tmptr == NULL) { + rc = of_property_read_u32(pdev->dev.of_node, "xlnx,wdt-interval", + &xdev->wdt_interval); + if (rc) { dev_warn(&pdev->dev, "Parameter \"xlnx,wdt-interval\" not found\n"); no_timeout = true; - } else { - xdev->wdt_interval = *tmptr; } - tmptr = (u32 *)of_get_property(pdev->dev.of_node, - "xlnx,wdt-enable-once", NULL); - if (tmptr == NULL) { + rc = of_property_read_u32(pdev->dev.of_node, "xlnx,wdt-enable-once", + &enable_once); + if (rc) dev_warn(&pdev->dev, "Parameter \"xlnx,wdt-enable-once\" not found\n"); + + if (enable_once) watchdog_set_nowayout(xilinx_wdt_wdd, true); - } /* * Twice of the 2^wdt_interval / freq because the first wdt overflow is @@ -201,7 +197,7 @@ static int xwdt_probe(struct platform_device *pdev) */ if (!no_timeout) xilinx_wdt_wdd->timeout = 2 * ((1 << xdev->wdt_interval) / - *pfreq); + pfreq); spin_lock_init(&xdev->spinlock); watchdog_set_drvdata(xilinx_wdt_wdd, xdev);