Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5128783yba; Wed, 10 Apr 2019 12:00:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwexT5XuCUld3dKUWTO/jyef+9UGBBugaZuNwuqs9idlh0jI/rbMBqPqnutkIDQL6FH1/kp X-Received: by 2002:a17:902:bd41:: with SMTP id b1mr46022015plx.221.1554922830900; Wed, 10 Apr 2019 12:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554922830; cv=none; d=google.com; s=arc-20160816; b=fvuErAW/baY1ZpEeXQSoi5d7MiejcctVVCbEGbqvgk17VynGt8BBL4s1jNdG1OVq2t ilXP2jPTrqHxa6yJcZexZtcoro4gGbV2HKWfPO5Wksl7/XEpUaJKQBNvK4oyEPeMrgzx YhAANgAjxajDfP/2QK6mkkl++ojJVN448tOs/pQxGh7ZQH6I88FwJdqGLXLwNXxO6DHn d9kYZhFWTE9OvnQC/lZftLhoJs1vZhggkBm9YBZF1+GE3w1sO9xVJ7yP9ZIYvoFWYC7x +Q4xbrFUNBKad9OV245pNeWK0ik1h40y6OrOB4D6BABVZWLaqDGCuDmZu0US0OfAbgHR eRvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ZIFkfAZMLG3ZtjNbK1/QwyzTqgHbls9I5r5J/yPn+AM=; b=M3rEKj8i9Q0o/kXAkrMx8QtFqGAou/QTbF7CtdKgPJh/uaOtzBDjXm2UfOGsK1DU1Q s1HOjvbWZuDg4pao2i9FzIRI0rWgUVOa60Bkl3Jzkly0YeJE57wD5iGMtV5r8CWd9rmn kOL8B9DWX7ijhfwNIT6gsxX7oInMWWfIE5qWqSvrS2Z9x49DW0V3RD5uAE8/gpUK0yeN 0QrVuF+TXG2gGe21goaw4evcxxDTNXIfRGHFL8C1yUXhf5n+HBdL1o6ko5iRXBkjXJP4 yIjMgeERz6xHhV0OsnZufDeCYpvRP5o9s37iVRdKaDdrpcKshxamJIoP9jRLxlQobNR2 IA4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UuzrEs3D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si32344115pgh.356.2019.04.10.12.00.14; Wed, 10 Apr 2019 12:00:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UuzrEs3D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732412AbfDJQ24 (ORCPT + 99 others); Wed, 10 Apr 2019 12:28:56 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33100 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387933AbfDJQ2f (ORCPT ); Wed, 10 Apr 2019 12:28:35 -0400 Received: by mail-pf1-f195.google.com with SMTP id h5so1806858pfo.0; Wed, 10 Apr 2019 09:28:34 -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=ZIFkfAZMLG3ZtjNbK1/QwyzTqgHbls9I5r5J/yPn+AM=; b=UuzrEs3D/iI4GnkUQsBc1f5DUUAWNrrCSXsMdOWmJOxXYH2MGmZffr+4yqKSZ3d1rS IXm+w43bLGo+1RzvRlYWQeF4k2eOFjV99y9SDZrcar7g9Jp26rLFn5pjC2ImL0qU6/PB S/N+eGn7dTQUOQY3zs6Zuqbn/cZnxfHowWx+fVOOTZS3nMLZvxvGQ/zBdN6YSUnwosee F5BeRvOmCrvsZH6hBKApEYTKeZqHTxZb+95Qa4iUrfnyxuzhJtdCd+YFZCDsFbugbmob m2oe6KXzTSLK+q27IXF8fHbAMNbRHh1EDYtWB2OABoWpN98RfIEWsDDdAoHAkcKkSE6Z RtmQ== 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=ZIFkfAZMLG3ZtjNbK1/QwyzTqgHbls9I5r5J/yPn+AM=; b=EPDOdsBEYPb7QJCKLOTQ2Q+jiH5fXcwzU3U77BtRf1erWf/FCLp+m9T853V/KE+jBw w/dbdEwzpGAbQyTDaR5tXS06sJk/YYlHkCUJANKeoGqWXszA6whwF8rNZbsVuk7ni+Mb /yTC/hAUJuNzfDNccYUdSP/s3G3fjzTW15c7J4mkUKMNuuB2K+2FrRaNmmWyYfU+bpqS fz49zJX8CcKyB1WrZq9kPBf30+AruBccRmIuSUYiT8dMQQzfFOkEebhl4zU6+papcwwb Ap/2dy8FP07dGVHP3v8CkzOhgApVz1kkmuK5FOypzuVg6Bkdgw+PFAyOi42w4svj3jDu slhg== X-Gm-Message-State: APjAAAXdaO8ByukW9vL1lE+JwYNEUlUj3e7zga8mK483GHPUaCbp7ChX HnpZZSrI7WKNS/lpP9TZay8= X-Received: by 2002:a63:36ce:: with SMTP id d197mr42761951pga.180.1554913714112; Wed, 10 Apr 2019 09:28:34 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id n5sm42295817pgp.80.2019.04.10.09.28.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:33 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 19/22] watchdog: rt2880_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:28:00 -0700 Message-Id: <1554913683-25454-20-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 empty remove function - Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly - 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/rt2880_wdt.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/watchdog/rt2880_wdt.c b/drivers/watchdog/rt2880_wdt.c index 4adf5f39fdd9..905e60f45eec 100644 --- a/drivers/watchdog/rt2880_wdt.c +++ b/drivers/watchdog/rt2880_wdt.c @@ -141,17 +141,18 @@ static struct watchdog_device rt288x_wdt_dev = { static int rt288x_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; rt288x_wdt_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(rt288x_wdt_base)) return PTR_ERR(rt288x_wdt_base); - rt288x_wdt_clk = devm_clk_get(&pdev->dev, NULL); + rt288x_wdt_clk = devm_clk_get(dev, NULL); if (IS_ERR(rt288x_wdt_clk)) return PTR_ERR(rt288x_wdt_clk); - rt288x_wdt_reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); + rt288x_wdt_reset = devm_reset_control_get_exclusive(dev, NULL); if (!IS_ERR(rt288x_wdt_reset)) reset_control_deassert(rt288x_wdt_reset); @@ -159,31 +160,20 @@ static int rt288x_wdt_probe(struct platform_device *pdev) rt288x_wdt_dev.bootstatus = rt288x_wdt_bootcause(); rt288x_wdt_dev.max_timeout = (0xfffful / rt288x_wdt_freq); - rt288x_wdt_dev.parent = &pdev->dev; + rt288x_wdt_dev.parent = dev; watchdog_init_timeout(&rt288x_wdt_dev, rt288x_wdt_dev.max_timeout, - &pdev->dev); + dev); watchdog_set_nowayout(&rt288x_wdt_dev, nowayout); - ret = watchdog_register_device(&rt288x_wdt_dev); + watchdog_stop_on_reboot(&rt288x_wdt_dev); + ret = devm_watchdog_register_device(dev, &rt288x_wdt_dev); if (!ret) - dev_info(&pdev->dev, "Initialized\n"); + dev_info(dev, "Initialized\n"); return 0; } -static int rt288x_wdt_remove(struct platform_device *pdev) -{ - watchdog_unregister_device(&rt288x_wdt_dev); - - return 0; -} - -static void rt288x_wdt_shutdown(struct platform_device *pdev) -{ - rt288x_wdt_stop(&rt288x_wdt_dev); -} - static const struct of_device_id rt288x_wdt_match[] = { { .compatible = "ralink,rt2880-wdt" }, {}, @@ -192,8 +182,6 @@ MODULE_DEVICE_TABLE(of, rt288x_wdt_match); static struct platform_driver rt288x_wdt_driver = { .probe = rt288x_wdt_probe, - .remove = rt288x_wdt_remove, - .shutdown = rt288x_wdt_shutdown, .driver = { .name = KBUILD_MODNAME, .of_match_table = rt288x_wdt_match, -- 2.7.4