From patchwork Wed Jan 11 00:44:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9508949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BE0FF6075F for ; Wed, 11 Jan 2017 00:47:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AED3728406 for ; Wed, 11 Jan 2017 00:47:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A282A28577; Wed, 11 Jan 2017 00:47:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 81F6F28406 for ; Wed, 11 Jan 2017 00:47:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cR74G-0002qA-ND; Wed, 11 Jan 2017 00:47:08 +0000 Received: from bh-25.webhostbox.net ([208.91.199.152]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cR74D-0002gF-7n for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2017 00:47:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From; bh=WoPysAqVzQFh95pGX3JNB0ykdNXeyJMkzQPp0ihKOIg=; b=O0YPUHY2qQhSl3 NJGHCFAhwuTDfNalLh/bWb/lFD85ur9U6ZMJS0XRW5u5HDuXddZ+KeMMkl1/l1TgGm12RSfqPA+gw rV+9pmb77Qb+vUL2tf0U73OfV9G4mJAdgBnJoeBgg7NGs6C+C7bIUrrPaYBcHAW64RbVDMsVQIlYN KeknnCvIKoGB5AMiW0RLuLfgVp8V57ern6d+Hohor/dYd/PwgH/jdZfEN+I49AoT5EmdoCOP3lNI4 rUzTe5tJVyCa2Q9xvCCGpgHH996U3K9EfO53V02pOZriCdJ3Jhk+ouMthm6ncSDgSsDA+PAR+oNuY k7vESdSMJZFL+HiikGVA==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:41694 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1cR73r-00213j-Sy; Wed, 11 Jan 2017 00:46:44 +0000 From: Guenter Roeck To: Wim Van Sebroeck Subject: [PATCH 44/62] watchdog: pnx4008_wdt: Convert to use device managed functions Date: Tue, 10 Jan 2017 16:44:53 -0800 Message-Id: <1484095516-12720-14-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484095516-12720-1-git-send-email-linux@roeck-us.net> References: <1484091325-9199-1-git-send-email-linux@roeck-us.net> <1484095516-12720-1-git-send-email-linux@roeck-us.net> X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170110_164705_357020_06CA162C X-CRM114-Status: GOOD ( 10.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Zapolskiy , Guenter Roeck , Sylvain Lemieux , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Use devm_add_action_or_reset() for calls to clk_disable_unprepare - Replace 'goto l; ... l: return e;' with 'return e;' - Drop remove function - Use devm_watchdog_register_driver() to register watchdog device Cc: Vladimir Zapolskiy Cc: Sylvain Lemieux Signed-off-by: Guenter Roeck Acked-by: Vladimir Zapolskiy --- drivers/watchdog/pnx4008_wdt.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c index 0529aed158a4..a0cda8748c9b 100644 --- a/drivers/watchdog/pnx4008_wdt.c +++ b/drivers/watchdog/pnx4008_wdt.c @@ -202,6 +202,11 @@ static int pnx4008_wdt_probe(struct platform_device *pdev) ret = clk_prepare_enable(wdt_clk); if (ret) return ret; + ret = devm_add_action_or_reset(&pdev->dev, + (void(*)(void *))clk_disable_unprepare, + wdt_clk); + if (ret) + return ret; pnx4008_wdd.bootstatus = (readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ? WDIOF_CARDRESET : 0; @@ -211,28 +216,15 @@ static int pnx4008_wdt_probe(struct platform_device *pdev) pnx4008_wdt_stop(&pnx4008_wdd); /* disable for now */ - ret = watchdog_register_device(&pnx4008_wdd); + ret = devm_watchdog_register_device(&pdev->dev, &pnx4008_wdd); if (ret < 0) { dev_err(&pdev->dev, "cannot register watchdog device\n"); - goto disable_clk; + return ret; } dev_info(&pdev->dev, "heartbeat %d sec\n", pnx4008_wdd.timeout); return 0; - -disable_clk: - clk_disable_unprepare(wdt_clk); - return ret; -} - -static int pnx4008_wdt_remove(struct platform_device *pdev) -{ - watchdog_unregister_device(&pnx4008_wdd); - - clk_disable_unprepare(wdt_clk); - - return 0; } #ifdef CONFIG_OF @@ -249,7 +241,6 @@ static struct platform_driver platform_wdt_driver = { .of_match_table = of_match_ptr(pnx4008_wdt_match), }, .probe = pnx4008_wdt_probe, - .remove = pnx4008_wdt_remove, }; module_platform_driver(platform_wdt_driver);