From patchwork Wed Apr 10 16:27:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E9B317E0 for ; Wed, 10 Apr 2019 16:29:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AAEB2885F for ; Wed, 10 Apr 2019 16:29:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F39C288CF; Wed, 10 Apr 2019 16:29:46 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED6CA286BD for ; Wed, 10 Apr 2019 16:29:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731763AbfDJQ3k (ORCPT ); Wed, 10 Apr 2019 12:29:40 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:42694 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387862AbfDJQ2Y (ORCPT ); Wed, 10 Apr 2019 12:28:24 -0400 Received: by mail-pl1-f194.google.com with SMTP id cv12so1733478plb.9; Wed, 10 Apr 2019 09:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=A8S7XSTI64ZGz7QExfklYyYSF03nx6KnqMOGBDym5s0=; b=JMQnMd0jgU/sfz3TH4kN8lc9efu1s4ojoJzK+hZapgzO2uNoLa5R5REyfo4/pbWIqo 3Bg98SiLvffA66jqYCDMEU5aLqPfWWYqgEQ2uiIzXVk0LDYLG08dm0L9arn3fGFtrnlb jIxov/WJdunwemW/Vh17ayT8aXISK7Ama6IzcmKK0Jz8J7Y4009uFj7/5xm/5C+EBAr3 5xf2o9fhpMbVlEbIwZxP0WM+fh0kIlC7m0EClSDHEqSOk6RJSqOmWZ0/syjq2gNPrmsD uay8TT93oUnfBH6xccDFckp/yDHZAS8qT1DMEfvwRBu6YSvlRC9HZ7gxxI+BVKmyb6IS GUYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=A8S7XSTI64ZGz7QExfklYyYSF03nx6KnqMOGBDym5s0=; b=CJzMOYwRK6pnr7+5UDvUbMEbROY+1rq/5oBNvVaw71ewamMcoX6okaqtwmkjiolQ2N x/QG17FZOPC156PS6gPnIbQEU5XbqoIKOul5czgFXOMAtIrGmTVNuZ7k/Iq3Jmdx7qXp lgCwHT7Xm31CiKSyGjbLKQK6T7yamH3Uj/dBcRlUsylz1NYzwjw4x/vi2jeUyfO2f0Zx feyIEpEsBWZPch+qfxPDqrQZSW7mEP9bOEnWrnbq7yldb8lXi8OKWu6LYz1SlReKzxWI K2DKTTc/g6qdhPuqWMg2tj+00FClnqzA7RD4DBWvTRlsVt3Wlvvh6YhfQrQshE3On1x3 Ef9g== X-Gm-Message-State: APjAAAWUKRAabe9crOMZDETJo9p6FPyybNRDz96gfIE+ztRG8T2Fgvha sDTWrBHQXYi29ePGvTZAsoY= X-Google-Smtp-Source: APXvYqxepkhR3FUPAhTEmfCpxVe8OwgJcM7oSnH0Oe6TpcQFP43WDl7lBVa05nAGT0iGXFtvYsEB3g== X-Received: by 2002:a17:902:da4:: with SMTP id 33mr13142734plv.20.1554913703373; Wed, 10 Apr 2019 09:28:23 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id f71sm51876276pfc.109.2019.04.10.09.28.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:22 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 11/22] watchdog: sbsa_gwdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:52 -0700 Message-Id: <1554913683-25454-12-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.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. Other improvements as listed below. 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 - Drop assignments to otherwise unused variables - Drop empty remove function - Use local variable 'struct device *dev' consistently - Use devm_watchdog_register_driver() to register watchdog device - Replace shutdown function with call to watchdog_stop_on_reboot() Signed-off-by: Guenter Roeck --- drivers/watchdog/sbsa_gwdt.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c index 68aff828bf7e..e17af8939c93 100644 --- a/drivers/watchdog/sbsa_gwdt.c +++ b/drivers/watchdog/sbsa_gwdt.c @@ -310,7 +310,8 @@ static int sbsa_gwdt_probe(struct platform_device *pdev) */ sbsa_gwdt_set_timeout(wdd, wdd->timeout); - ret = watchdog_register_device(wdd); + watchdog_stop_on_reboot(wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) return ret; @@ -321,22 +322,6 @@ static int sbsa_gwdt_probe(struct platform_device *pdev) return 0; } -static void sbsa_gwdt_shutdown(struct platform_device *pdev) -{ - struct sbsa_gwdt *gwdt = platform_get_drvdata(pdev); - - sbsa_gwdt_stop(&gwdt->wdd); -} - -static int sbsa_gwdt_remove(struct platform_device *pdev) -{ - struct sbsa_gwdt *gwdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(&gwdt->wdd); - - return 0; -} - /* Disable watchdog if it is active during suspend */ static int __maybe_unused sbsa_gwdt_suspend(struct device *dev) { @@ -382,8 +367,6 @@ static struct platform_driver sbsa_gwdt_driver = { .of_match_table = sbsa_gwdt_of_match, }, .probe = sbsa_gwdt_probe, - .remove = sbsa_gwdt_remove, - .shutdown = sbsa_gwdt_shutdown, .id_table = sbsa_gwdt_pdev_match, };