From patchwork Mon Apr 8 19:38:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890045 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 3849C1805 for ; Mon, 8 Apr 2019 19:41:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2371F285A4 for ; Mon, 8 Apr 2019 19:41:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 178A9286FE; Mon, 8 Apr 2019 19:41:38 +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 A334C285A4 for ; Mon, 8 Apr 2019 19:41:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727722AbfDHTjk (ORCPT ); Mon, 8 Apr 2019 15:39:40 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44879 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726068AbfDHTjj (ORCPT ); Mon, 8 Apr 2019 15:39:39 -0400 Received: by mail-pl1-f196.google.com with SMTP id g12so7892029pll.11; Mon, 08 Apr 2019 12:39:39 -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=9QzejewaFdMKjPQNyj8Ku/+3qlbUdJ83+naJQ570xrE=; b=GNfv6zDb32qh0zEdHefmpQoYu8Ae0k0ZB2yN9h/QU604LhJHiGC4pl1W1buJKJi9FA cEwLxHJiqXiPBYDvW8NJPZ+//sbOb4jqss+tO5PydCFcqQs4xKrK9YE0wA9rOCv8dP2G h3cU5LOac7EQ8gAH9DwrJ2SI7BVa+o3skRdKt+Egrzu89OLL7/V2oc0Mz2Eu2n6ML7+e VsuEJVqJGI4gaS0zXkcJSfkE0DgjsZYlauwnwm1pN+j/xi221V1LqODX+sGGyVZplzrn iMJmJWG1eTxVaUu09GETwIMWQzjHLy/XyQUyFL9SUwA5pHTjpS7jJApNpXNLKGU8AIOP XZjA== 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=9QzejewaFdMKjPQNyj8Ku/+3qlbUdJ83+naJQ570xrE=; b=D+ECQul8S0qDFhzmqCIylVT4FL1YBb6W8Cd7O7olzbA6CymGiod78Am9IvFBdi5lpy ueM2TyVRqv2oCiQumyiHRJF0GzayuVVb1uoDf2Nm+m7nS6YFNQ++JUDS570h0R6oWRjG HqRrNcr4TFoEIE2uY7eHMQyWFaJEqdM46DKWi8V6PMmcW1k3M/ek4A5F90wmjMvzCTEh hGIwSD050uCMj4DUTYxI1z1gb9wxTHgWqg3LPqoh1uh5DaNnP8etQNzSezPwAVe77sNc czByJn9J76uQLngl+kvgd4hoBjU4LUVw890TAqiuYtCQ6kQuPQoNkIPCEd/GY+cjum/A 0pmQ== X-Gm-Message-State: APjAAAVOOPrXc77HZyu09/vEsrm/2woPchep4ZGTRReDnmznoB6Xmv0C Pa17aDWt/2lFslofNA+w9q00g5y2 X-Google-Smtp-Source: APXvYqx9fezUY/IN0+pySCDULfKzbUUQcMoeOk1G1rU9Kk96vk8IYC1XFFWQGF5QS34GjNHPP1hsuw== X-Received: by 2002:a17:902:f81:: with SMTP id 1mr32624572plz.216.1554752378716; Mon, 08 Apr 2019 12:39:38 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id n1sm35371700pgv.19.2019.04.08.12.39.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:38 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 01/22] watchdog: armada_37xx_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:25 -0700 Message-Id: <1554752326-13319-2-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 unnecessary braces around conditional return statements - Drop empty remove function - Use devm_add_action_or_reset() for calls to clk_disable_unprepare - 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/armada_37xx_wdt.c | 43 +++++++++++++------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/drivers/watchdog/armada_37xx_wdt.c b/drivers/watchdog/armada_37xx_wdt.c index 4b4054f54df9..e5dcb26d85f0 100644 --- a/drivers/watchdog/armada_37xx_wdt.c +++ b/drivers/watchdog/armada_37xx_wdt.c @@ -244,6 +244,11 @@ static const struct watchdog_ops armada_37xx_wdt_ops = { .get_timeleft = armada_37xx_wdt_get_timeleft, }; +static void armada_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int armada_37xx_wdt_probe(struct platform_device *pdev) { struct armada_37xx_watchdog *dev; @@ -278,12 +283,14 @@ static int armada_37xx_wdt_probe(struct platform_device *pdev) ret = clk_prepare_enable(dev->clk); if (ret) return ret; + ret = devm_add_action_or_reset(&pdev->dev, + armada_clk_disable_unprepare, dev->clk); + if (ret) + return ret; dev->clk_rate = clk_get_rate(dev->clk); - if (!dev->clk_rate) { - ret = -EINVAL; - goto disable_clk; - } + if (!dev->clk_rate) + return -EINVAL; /* * Since the timeout in seconds is given as 32 bit unsigned int, and @@ -307,35 +314,15 @@ static int armada_37xx_wdt_probe(struct platform_device *pdev) set_bit(WDOG_HW_RUNNING, &dev->wdt.status); watchdog_set_nowayout(&dev->wdt, nowayout); - ret = watchdog_register_device(&dev->wdt); + watchdog_stop_on_reboot(&dev->wdt); + ret = devm_watchdog_register_device(&pdev->dev, &dev->wdt); if (ret) - goto disable_clk; + return ret; dev_info(&pdev->dev, "Initial timeout %d sec%s\n", dev->wdt.timeout, nowayout ? ", nowayout" : ""); return 0; - -disable_clk: - clk_disable_unprepare(dev->clk); - return ret; -} - -static int armada_37xx_wdt_remove(struct platform_device *pdev) -{ - struct watchdog_device *wdt = platform_get_drvdata(pdev); - struct armada_37xx_watchdog *dev = watchdog_get_drvdata(wdt); - - watchdog_unregister_device(wdt); - clk_disable_unprepare(dev->clk); - return 0; -} - -static void armada_37xx_wdt_shutdown(struct platform_device *pdev) -{ - struct watchdog_device *wdt = platform_get_drvdata(pdev); - - armada_37xx_wdt_stop(wdt); } static int __maybe_unused armada_37xx_wdt_suspend(struct device *dev) @@ -370,8 +357,6 @@ MODULE_DEVICE_TABLE(of, armada_37xx_wdt_match); static struct platform_driver armada_37xx_wdt_driver = { .probe = armada_37xx_wdt_probe, - .remove = armada_37xx_wdt_remove, - .shutdown = armada_37xx_wdt_shutdown, .driver = { .name = "armada_37xx_wdt", .of_match_table = of_match_ptr(armada_37xx_wdt_match), From patchwork Mon Apr 8 19:38:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890043 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 BB6561669 for ; Mon, 8 Apr 2019 19:41:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A453F285EB for ; Mon, 8 Apr 2019 19:41:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98BB6286FE; Mon, 8 Apr 2019 19:41:37 +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 0C1A5285A4 for ; Mon, 8 Apr 2019 19:41:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727833AbfDHTjl (ORCPT ); Mon, 8 Apr 2019 15:39:41 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45943 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727756AbfDHTjl (ORCPT ); Mon, 8 Apr 2019 15:39:41 -0400 Received: by mail-pf1-f194.google.com with SMTP id e24so8192417pfi.12; Mon, 08 Apr 2019 12:39:40 -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=P0UJoYAqIWL8MWfY4mue8flNXi0lxQzA3Ojf53WPbeQ=; b=CR9gD2hfp1sTXzlbkMBXjvJNPhVopjkJzMGnLmhYgwPlFwqAvRttLfydjCIt3BWFkA UbTMKmbE93FugnPJ2OID2WtMBO9ZNX/ojJHHQvuleAcjZPudGaEKp4UBsiCdrFy6em50 8gknuqJuuV7OBR4UiL/B8bMF7qSgpKapyrV16/WZfJZB0BJDAW1voYSCMqycciplJpiZ mN3Q4tVMzGHXKttU5nuBawh+WsNO0oM5x3PJc7NawJ8VnTB7jQRq+g5/Q2M6XNIbw+xL 0C5YS+piYWQl/ltpmZ9RGky8cgIWOzCNNrXFjn+8s96ySwHEJOzuRmJlD8l1HV0M/Ocr CcIw== 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=P0UJoYAqIWL8MWfY4mue8flNXi0lxQzA3Ojf53WPbeQ=; b=tzVKVFypnJgdgc/LxK9S9YZ3NSaxflXfVtTqCjIpx87IzKAsMA1SBbbaz/yVZrHo95 kICt0srXECw67kklgacD3QOE0RrXxA4WV/rlZ78tk+E8LACtW74WgicztgGeWPnv7WXx DfywBFx6oKGUwyURP5FsBYS3TELEprdPqFbDYs/TdRsSyP9o0+62go1x7EPGzszJ1HXR p9wYfHnL0repS/74c3fHKxBORGB/0vwinuAgG4SghRVwEP9+sgMr4M1kQkj6la50pcTm jjIaeuvVjqntgFFSbe4jm8jDT5dFzUTw2+Js/muoKX6WGQKyMVOxXvgiCYHYJ0sTPg3z G6Mw== X-Gm-Message-State: APjAAAUfJQsZHYW6qNfndAgGzYL0OEPiFLdIVW28DoLw9JbwShfeIFcx e/2NEslmkXuC0rh8aDkzWRzsgXRC X-Google-Smtp-Source: APXvYqx0xd9x3HdNECU1T29vgKjUPtLinL40XEYbBTLflWJGF5IAvYPq0bv96YW6DoRqOGsz4OCdmA== X-Received: by 2002:a62:1d94:: with SMTP id d142mr30962597pfd.83.1554752380107; Mon, 08 Apr 2019 12:39:40 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e4sm41600993pgd.32.2019.04.08.12.39.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:39 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 02/22] watchdog: asm9260_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:26 -0700 Message-Id: <1554752326-13319-3-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 devm_add_action_or_reset() for calls to clk_disable_unprepare - Replace 'goto l; ... l: return e;' with 'return e;' - 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/asm9260_wdt.c | 73 +++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 44 deletions(-) diff --git a/drivers/watchdog/asm9260_wdt.c b/drivers/watchdog/asm9260_wdt.c index 1de272bb2070..c5b9aae544dd 100644 --- a/drivers/watchdog/asm9260_wdt.c +++ b/drivers/watchdog/asm9260_wdt.c @@ -196,6 +196,11 @@ static const struct watchdog_ops asm9260_wdt_ops = { .restart = asm9260_restart, }; +static void asm9260_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int asm9260_wdt_get_dt_clks(struct asm9260_wdt_priv *priv) { int err; @@ -219,26 +224,32 @@ static int asm9260_wdt_get_dt_clks(struct asm9260_wdt_priv *priv) dev_err(priv->dev, "Failed to enable ahb_clk!\n"); return err; } + err = devm_add_action_or_reset(priv->dev, + asm9260_clk_disable_unprepare, + priv->clk_ahb); + if (err) + return err; err = clk_set_rate(priv->clk, CLOCK_FREQ); if (err) { - clk_disable_unprepare(priv->clk_ahb); dev_err(priv->dev, "Failed to set rate!\n"); return err; } err = clk_prepare_enable(priv->clk); if (err) { - clk_disable_unprepare(priv->clk_ahb); dev_err(priv->dev, "Failed to enable clk!\n"); return err; } + err = devm_add_action_or_reset(priv->dev, + asm9260_clk_disable_unprepare, + priv->clk); + if (err) + return err; /* wdt has internal divider */ clk = clk_get_rate(priv->clk); if (!clk) { - clk_disable_unprepare(priv->clk); - clk_disable_unprepare(priv->clk_ahb); dev_err(priv->dev, "Failed, clk is 0!\n"); return -EINVAL; } @@ -274,23 +285,23 @@ static void asm9260_wdt_get_dt_mode(struct asm9260_wdt_priv *priv) static int asm9260_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct asm9260_wdt_priv *priv; struct watchdog_device *wdd; int ret; static const char * const mode_name[] = { "hw", "sw", "debug", }; - priv = devm_kzalloc(&pdev->dev, sizeof(struct asm9260_wdt_priv), - GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(struct asm9260_wdt_priv), GFP_KERNEL); if (!priv) return -ENOMEM; - priv->dev = &pdev->dev; + priv->dev = dev; priv->iobase = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(priv->iobase)) return PTR_ERR(priv->iobase); - priv->rst = devm_reset_control_get_exclusive(&pdev->dev, "wdt_rst"); + priv->rst = devm_reset_control_get_exclusive(dev, "wdt_rst"); if (IS_ERR(priv->rst)) return PTR_ERR(priv->rst); @@ -303,7 +314,7 @@ static int asm9260_wdt_probe(struct platform_device *pdev) wdd->ops = &asm9260_wdt_ops; wdd->min_timeout = 1; wdd->max_timeout = BM_WDTC_MAX(priv->wdt_freq); - wdd->parent = &pdev->dev; + wdd->parent = dev; watchdog_set_drvdata(wdd, priv); @@ -313,7 +324,7 @@ static int asm9260_wdt_probe(struct platform_device *pdev) * the max instead. */ wdd->timeout = ASM9260_WDT_DEFAULT_TIMEOUT; - watchdog_init_timeout(wdd, 0, &pdev->dev); + watchdog_init_timeout(wdd, 0, dev); asm9260_wdt_get_dt_mode(priv); @@ -325,49 +336,25 @@ static int asm9260_wdt_probe(struct platform_device *pdev) * Not all supported platforms specify an interrupt for the * watchdog, so let's make it optional. */ - ret = devm_request_irq(&pdev->dev, priv->irq, - asm9260_wdt_irq, 0, pdev->name, priv); + ret = devm_request_irq(dev, priv->irq, asm9260_wdt_irq, 0, + pdev->name, priv); if (ret < 0) - dev_warn(&pdev->dev, "failed to request IRQ\n"); + dev_warn(dev, "failed to request IRQ\n"); } watchdog_set_restart_priority(wdd, 128); - ret = watchdog_register_device(wdd); + watchdog_stop_on_reboot(wdd); + watchdog_stop_on_unregister(wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) - goto clk_off; + return ret; platform_set_drvdata(pdev, priv); - dev_info(&pdev->dev, "Watchdog enabled (timeout: %d sec, mode: %s)\n", + dev_info(dev, "Watchdog enabled (timeout: %d sec, mode: %s)\n", wdd->timeout, mode_name[priv->mode]); return 0; - -clk_off: - clk_disable_unprepare(priv->clk); - clk_disable_unprepare(priv->clk_ahb); - return ret; -} - -static void asm9260_wdt_shutdown(struct platform_device *pdev) -{ - struct asm9260_wdt_priv *priv = platform_get_drvdata(pdev); - - asm9260_wdt_disable(&priv->wdd); -} - -static int asm9260_wdt_remove(struct platform_device *pdev) -{ - struct asm9260_wdt_priv *priv = platform_get_drvdata(pdev); - - asm9260_wdt_disable(&priv->wdd); - - watchdog_unregister_device(&priv->wdd); - - clk_disable_unprepare(priv->clk); - clk_disable_unprepare(priv->clk_ahb); - - return 0; } static const struct of_device_id asm9260_wdt_of_match[] = { @@ -382,8 +369,6 @@ static struct platform_driver asm9260_wdt_driver = { .of_match_table = asm9260_wdt_of_match, }, .probe = asm9260_wdt_probe, - .remove = asm9260_wdt_remove, - .shutdown = asm9260_wdt_shutdown, }; module_platform_driver(asm9260_wdt_driver); From patchwork Mon Apr 8 19:38:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890041 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 9F568922 for ; Mon, 8 Apr 2019 19:41:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89F34285A4 for ; Mon, 8 Apr 2019 19:41:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CB2A286FE; Mon, 8 Apr 2019 19:41:35 +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 F0677285A4 for ; Mon, 8 Apr 2019 19:41:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728019AbfDHTjm (ORCPT ); Mon, 8 Apr 2019 15:39:42 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46368 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727878AbfDHTjm (ORCPT ); Mon, 8 Apr 2019 15:39:42 -0400 Received: by mail-pf1-f193.google.com with SMTP id 9so8194339pfj.13; Mon, 08 Apr 2019 12:39:41 -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=kepgUGpZfR5uAkMzvzU4BdaVdRicSAbSlfhmAD09THE=; b=u9mfTKe2I2QPmesjPlwcFJ284y6eMgvW1Ic8EFkZzputOYSc6tI0BALxPeFBNbYc/e Ga6g01BLlU2zfRgLDtbJoLiKisdeXJlS84z9VYnfUrsG2SeoeLZrLAfM337YErwV6con pxfQ7yeiGKlILWmBhEcZriU9l2HZYKz0e+7JAAmXyzdOuhms31hqSp0p/3nG2gbMlfAL AszmoJRA42SqoOEgCj8JW3wyFLNF8cNnUfq6rTbg8Xa5sdubc6qibPT1U8jEMp3PGoCK 8eX10nQokZguMA7Usx9sZH1AsMV8BLtkcataYL6qbyfIbG4r2KVR850LSv7NqRqntimp jZyQ== 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=kepgUGpZfR5uAkMzvzU4BdaVdRicSAbSlfhmAD09THE=; b=PnEjk0Gj9nkax3DDCAM+ZBMCpu++64gUoT1V9iRHoCv3ugaZLk8scaDepp2Jy8fw6m zlCVI/EQMHyJnlGQfWiSmo5WOoLLx0vlnGPIVcfCNUXep1IQsmtX3FRs1OGDmDV5DnRm YctvKSjWPvoveGYDfX2Fu0OobVusIDuUlRkjIvRyLB1fpbseUV2TQ1FYjK0E06E6nO9g PtiYBgEDzhX4ll85iqKVLiIEZJstRgOUoCGdsqFPUsWFhEWJubVQgSLUu82hwXy6RPzy N071CdnLmY52VncWb4EwC4PyGGXQb/gFWxFyyGAEih3BjXGm75ssNpsbkN5T24Da34yQ IQnw== X-Gm-Message-State: APjAAAUlydOivJUfLCFZ34ZFiP6LD8ehmG3RlaJJq9iKeGpWoeOeTzwl lEZ9gm+1ebxLgD32GvBMHUdbU9Vk X-Google-Smtp-Source: APXvYqwiGzJbVJFaGS/pS5vsSDZWgfVEo+PIdWkL41UK9fWJ8HBjeGzhJ3DZdKhsblibK5DsZRprqQ== X-Received: by 2002:a63:1d4f:: with SMTP id d15mr3134625pgm.347.1554752381464; Mon, 08 Apr 2019 12:39:41 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id g67sm47921553pfg.94.2019.04.08.12.39.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:41 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Joel Stanley , Andrew Jeffery Subject: [PATCH 03/22] watchdog: aspeed_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Mon, 8 Apr 2019 12:38:27 -0700 Message-Id: <1554752326-13319-4-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly. 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 Cc: Joel Stanley Cc: Andrew Jeffery Signed-off-by: Guenter Roeck Reviewed-by: Andrew Jeffery --- drivers/watchdog/aspeed_wdt.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c index f09333fd54b4..34117745c65f 100644 --- a/drivers/watchdog/aspeed_wdt.c +++ b/drivers/watchdog/aspeed_wdt.c @@ -187,6 +187,7 @@ static const struct watchdog_info aspeed_wdt_info = { static int aspeed_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; const struct aspeed_wdt_config *config; const struct of_device_id *ofdid; struct aspeed_wdt *wdt; @@ -196,7 +197,7 @@ static int aspeed_wdt_probe(struct platform_device *pdev) u32 status; int ret; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -212,12 +213,12 @@ static int aspeed_wdt_probe(struct platform_device *pdev) wdt->wdd.info = &aspeed_wdt_info; wdt->wdd.ops = &aspeed_wdt_ops; wdt->wdd.max_hw_heartbeat_ms = WDT_MAX_TIMEOUT_MS; - wdt->wdd.parent = &pdev->dev; + wdt->wdd.parent = dev; wdt->wdd.timeout = WDT_DEFAULT_TIMEOUT; - watchdog_init_timeout(&wdt->wdd, 0, &pdev->dev); + watchdog_init_timeout(&wdt->wdd, 0, dev); - np = pdev->dev.of_node; + np = dev->of_node; ofdid = of_match_node(aspeed_wdt_of_table, np); if (!ofdid) @@ -286,11 +287,11 @@ static int aspeed_wdt_probe(struct platform_device *pdev) u32 max_duration = config->ext_pulse_width_mask + 1; if (duration == 0 || duration > max_duration) { - dev_err(&pdev->dev, "Invalid pulse duration: %uus\n", - duration); + dev_err(dev, "Invalid pulse duration: %uus\n", + duration); duration = max(1U, min(max_duration, duration)); - dev_info(&pdev->dev, "Pulse duration set to %uus\n", - duration); + dev_info(dev, "Pulse duration set to %uus\n", + duration); } /* @@ -312,9 +313,9 @@ static int aspeed_wdt_probe(struct platform_device *pdev) if (status & WDT_TIMEOUT_STATUS_BOOT_SECONDARY) wdt->wdd.bootstatus = WDIOF_CARDRESET; - ret = devm_watchdog_register_device(&pdev->dev, &wdt->wdd); + ret = devm_watchdog_register_device(dev, &wdt->wdd); if (ret) { - dev_err(&pdev->dev, "failed to register\n"); + dev_err(dev, "failed to register\n"); return ret; } From patchwork Mon Apr 8 19:38:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890039 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 E09821669 for ; Mon, 8 Apr 2019 19:41:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAE4C285A4 for ; Mon, 8 Apr 2019 19:41:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF38B286FE; Mon, 8 Apr 2019 19:41:30 +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 47641285A4 for ; Mon, 8 Apr 2019 19:41:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727285AbfDHTlX (ORCPT ); Mon, 8 Apr 2019 15:41:23 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:45907 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728548AbfDHTjo (ORCPT ); Mon, 8 Apr 2019 15:39:44 -0400 Received: by mail-pl1-f196.google.com with SMTP id bf11so7891432plb.12; Mon, 08 Apr 2019 12:39:43 -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=Jneh01n1+bIhANgepGSuhAjCJdMw/IuW338uETIBMa8=; b=N4LymmXzj+cfs0sFJ+tcmMXo15eMUNCQAdAfR9ZvQAhNz4WWzE710lnjAVplzdAI4s p5jDuXvGl1WWIir/esDEUMoPPMuNsMYtiFb28JPdnafAjnzUvUKIDDJRDyqk0w8cGKdH kQCy4HMEehk2AUZ2e855/wyxXcoCuVn/JBDOsYWJFeIxHAOAktKtTnXWrMNHzFnIE1hU 83fdAV7ppxUkO9NL1uOtw2I/q0WIoyMIX+T3UZlmA2DVrkHMFQTQ1lrp6YwK8xV0Txu7 EszVtobE1bTijON+tgeCvvbrXy7E2+C2Sf+cR9JsRDJg3MkUYcJdx8xCVVVDgcprv7IK hiCQ== 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=Jneh01n1+bIhANgepGSuhAjCJdMw/IuW338uETIBMa8=; b=Gadin6sJxlMRblGuf5JfJWc/THNE2uWJUwUrHZUu6sfphmcvAVXi+soWU6ZUART7jW yFcG6VHGhhqanjG/x+sHoblvpqQzKugxO3C20wZTYtl/I5L1WGDSFDvj+tboPpRsT7Wo gsH5Efk3uO3pZaBavmiTq8MNMjjqSBmxflNYbNeY4+8HbugF4ewdGmEEDYArRlV843VQ fRrORCIpizNKCO73p1icZO/4huH/KnlhaX2RQF2hLrkwEiZ8Pf1M+LQIzlJ/YZKQncE3 EgdCwTAqTsuiuMB02iyg4KrXF8sgg8RSvc0jOlUHbkZ3HB0QQKFEIdMU3MDmSbkQ33/B dVpg== X-Gm-Message-State: APjAAAVgeYe+d3u9RrVKNDOAqw2Xk1cmrIJO/hYf1enoaKNSubaP/qnM a0Yb6yZ5HWgKbhrYnpe+QYU= X-Google-Smtp-Source: APXvYqy41qvPRPhPSOP1qoziMgnoeg/x0mdw6RZnOZQCJ29M+Oekz5gsa6+YkF2v1pxhpJIkjPvINw== X-Received: by 2002:a17:902:4101:: with SMTP id e1mr31119676pld.25.1554752382864; Mon, 08 Apr 2019 12:39:42 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b2sm36481508pfo.150.2019.04.08.12.39.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:42 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 04/22] watchdog: atlas7_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:28 -0700 Message-Id: <1554752326-13319-5-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 unnecessary braces around conditional return statements - Drop empty remove function - Use devm_add_action_or_reset() for calls to clk_disable_unprepare - Replace 'of_clk_get(np, 0)' with 'devm_clk_get(dev, NULL)' - 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/atlas7_wdt.c | 61 ++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 42 deletions(-) diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c index e170933aa0a8..79337d2a8a8e 100644 --- a/drivers/watchdog/atlas7_wdt.c +++ b/drivers/watchdog/atlas7_wdt.c @@ -125,78 +125,57 @@ static const struct of_device_id atlas7_wdt_ids[] = { {} }; +static void atlas7_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int atlas7_wdt_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; struct atlas7_wdog *wdt; struct clk *clk; int ret; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; wdt->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(wdt->base)) return PTR_ERR(wdt->base); - clk = of_clk_get(np, 0); + clk = devm_clk_get(dev, NULL); if (IS_ERR(clk)) return PTR_ERR(clk); ret = clk_prepare_enable(clk); if (ret) { - dev_err(&pdev->dev, "clk enable failed\n"); - goto err; + dev_err(dev, "clk enable failed\n"); + return ret; } + ret = devm_add_action_or_reset(dev, atlas7_clk_disable_unprepare, clk); + if (ret) + return ret; /* disable watchdog hardware */ writel(0, wdt->base + ATLAS7_WDT_CNT_CTRL); wdt->tick_rate = clk_get_rate(clk); - if (!wdt->tick_rate) { - ret = -EINVAL; - goto err1; - } + if (!wdt->tick_rate) + return -EINVAL; wdt->clk = clk; atlas7_wdd.min_timeout = 1; atlas7_wdd.max_timeout = UINT_MAX / wdt->tick_rate; - watchdog_init_timeout(&atlas7_wdd, 0, &pdev->dev); + watchdog_init_timeout(&atlas7_wdd, 0, dev); watchdog_set_nowayout(&atlas7_wdd, nowayout); watchdog_set_drvdata(&atlas7_wdd, wdt); platform_set_drvdata(pdev, &atlas7_wdd); - ret = watchdog_register_device(&atlas7_wdd); - if (ret) - goto err1; - - return 0; - -err1: - clk_disable_unprepare(clk); -err: - clk_put(clk); - return ret; -} - -static void atlas7_wdt_shutdown(struct platform_device *pdev) -{ - struct watchdog_device *wdd = platform_get_drvdata(pdev); - struct atlas7_wdog *wdt = watchdog_get_drvdata(wdd); - - atlas7_wdt_disable(wdd); - clk_disable_unprepare(wdt->clk); -} - -static int atlas7_wdt_remove(struct platform_device *pdev) -{ - struct watchdog_device *wdd = platform_get_drvdata(pdev); - struct atlas7_wdog *wdt = watchdog_get_drvdata(wdd); - - atlas7_wdt_shutdown(pdev); - clk_put(wdt->clk); - return 0; + watchdog_stop_on_reboot(&atlas7_wdd); + watchdog_stop_on_unregister(&atlas7_wdd); + return devm_watchdog_register_device(dev, &atlas7_wdd); } static int __maybe_unused atlas7_wdt_suspend(struct device *dev) @@ -234,8 +213,6 @@ static struct platform_driver atlas7_wdt_driver = { .of_match_table = atlas7_wdt_ids, }, .probe = atlas7_wdt_probe, - .remove = atlas7_wdt_remove, - .shutdown = atlas7_wdt_shutdown, }; module_platform_driver(atlas7_wdt_driver); From patchwork Mon Apr 8 19:38:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890035 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 92D8F922 for ; Mon, 8 Apr 2019 19:41:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D7ED285A4 for ; Mon, 8 Apr 2019 19:41:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7153C286FE; Mon, 8 Apr 2019 19:41:17 +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 19D9D285A4 for ; Mon, 8 Apr 2019 19:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728666AbfDHTjq (ORCPT ); Mon, 8 Apr 2019 15:39:46 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41457 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727878AbfDHTjo (ORCPT ); Mon, 8 Apr 2019 15:39:44 -0400 Received: by mail-pf1-f195.google.com with SMTP id 188so8206851pfd.8; Mon, 08 Apr 2019 12:39:44 -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=sLZWoglaHpenSl2BSHPcSajCjhQskwq7KOznv+AB9hQ=; b=YIK46fsThrj89x1NgCCmjcgIQWAkmKUaXF+QMCneAMPTflM95ST0ulTKCzPLh8mKZc pnUbX2O8MyZJdPUJ0YvY+SbBY58ClOuizmIWcFXVlv+MtFUwO5zw6UJNIqF5ji1yCS9D ApGAtwsk8/UwdCDbhyjVmZQ1+RuknbAwpUkOLtEPktoO8PZ8IzdfXjc2KyeUrKY9bUO/ 7sucP2i7VWdR3qzJmIbRVO0AVv6Irc/5GbakUVb5ycgFXf3qOXnJZEEiRgYBpmxCfLVt +ooUJcOneFtBBVqfeDnp3h0+dpfxgPoAgEXeG+d5N09+ljgcbCFXMCyML6o9A/VpyH4a V8/w== 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=sLZWoglaHpenSl2BSHPcSajCjhQskwq7KOznv+AB9hQ=; b=Ebe1ixZzLfg3E4zHU8vut6uZfTSTd0s71PkPJTj+Tco0CkzvlTI2p6/XkgZF7k72Gs RMf1AmqczQLUe+AXEyYjkUNm8XwHI6W2+AYijgBGQoWKSqGHJkHttkgrbBgffbWg9Nil UzWsPu/xHZaHLSHbPAdHIQBpQ8ERazJco2XNlCUtkLG1zpp1wPeKonDE06vPDtOblgaE z1BX1IUTVVhHyngow1kw0oCKnOMvFXoRRuwrcd8MS4DiKAB7+0FDUO/o98pQjlG0Y8dl u/5/3a6v1UfbQ0q0ueS9D/7F1/xbXt7hOoXPszIVKuXnbyIdcbXF0zZHrN0xEvp9vEAp VfRA== X-Gm-Message-State: APjAAAUwszT/QeMamFYvIW96ko5so0CqUy/lxTmW4hQ1wKKJKEq7yiJ4 CQjJssZcJpLlBav85q1xe8M= X-Google-Smtp-Source: APXvYqzwNBx8JMyKR0M/FLo+aFaFrbzYZe2Nhz9Nr02BXWQTgAGekWQa94t69mZgu+ghrPJmQzzctA== X-Received: by 2002:a63:6a45:: with SMTP id f66mr28876087pgc.7.1554752384264; Mon, 08 Apr 2019 12:39:44 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 17sm70509493pfw.65.2019.04.08.12.39.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:43 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Eric Anholt , Stefan Wahren Subject: [PATCH 05/22] watchdog: bcm2835_wdt: drop platform_set_drvdata Date: Mon, 8 Apr 2019 12:38:29 -0700 Message-Id: <1554752326-13319-6-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 There is no call to platform_get_drvdata() in the driver, so platform_set_drvdata() is unnecessary and can be dropped. 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 Cc: Florian Fainelli Cc: Ray Jui Cc: Scott Branden Cc: bcm-kernel-feedback-list@broadcom.com Cc: Eric Anholt Cc: Stefan Wahren Signed-off-by: Guenter Roeck Acked-by: Stefan Wahren --- drivers/watchdog/bcm2835_wdt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c index 1834524ae373..560c1c54c177 100644 --- a/drivers/watchdog/bcm2835_wdt.c +++ b/drivers/watchdog/bcm2835_wdt.c @@ -177,7 +177,6 @@ static int bcm2835_wdt_probe(struct platform_device *pdev) wdt = devm_kzalloc(dev, sizeof(struct bcm2835_wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; - platform_set_drvdata(pdev, wdt); spin_lock_init(&wdt->lock); From patchwork Mon Apr 8 19:38:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890037 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 BEB081669 for ; Mon, 8 Apr 2019 19:41:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8B9A285A4 for ; Mon, 8 Apr 2019 19:41:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D53F286FE; Mon, 8 Apr 2019 19:41:23 +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 18D94285EB for ; Mon, 8 Apr 2019 19:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726436AbfDHTlR (ORCPT ); Mon, 8 Apr 2019 15:41:17 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45950 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728667AbfDHTjq (ORCPT ); Mon, 8 Apr 2019 15:39:46 -0400 Received: by mail-pf1-f196.google.com with SMTP id e24so8192570pfi.12; Mon, 08 Apr 2019 12:39:46 -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=meLAD+DIRCeVzo4Af4ZKbYchnE6bZYikYlq7WnlFmvk=; b=gAFvQ5zr4J9jE74VwbVs3gUDQ97/w7t4usH9xYXgZ0n6MqAa5ujFsq2/J7WYCdO838 UeXcNCT8dLohEirg/pafbacDryKiAe6WfuXfuY9s6xWXrEORXeVoH4Ek8112yQwUdLbG g4L+jFYJwCb2+mvg9XKBpch/gKbQl1bxe1PUQvA9L+Bbl8v0+xxpENzdSHg9zh0iMnBh u3oxhKtT4hhUg7DzxjXmNYZ/2Qvd1gShzssF4aL1LKWLpdTSlnLfrGyjx6+7VZjkS1sY DhKHr9XMyZENfxdOWQxUsSiokCcX1vcCZfpGYisNmxY/xo+cQ2O0TVcrh+azFlcRKhbT DXZg== 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=meLAD+DIRCeVzo4Af4ZKbYchnE6bZYikYlq7WnlFmvk=; b=r20Q+3UEQQYMWOZiXvAMKLyPTl4cVFr1qOANazqOBbrYnbMO0JKIwTiB6IQxxfpoob pnxaSv7MKz9DeHCdhOkyHW83vT9bsZKgTYJbYZ37+2rwJDMYj1k1WoHrWRDhqAfurzw6 UR1dviz6Bv6T0x3fyaLtMQa2TMUugRyaPyQlfUGdjSwtZYJtwe4Amnl5j0nXY0wQQWa9 uQGF1WPm1ee9HKaPrmSB6BKGnXBr593DaR7u/+Gwh8tz0R8Iri6xbVMGtXvTWfb6SUPV Nxlhx7pvuvSFi/HRrPmn0cyO92RYnOb+vabt+IQ2ExxoLxh9ajHZaQ2dCQtKhUsQ+Hno qs7A== X-Gm-Message-State: APjAAAUi8e07gyTHH4/U/cTnchkJAdI2MyInCODoapgcrNRcC/bWX3ZK jPqpV/2NH1DENBpta12p3d2OwKxn X-Google-Smtp-Source: APXvYqxGFayllojPsdajA+bDfCNiiZHVEKIiy1BhKYJ4IPmDsY7uYcs6rtAhvoJtNwpdY5TPkPS7eA== X-Received: by 2002:a65:5106:: with SMTP id f6mr29649210pgq.253.1554752385664; Mon, 08 Apr 2019 12:39:45 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id v19sm41393928pfn.62.2019.04.08.12.39.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:45 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 06/22] watchdog: bcm7038_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:30 -0700 Message-Id: <1554752326-13319-7-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 devm_add_action_or_reset() for calls to clk_disable_unprepare - 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/bcm7038_wdt.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/drivers/watchdog/bcm7038_wdt.c b/drivers/watchdog/bcm7038_wdt.c index 71fca45eab5d..d3d88f6703d7 100644 --- a/drivers/watchdog/bcm7038_wdt.c +++ b/drivers/watchdog/bcm7038_wdt.c @@ -107,6 +107,11 @@ static const struct watchdog_ops bcm7038_wdt_ops = { .get_timeleft = bcm7038_wdt_get_timeleft, }; +static void bcm7038_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int bcm7038_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -129,6 +134,11 @@ static int bcm7038_wdt_probe(struct platform_device *pdev) err = clk_prepare_enable(wdt->clk); if (err) return err; + err = devm_add_action_or_reset(dev, + bcm7038_clk_disable_unprepare, + wdt->clk); + if (err) + return err; wdt->rate = clk_get_rate(wdt->clk); /* Prevent divide-by-zero exception */ if (!wdt->rate) @@ -146,10 +156,11 @@ static int bcm7038_wdt_probe(struct platform_device *pdev) wdt->wdd.parent = dev; watchdog_set_drvdata(&wdt->wdd, wdt); - err = watchdog_register_device(&wdt->wdd); + watchdog_stop_on_reboot(&wdt->wdd); + watchdog_stop_on_unregister(&wdt->wdd); + err = devm_watchdog_register_device(dev, &wdt->wdd); if (err) { dev_err(dev, "Failed to register watchdog device\n"); - clk_disable_unprepare(wdt->clk); return err; } @@ -158,19 +169,6 @@ static int bcm7038_wdt_probe(struct platform_device *pdev) return 0; } -static int bcm7038_wdt_remove(struct platform_device *pdev) -{ - struct bcm7038_watchdog *wdt = platform_get_drvdata(pdev); - - if (!nowayout) - bcm7038_wdt_stop(&wdt->wdd); - - watchdog_unregister_device(&wdt->wdd); - clk_disable_unprepare(wdt->clk); - - return 0; -} - #ifdef CONFIG_PM_SLEEP static int bcm7038_wdt_suspend(struct device *dev) { @@ -196,14 +194,6 @@ static int bcm7038_wdt_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(bcm7038_wdt_pm_ops, bcm7038_wdt_suspend, bcm7038_wdt_resume); -static void bcm7038_wdt_shutdown(struct platform_device *pdev) -{ - struct bcm7038_watchdog *wdt = platform_get_drvdata(pdev); - - if (watchdog_active(&wdt->wdd)) - bcm7038_wdt_stop(&wdt->wdd); -} - static const struct of_device_id bcm7038_wdt_match[] = { { .compatible = "brcm,bcm7038-wdt" }, {}, @@ -212,8 +202,6 @@ MODULE_DEVICE_TABLE(of, bcm7038_wdt_match); static struct platform_driver bcm7038_wdt_driver = { .probe = bcm7038_wdt_probe, - .remove = bcm7038_wdt_remove, - .shutdown = bcm7038_wdt_shutdown, .driver = { .name = "bcm7038-wdt", .of_match_table = bcm7038_wdt_match, From patchwork Mon Apr 8 19:38:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890031 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 B6BBC1805 for ; Mon, 8 Apr 2019 19:41:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1A20285EB for ; Mon, 8 Apr 2019 19:41:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9601928789; Mon, 8 Apr 2019 19:41:12 +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 2B292285EB for ; Mon, 8 Apr 2019 19:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728718AbfDHTjt (ORCPT ); Mon, 8 Apr 2019 15:39:49 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41295 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727878AbfDHTjr (ORCPT ); Mon, 8 Apr 2019 15:39:47 -0400 Received: by mail-pl1-f196.google.com with SMTP id d1so7913600plj.8; Mon, 08 Apr 2019 12:39:47 -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=n8M7yZS77yDr2htBbKlSnEeLAu95sbQ1FVJ5Vh9oVR4=; b=DII4ZdINVbIl4RxxRaT/0s9IA86LqanNMtYrR4S7m/0fD3U9AD353pEGYuo0NVUpJN O697luZEe1imkuofChHARthyNkS86/RV5CrKSeZxfcTrxqj6RSyJqw540ogOu63z1cmB TR91T2qywPs6WT7eewbxa0q5yLq1ZywPllo+UdHdU+a5MymjWzTDUFTySx0E9yz7fjMc 6klTQHqvYiVbMVef8NQK4lQEHH/pYK8djWNDh7qrNltODLIlOvYshl0kn34/2/irXYnG eR6Q7es4Qa0mjUVDoGWoYw+CU4UsmF8Uef6DNqIBzznanVi2jzcgFtScBs4+8l1d8PHC Gv7w== 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=n8M7yZS77yDr2htBbKlSnEeLAu95sbQ1FVJ5Vh9oVR4=; b=Qeb7w0L0n886IjtG1dV3f/CAkA3Hf554sPC+IGNZFY32cAs2bR0jPL4+JI4mRTfCEe uTthggiD2/KxWNjljjly0uLA1hc/Sdq57FwT7jXQZboe3/q44kIOLt6RLKhHMeprTpHj 5Kdth6wess7YYgNV51Wvu8+rX7JUNkAr2qesvTVdMjUYqn3/b2J9PvpA+B7JuHGnKQHw Qdx4NrdlnLTLhIb5zsHcQ3x2r0Rc/jyVcrvc25yH7DzCHrQiTKfTkoLqKODk22l52EtI KgfuQkuRqtlvOLkrLf7PHvqmSupsFLwWcgwUIjM4yREACZ4eZY2RC/0CBMWZxzPBoEYQ VMmg== X-Gm-Message-State: APjAAAVlPTg3ewsWw/tl/+1aHpIHHOww76XNjkT7HXRAgeYImxrcHHhB HWpi/iWQFkph4flGHUscLzI= X-Google-Smtp-Source: APXvYqzF1Qz+0o+N/KCYwo3uzL1Fuu8qWi75fCwj3Wadyb2+eRHk2ObZbn/0/MGICbDfwgldiolfIg== X-Received: by 2002:a17:902:5a2:: with SMTP id f31mr31037240plf.119.1554752387258; Mon, 08 Apr 2019 12:39:47 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 19sm34964251pga.88.2019.04.08.12.39.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:46 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com Subject: [PATCH 07/22] watchdog: bcm_kona_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:31 -0700 Message-Id: <1554752326-13319-8-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 - 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() Cc: Florian Fainelli Cc: Ray Jui Cc: Scott Branden Cc: bcm-kernel-feedback-list@broadcom.com Signed-off-by: Guenter Roeck Reviewed-by: Ray Jui --- drivers/watchdog/bcm_kona_wdt.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/watchdog/bcm_kona_wdt.c b/drivers/watchdog/bcm_kona_wdt.c index d52334ab0805..e2ad44816359 100644 --- a/drivers/watchdog/bcm_kona_wdt.c +++ b/drivers/watchdog/bcm_kona_wdt.c @@ -271,11 +271,6 @@ static struct watchdog_device bcm_kona_wdt_wdd = { .timeout = SECWDOG_MAX_COUNT >> SECWDOG_DEFAULT_RESOLUTION, }; -static void bcm_kona_wdt_shutdown(struct platform_device *pdev) -{ - bcm_kona_wdt_stop(&bcm_kona_wdt_wdd); -} - static int bcm_kona_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -301,7 +296,7 @@ static int bcm_kona_wdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, wdt); watchdog_set_drvdata(&bcm_kona_wdt_wdd, wdt); - bcm_kona_wdt_wdd.parent = &pdev->dev; + bcm_kona_wdt_wdd.parent = dev; ret = bcm_kona_wdt_set_timeout_reg(&bcm_kona_wdt_wdd, 0); if (ret) { @@ -309,7 +304,9 @@ static int bcm_kona_wdt_probe(struct platform_device *pdev) return ret; } - ret = watchdog_register_device(&bcm_kona_wdt_wdd); + watchdog_stop_on_reboot(&bcm_kona_wdt_wdd); + watchdog_stop_on_unregister(&bcm_kona_wdt_wdd); + ret = devm_watchdog_register_device(dev, &bcm_kona_wdt_wdd); if (ret) { dev_err(dev, "Failed to register watchdog device"); return ret; @@ -324,8 +321,6 @@ static int bcm_kona_wdt_probe(struct platform_device *pdev) static int bcm_kona_wdt_remove(struct platform_device *pdev) { bcm_kona_wdt_debug_exit(pdev); - bcm_kona_wdt_shutdown(pdev); - watchdog_unregister_device(&bcm_kona_wdt_wdd); dev_dbg(&pdev->dev, "Watchdog driver disabled"); return 0; @@ -344,7 +339,6 @@ static struct platform_driver bcm_kona_wdt_driver = { }, .probe = bcm_kona_wdt_probe, .remove = bcm_kona_wdt_remove, - .shutdown = bcm_kona_wdt_shutdown, }; module_platform_driver(bcm_kona_wdt_driver); From patchwork Mon Apr 8 19:38:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890033 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 C32321669 for ; Mon, 8 Apr 2019 19:41:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD263285A4 for ; Mon, 8 Apr 2019 19:41:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A17CF286FE; Mon, 8 Apr 2019 19:41:13 +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 00A37285A4 for ; Mon, 8 Apr 2019 19:41:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727206AbfDHTlF (ORCPT ); Mon, 8 Apr 2019 15:41:05 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:43594 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726691AbfDHTjt (ORCPT ); Mon, 8 Apr 2019 15:39:49 -0400 Received: by mail-pl1-f195.google.com with SMTP id n8so3348980plp.10; Mon, 08 Apr 2019 12:39:48 -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=tratJcb8Iua0rnSEaA89+NPVkvokWzZYSDeGf4OVw4I=; b=Zk2bovSywM3Ur+04hllbLRzaUD91Wx6PzV/4XuB9A1DxaZwJu3Zh0d7Uc+UXPVAJPB KbHOXWuXRSYDu0s/rHiQNC8HqJAWZZ4w0eyMqojEAM2CBCgjSUs9+yiDnD3h2HWNzMHV uTKMp5bSgjYXSgU6c9wjCLYjJxVazgRG1GaeQ5PvLXZZK/9wAV0XhGAXiJ6RM3pvA8vV bG22J/yP5Oyi+iZYiMT1lDTtm7s2SFC0oCL0NtpylsnqwNdXybaqBi7T8+w+vTm5a++J xdm5dp2eoFKYdfZBOcWcZtVv/wEGwCSFM2Jrq6eCp6rAomk1DqPJLzPzkyre7x2tLyoh Vhiw== 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=tratJcb8Iua0rnSEaA89+NPVkvokWzZYSDeGf4OVw4I=; b=EwkLVMaVfusCT0dhPGeYy5LuZ3v/Ti2PCVKhWa5eBrvHbPGiaQ9CBtUlNoIDn32v42 GvKGnlUfNHW+4PEV2a45GDaAWKk0q0XbfLNJUgUDUxgVybTuuyYKBMclpUDn5FOqNi7T BHxXpMjNlGax516kuyOAHUNdYSqA5thkVoQCkL2PzPXZLo8MRsDK1ADhS+pMksrTL+Q7 3nRZVi3S8N82gBauYeFZOg3utCAWriumsk1Tqk3TLZGF93dC3jrz4RM5uZiZbDxc9Jm3 FEa+sdqLQKAf7PxXPOXdl1ig0vQi+L20VvQ2TT6yV7RUxCUhb6ZjjC6ymX+GTEKGvYBr QSHg== X-Gm-Message-State: APjAAAW25AUVWNbf0rj6Dn81RAXsNbCKYtC+E8gF/wJarfrL8wBC2Dxw 6O6e4rWf5nnfjsBlJfRR3V8= X-Google-Smtp-Source: APXvYqxWj89KBIYtugNnCerajl7uEOwhQXJ0MbWG2xRvyjZjtu7xrZVFYf0xInMYKZx0s8pjf6/RgQ== X-Received: by 2002:a17:902:820c:: with SMTP id x12mr32397325pln.199.1554752388568; Mon, 08 Apr 2019 12:39:48 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id v189sm80671830pgd.77.2019.04.08.12.39.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:48 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 08/22] watchdog: cadence_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:32 -0700 Message-Id: <1554752326-13319-9-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 devm_add_action_or_reset() for calls to clk_disable_unprepare - Replace 'goto l; ... l: return e;' with 'return e;' - Replace 'val = e; return val;' with 'return e;' - 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/cadence_wdt.c | 83 ++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 56 deletions(-) diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c index 5986f18f97e2..c5051907df00 100644 --- a/drivers/watchdog/cadence_wdt.c +++ b/drivers/watchdog/cadence_wdt.c @@ -274,6 +274,11 @@ static const struct watchdog_ops cdns_wdt_ops = { .set_timeout = cdns_wdt_settimeout, }; +static void cdns_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + /************************Platform Operations*****************************/ /** * cdns_wdt_probe - Probe call for the device. @@ -285,12 +290,13 @@ static const struct watchdog_ops cdns_wdt_ops = { */ static int cdns_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret, irq; unsigned long clock_f; struct cdns_wdt *wdt; struct watchdog_device *cdns_wdt_device; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -306,13 +312,13 @@ static int cdns_wdt_probe(struct platform_device *pdev) return PTR_ERR(wdt->regs); /* Register the interrupt */ - wdt->rst = of_property_read_bool(pdev->dev.of_node, "reset-on-timeout"); + wdt->rst = of_property_read_bool(dev->of_node, "reset-on-timeout"); irq = platform_get_irq(pdev, 0); if (!wdt->rst && irq >= 0) { - ret = devm_request_irq(&pdev->dev, irq, cdns_wdt_irq_handler, 0, + ret = devm_request_irq(dev, irq, cdns_wdt_irq_handler, 0, pdev->name, pdev); if (ret) { - dev_err(&pdev->dev, + dev_err(dev, "cannot register interrupt handler err=%d\n", ret); return ret; @@ -320,11 +326,11 @@ static int cdns_wdt_probe(struct platform_device *pdev) } /* Initialize the members of cdns_wdt structure */ - cdns_wdt_device->parent = &pdev->dev; + cdns_wdt_device->parent = dev; - ret = watchdog_init_timeout(cdns_wdt_device, wdt_timeout, &pdev->dev); + ret = watchdog_init_timeout(cdns_wdt_device, wdt_timeout, dev); if (ret) { - dev_err(&pdev->dev, "unable to set timeout value\n"); + dev_err(dev, "unable to set timeout value\n"); return ret; } @@ -332,18 +338,21 @@ static int cdns_wdt_probe(struct platform_device *pdev) watchdog_stop_on_reboot(cdns_wdt_device); watchdog_set_drvdata(cdns_wdt_device, wdt); - wdt->clk = devm_clk_get(&pdev->dev, NULL); + wdt->clk = devm_clk_get(dev, NULL); if (IS_ERR(wdt->clk)) { - dev_err(&pdev->dev, "input clock not found\n"); - ret = PTR_ERR(wdt->clk); - return ret; + dev_err(dev, "input clock not found\n"); + return PTR_ERR(wdt->clk); } ret = clk_prepare_enable(wdt->clk); if (ret) { - dev_err(&pdev->dev, "unable to enable clock\n"); + dev_err(dev, "unable to enable clock\n"); return ret; } + ret = devm_add_action_or_reset(dev, cdns_clk_disable_unprepare, + wdt->clk); + if (ret) + return ret; clock_f = clk_get_rate(wdt->clk); if (clock_f <= CDNS_WDT_CLK_75MHZ) { @@ -356,56 +365,20 @@ static int cdns_wdt_probe(struct platform_device *pdev) spin_lock_init(&wdt->io_lock); - ret = watchdog_register_device(cdns_wdt_device); + watchdog_stop_on_reboot(cdns_wdt_device); + watchdog_stop_on_unregister(cdns_wdt_device); + ret = devm_watchdog_register_device(dev, cdns_wdt_device); if (ret) { - dev_err(&pdev->dev, "Failed to register wdt device\n"); - goto err_clk_disable; + dev_err(dev, "Failed to register wdt device\n"); + return ret; } platform_set_drvdata(pdev, wdt); - dev_info(&pdev->dev, "Xilinx Watchdog Timer at %p with timeout %ds%s\n", + dev_info(dev, "Xilinx Watchdog Timer at %p with timeout %ds%s\n", wdt->regs, cdns_wdt_device->timeout, nowayout ? ", nowayout" : ""); return 0; - -err_clk_disable: - clk_disable_unprepare(wdt->clk); - - return ret; -} - -/** - * cdns_wdt_remove - Probe call for the device. - * - * @pdev: handle to the platform device structure. - * Return: 0 on success, otherwise negative error. - * - * Unregister the device after releasing the resources. - */ -static int cdns_wdt_remove(struct platform_device *pdev) -{ - struct cdns_wdt *wdt = platform_get_drvdata(pdev); - - cdns_wdt_stop(&wdt->cdns_wdt_device); - watchdog_unregister_device(&wdt->cdns_wdt_device); - clk_disable_unprepare(wdt->clk); - - return 0; -} - -/** - * cdns_wdt_shutdown - Stop the device. - * - * @pdev: handle to the platform structure. - * - */ -static void cdns_wdt_shutdown(struct platform_device *pdev) -{ - struct cdns_wdt *wdt = platform_get_drvdata(pdev); - - cdns_wdt_stop(&wdt->cdns_wdt_device); - clk_disable_unprepare(wdt->clk); } /** @@ -460,8 +433,6 @@ MODULE_DEVICE_TABLE(of, cdns_wdt_of_match); /* Driver Structure */ static struct platform_driver cdns_wdt_driver = { .probe = cdns_wdt_probe, - .remove = cdns_wdt_remove, - .shutdown = cdns_wdt_shutdown, .driver = { .name = "cdns-wdt", .of_match_table = cdns_wdt_of_match, From patchwork Mon Apr 8 19:38:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890003 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 43CB11805 for ; Mon, 8 Apr 2019 19:39:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EE6928569 for ; Mon, 8 Apr 2019 19:39:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 238C5285A3; Mon, 8 Apr 2019 19:39:54 +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 B585128569 for ; Mon, 8 Apr 2019 19:39:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728772AbfDHTjx (ORCPT ); Mon, 8 Apr 2019 15:39:53 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:33611 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728731AbfDHTju (ORCPT ); Mon, 8 Apr 2019 15:39:50 -0400 Received: by mail-pg1-f196.google.com with SMTP id k19so7896408pgh.0; Mon, 08 Apr 2019 12:39:50 -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=MmPUEUcV2qWha6hVjFgTxBEPjINUfNIEc6V+OTChC98=; b=vFSCD2+WKiyO5vjfy8BRP9sBopWQONpzQhaCRjI5pj82bJ4VxHKwjdnzqiF7i+7N+b gFL7TPWx4nKhHGtLvUu7aqtxTltpM7NK1KRGWy2D2d9X+bPZeObmc0tp0/WC3ZdRsX/3 8Yvd3FJsKwuCRtDNWUzYXyfvTzIIXB6+8/ppophDUdm04BNdIJ0Fgytqz9Y7/gO2CbW4 TnOd9KzJvfZ9oY2nDdpzTsNbiSoovsCWIZcYKPNPoC23bVFSO914zogSMOLKyaBsLkzF 3+ydKfdsP9RemeLyPDIDyrL1pclU5/KylGSr6e1LtGHJXbvenK0Uh1Ac9SZcBSJODhSs 7SoQ== 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=MmPUEUcV2qWha6hVjFgTxBEPjINUfNIEc6V+OTChC98=; b=hvNUrPnhEsc0VUfdI7bVFQ3nnG/zroQEYZjmNBSXfmLq8DfnSAaZpkzDW+tq6rOFMs Ds7UjGxz6t5ZiNaQjy5vZ6RXqZcCvtAOnW7WXUazCimxkW6Ly5Vy6t/nOW3EaYYOeKDd iGSrP+r7/sT4+ZOFTL/hEVXBhy3JQ6jPaN9CHlzhHulBvY88nD2pXoRxys9PEKTivlcw pmcrvgEdctUwK+4oh67GXIlTFbQD5jda/RgIz8xAwMBXKeqCF1wmBR4HdXl1rbQKWbWn avHuNYuL/7DUHscFAAe+RGdSNkRvpiR7mXhLSVtub31CjU2e/VUPPIl5JaJQ5whTIse2 aB2Q== X-Gm-Message-State: APjAAAWXSjoCQjzhK2iWuA56zwKDsXGjPFZJYrEyVpKEO9AXZX/b34/D 1+Bv5PGfXP5vFyF7Gw/OSVs= X-Google-Smtp-Source: APXvYqxrtWwrSowQTRBbPiIgX3V5NRNYn9JOKkRoUnwTpDkuOVT+vc3rPiHPcMnrRSs9CVLX2BuAUg== X-Received: by 2002:a63:5c43:: with SMTP id n3mr28009486pgm.163.1554752389921; Mon, 08 Apr 2019 12:39:49 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b6sm37325708pgl.49.2019.04.08.12.39.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:49 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Support Opensource Subject: [PATCH 09/22] watchdog: da9052_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Mon, 8 Apr 2019 12:38:33 -0700 Message-Id: <1554752326-13319-10-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly. 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 Cc: Support Opensource Signed-off-by: Guenter Roeck Acked-by: Steve Twiss --- drivers/watchdog/da9052_wdt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/da9052_wdt.c b/drivers/watchdog/da9052_wdt.c index e263bad99574..a2feef1ff307 100644 --- a/drivers/watchdog/da9052_wdt.c +++ b/drivers/watchdog/da9052_wdt.c @@ -150,13 +150,13 @@ static const struct watchdog_ops da9052_wdt_ops = { static int da9052_wdt_probe(struct platform_device *pdev) { - struct da9052 *da9052 = dev_get_drvdata(pdev->dev.parent); + struct device *dev = &pdev->dev; + struct da9052 *da9052 = dev_get_drvdata(dev->parent); struct da9052_wdt_data *driver_data; struct watchdog_device *da9052_wdt; int ret; - driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data), - GFP_KERNEL); + driver_data = devm_kzalloc(dev, sizeof(*driver_data), GFP_KERNEL); if (!driver_data) return -ENOMEM; driver_data->da9052 = da9052; @@ -166,18 +166,17 @@ static int da9052_wdt_probe(struct platform_device *pdev) da9052_wdt->timeout = DA9052_DEF_TIMEOUT; da9052_wdt->info = &da9052_wdt_info; da9052_wdt->ops = &da9052_wdt_ops; - da9052_wdt->parent = &pdev->dev; + da9052_wdt->parent = dev; watchdog_set_drvdata(da9052_wdt, driver_data); ret = da9052_reg_update(da9052, DA9052_CONTROL_D_REG, DA9052_CONTROLD_TWDSCALE, 0); if (ret < 0) { - dev_err(&pdev->dev, "Failed to disable watchdog bits, %d\n", - ret); + dev_err(dev, "Failed to disable watchdog bits, %d\n", ret); return ret; } - ret = devm_watchdog_register_device(&pdev->dev, &driver_data->wdt); + ret = devm_watchdog_register_device(dev, &driver_data->wdt); if (ret != 0) { dev_err(da9052->dev, "watchdog_register_device() failed: %d\n", ret); From patchwork Mon Apr 8 19:38:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890001 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 34EB8922 for ; Mon, 8 Apr 2019 19:39:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ED222851A for ; Mon, 8 Apr 2019 19:39:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11FF428595; Mon, 8 Apr 2019 19:39:54 +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 94CFD2851A for ; Mon, 8 Apr 2019 19:39:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728760AbfDHTjw (ORCPT ); Mon, 8 Apr 2019 15:39:52 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36867 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727878AbfDHTjw (ORCPT ); Mon, 8 Apr 2019 15:39:52 -0400 Received: by mail-pl1-f194.google.com with SMTP id w23so7918289ply.4; Mon, 08 Apr 2019 12:39:51 -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=IAzbxkJlpTQ2aw4GmH8bUwHqrx58SWUqD0TKIw07vIM=; b=AMQO4d+l1S3uvkKrlHtSrlCMAbtDbeySQL1pX7CC5U0gWnuUDX6TQBbYVVn9I2gI82 9/+EulQerD50YUabYbmTcza7T3vebvxJly62KOBi5mP+E5CHSA/kDHZ5n8l3k5/VFEgp WhyZu5vCkNN/4BLv6mqaj1/yXcr9SHgkRunOJ/kY21u3ncbCdrzjHXIFBGKRPMGCyvJ3 aufT35+4kQppms44VGOR3St8ah5ItogttPi//4GDYfuCKw48NDEFeKwteZAsfqEV4xJF Z69Y0jYdDUtpbxo8KQCpRFt8nQzi3lxjYvvXMVF7DPc0YlSPUxJ+i+VRpLZeuuorBGS8 MTiA== 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=IAzbxkJlpTQ2aw4GmH8bUwHqrx58SWUqD0TKIw07vIM=; b=Fzgo6v4zb7SgYtWG2zkBmLu7UGUWDlYFf+u29w5g+xH7qhA08cfO2Ym8hCoRcCwJCV EW8jIDA6POLtBxJ37xA/fTWA9wf5WCaUT/1fA8348bv9ZRV1r7G4EaIaIZCTvrrJL228 FsXSR42IzpKY9eb2by+D6Omeec1xnqoC5Kmk618W4MctnnEpWG/nohBG8UzvzyfU7INP K3nmQOt4v8zWgSaM1SrUf8vidpYYVdIeoB16Y0Puk2vIxGhkNLzXeusmppqn7ioxuwTr QoWO7U4UDwAUdoT+Zxil87CISW0ecVxw5thRdOnTqXrkXh2cm01gUZLCTMTWhCBtcyD3 XeGQ== X-Gm-Message-State: APjAAAURIZihdg9E3RIFqmp/xm2338ajmYriVUZrL73soQvXIDT0Zl8i NHUPRltxWw3b28X65ESnk+g= X-Google-Smtp-Source: APXvYqy7XEMnu428nXuTVmDPQPk8Y7+bsYzitSMxqPpNU3hvN5iT+Pz+BSWTwTd/Av/Q8Wgo0e2xIQ== X-Received: by 2002:a17:902:1124:: with SMTP id d33mr7821386pla.268.1554752391318; Mon, 08 Apr 2019 12:39:51 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id z20sm42163181pgf.70.2019.04.08.12.39.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:50 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Support Opensource Subject: [PATCH 10/22] watchdog: da9055_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Mon, 8 Apr 2019 12:38:34 -0700 Message-Id: <1554752326-13319-11-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly. 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 Cc: Support Opensource Signed-off-by: Guenter Roeck Acked-by: Steve Twiss --- drivers/watchdog/da9055_wdt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/watchdog/da9055_wdt.c b/drivers/watchdog/da9055_wdt.c index 26a5b2984094..389a4bdd208c 100644 --- a/drivers/watchdog/da9055_wdt.c +++ b/drivers/watchdog/da9055_wdt.c @@ -119,13 +119,13 @@ static const struct watchdog_ops da9055_wdt_ops = { static int da9055_wdt_probe(struct platform_device *pdev) { - struct da9055 *da9055 = dev_get_drvdata(pdev->dev.parent); + struct device *dev = &pdev->dev; + struct da9055 *da9055 = dev_get_drvdata(dev->parent); struct da9055_wdt_data *driver_data; struct watchdog_device *da9055_wdt; int ret; - driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data), - GFP_KERNEL); + driver_data = devm_kzalloc(dev, sizeof(*driver_data), GFP_KERNEL); if (!driver_data) return -ENOMEM; @@ -136,17 +136,17 @@ static int da9055_wdt_probe(struct platform_device *pdev) da9055_wdt->timeout = DA9055_DEF_TIMEOUT; da9055_wdt->info = &da9055_wdt_info; da9055_wdt->ops = &da9055_wdt_ops; - da9055_wdt->parent = &pdev->dev; + da9055_wdt->parent = dev; watchdog_set_nowayout(da9055_wdt, nowayout); watchdog_set_drvdata(da9055_wdt, driver_data); ret = da9055_wdt_stop(da9055_wdt); if (ret < 0) { - dev_err(&pdev->dev, "Failed to stop watchdog, %d\n", ret); + dev_err(dev, "Failed to stop watchdog, %d\n", ret); return ret; } - ret = devm_watchdog_register_device(&pdev->dev, &driver_data->wdt); + ret = devm_watchdog_register_device(dev, &driver_data->wdt); if (ret != 0) dev_err(da9055->dev, "watchdog_register_device() failed: %d\n", ret); From patchwork Mon Apr 8 19:38:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890029 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 E7CC7922 for ; Mon, 8 Apr 2019 19:41:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2375285A4 for ; Mon, 8 Apr 2019 19:41:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C65CB285EB; Mon, 8 Apr 2019 19:41:03 +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 A2B9D286FE for ; Mon, 8 Apr 2019 19:41:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728793AbfDHTjx (ORCPT ); Mon, 8 Apr 2019 15:39:53 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40207 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728765AbfDHTjx (ORCPT ); Mon, 8 Apr 2019 15:39:53 -0400 Received: by mail-pf1-f196.google.com with SMTP id c207so8211198pfc.7; Mon, 08 Apr 2019 12:39:53 -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=g0Y1r2JeuOsU6r31ExCrDv6Aq8kzHhgXdZSTmOFnQ84=; b=M6UfDSdvglgCaK4OunQJQpk46h7E+emNHYfsuHwdsQxt/7ksNnlUQyk5cASVinqbv5 UBMq/iBV80Qg4fmJT0h6619xEHrm+nGR7Gze6rygq+S2tuAPYWOrJ/ShfeEg3TONSaA7 fwCI245o+digv0vcx1g+/R+skwgqxASO/dfzGd3uSXDwI4ZBrzsYMydEgRxCGLAn2Onu DYb4+S/DSXDbKRECKguMFboFaKjWCKZgLHIed1Q+m0vyIqBuBx8O0UQD6OARWky6oNy3 LhlYw7pPRrEb4xoF+t2wfYt5OBDd/SDizOhREux1FlYF6Sra1fB0QJ0uIjyTDJnhMjkO iXwg== 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=g0Y1r2JeuOsU6r31ExCrDv6Aq8kzHhgXdZSTmOFnQ84=; b=WRQd1b1HILcJqh1K7f3dfeG7QFcf/ARrQfGwKzxPGcv/NFrSDgG9oX6hYhEH+ZmGpl xgmPLU9zJVmAEYZL/RONIXhpwdbf4zP/WmND+itDhjUnQ57gAhJH++dvC6KhJWexu+zj dtIXxS2U67vbywut3Fpp01kAUtE357UPcA5XvqGXGWxYfkQJEY6WespYWSTLCDk8cqkY Ke8k3/j5NZzAMgQ8DHYaQGy3FyzMswF3p1On+n2H3qM8Xa22JnyURAavwhA4laZGg5rl sfyV2DX1dC3gfY+MTr8CQcj2QxAVf1CHPBHfpsiqkxIDgAWVYa01GKCFy5/VmdpStvoG pOEA== X-Gm-Message-State: APjAAAVWh69cgr8Ls+AdS2gb3wBMrKL6asxuTIZq9XiTeu5S0P42N/rd VV1rgQbDpHnsQSMia6yeqZ4= X-Google-Smtp-Source: APXvYqxPvtlNeqzBrg/utQKwhLP5o97jkqiobxvQkDxQwaLRLfV8eFMCoQsbGJXtri6wlzKjvMyWiw== X-Received: by 2002:a63:6786:: with SMTP id b128mr30464093pgc.318.1554752392767; Mon, 08 Apr 2019 12:39:52 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id c25sm44259208pfo.69.2019.04.08.12.39.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:52 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Support Opensource Subject: [PATCH 11/22] watchdog: da9062_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Mon, 8 Apr 2019 12:38:35 -0700 Message-Id: <1554752326-13319-12-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly. Also replace 'ret = func(); return ret;' with 'return func();'. 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 Cc: Support Opensource Signed-off-by: Guenter Roeck Acked-by: Steve Twiss --- drivers/watchdog/da9062_wdt.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c index fe169d8e1fb2..aac749cfaccb 100644 --- a/drivers/watchdog/da9062_wdt.c +++ b/drivers/watchdog/da9062_wdt.c @@ -46,14 +46,9 @@ static unsigned int da9062_wdt_timeout_to_sel(unsigned int secs) static int da9062_reset_watchdog_timer(struct da9062_watchdog *wdt) { - int ret; - - ret = regmap_update_bits(wdt->hw->regmap, - DA9062AA_CONTROL_F, - DA9062AA_WATCHDOG_MASK, - DA9062AA_WATCHDOG_MASK); - - return ret; + return regmap_update_bits(wdt->hw->regmap, DA9062AA_CONTROL_F, + DA9062AA_WATCHDOG_MASK, + DA9062AA_WATCHDOG_MASK); } static int da9062_wdt_update_timeout_register(struct da9062_watchdog *wdt, @@ -190,15 +185,16 @@ MODULE_DEVICE_TABLE(of, da9062_compatible_id_table); static int da9062_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; struct da9062 *chip; struct da9062_watchdog *wdt; - chip = dev_get_drvdata(pdev->dev.parent); + chip = dev_get_drvdata(dev->parent); if (!chip) return -EINVAL; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -211,13 +207,13 @@ static int da9062_wdt_probe(struct platform_device *pdev) wdt->wdtdev.min_hw_heartbeat_ms = DA9062_RESET_PROTECTION_MS; wdt->wdtdev.timeout = DA9062_WDG_DEFAULT_TIMEOUT; wdt->wdtdev.status = WATCHDOG_NOWAYOUT_INIT_STATUS; - wdt->wdtdev.parent = &pdev->dev; + wdt->wdtdev.parent = dev; watchdog_set_restart_priority(&wdt->wdtdev, 128); watchdog_set_drvdata(&wdt->wdtdev, wdt); - ret = devm_watchdog_register_device(&pdev->dev, &wdt->wdtdev); + ret = devm_watchdog_register_device(dev, &wdt->wdtdev); if (ret < 0) { dev_err(wdt->hw->dev, "watchdog registration failed (%d)\n", ret); From patchwork Mon Apr 8 19:38:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890027 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 D3C48922 for ; Mon, 8 Apr 2019 19:41:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEA3E285A4 for ; Mon, 8 Apr 2019 19:41:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B317D28746; Mon, 8 Apr 2019 19:41:02 +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 D119B285A4 for ; Mon, 8 Apr 2019 19:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbfDHTkz (ORCPT ); Mon, 8 Apr 2019 15:40:55 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35543 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728820AbfDHTjz (ORCPT ); Mon, 8 Apr 2019 15:39:55 -0400 Received: by mail-pg1-f193.google.com with SMTP id g8so7886505pgf.2; Mon, 08 Apr 2019 12:39:54 -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=Q4IVqeF4eZZXzwVrhyw6JtwBOUJ05UVuGHVxZTEZZdU=; b=N3tNEhM4n5CfkxYTcyWJbYPcwVQRRdZLr2UhTXffPar0h9nfX6CfIxON0DdhDJVU52 aFKqgKzMN21GkK+pYfVMGlNVkIT3By/9vKd9XtvDu8+wrNazmhcOBQ6rvvzxOJ7ODnvw W4qczJuODQwMRZme95bXyat9m+WnkhQ+2JetESXGSELDlpO1BsryR4tatwbSaiHos0g/ LfpexKN9R4iU2ifWpf8IlmwpszQvWN+sXjpD69+pqGOSUQ8mX/KE0PpYBwZ/TPPIpz+3 GdnyzDxZv55laIigHrUGrVkI0Vs+BnMsF6xPr5tBO2XtNTVEC6gX3/epECu7SXgpAEzS Vm7w== 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=Q4IVqeF4eZZXzwVrhyw6JtwBOUJ05UVuGHVxZTEZZdU=; b=OF996+BJfKNfWF9VPXkKoh+12gV4vXPgrajF4zf18EnG/DmpejRG7soe158+4R6/Xq IYOGfPFn0yn8cBcVsLWvIuU/W22lxaq8GVZlaHbaEG+W8k0pNJDmO2XeYm4vzqt2ipP6 cu2B+7DlwT+dN6QlwyFerReKNHqiXH3ESJrTytYDcDbZB98prsJy30RaPn/F7tIu6/nc Km7sevo99hS+Yx1g30c2uowuflCwCQ3Vz5Ggfc0GYJP6woMggOgLfxkm3sfwcvEY/Soa DC0C3Tm7IInOxhjjEVTCg+V0KHXDpQx8VIWkVgv6cNQ1yUrQ+a4hNgIn++pm2rd/5Wol RD1Q== X-Gm-Message-State: APjAAAVxX2NgTiL7RKM9RACm9wiO7XC5su6GM9hjKC/MfQNHwHTqhy52 jBlabIMtA4j2QTWmsQx814vRAAxC X-Google-Smtp-Source: APXvYqwkn4qLegFXQdKoqO/f/kRIxwjxg2aiOghzxxTAxLFve2jRnPPAed5TyPnVcHpjf7fzBmY7vA== X-Received: by 2002:a63:e004:: with SMTP id e4mr30532805pgh.344.1554752394183; Mon, 08 Apr 2019 12:39:54 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 20sm40639951pfn.131.2019.04.08.12.39.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:53 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Support Opensource Subject: [PATCH 12/22] watchdog: da9063_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Mon, 8 Apr 2019 12:38:36 -0700 Message-Id: <1554752326-13319-13-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly. 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 Cc: Support Opensource Signed-off-by: Guenter Roeck Acked-by: Steve Twiss --- drivers/watchdog/da9063_wdt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c index 384dca16af8b..06eb9070203c 100644 --- a/drivers/watchdog/da9063_wdt.c +++ b/drivers/watchdog/da9063_wdt.c @@ -188,17 +188,18 @@ static const struct watchdog_ops da9063_watchdog_ops = { static int da9063_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct da9063 *da9063; struct watchdog_device *wdd; - if (!pdev->dev.parent) + if (!dev->parent) return -EINVAL; - da9063 = dev_get_drvdata(pdev->dev.parent); + da9063 = dev_get_drvdata(dev->parent); if (!da9063) return -EINVAL; - wdd = devm_kzalloc(&pdev->dev, sizeof(*wdd), GFP_KERNEL); + wdd = devm_kzalloc(dev, sizeof(*wdd), GFP_KERNEL); if (!wdd) return -ENOMEM; @@ -208,7 +209,7 @@ static int da9063_wdt_probe(struct platform_device *pdev) wdd->max_timeout = DA9063_WDT_MAX_TIMEOUT; wdd->min_hw_heartbeat_ms = DA9063_RESET_PROTECTION_MS; wdd->timeout = DA9063_WDG_TIMEOUT; - wdd->parent = &pdev->dev; + wdd->parent = dev; wdd->status = WATCHDOG_NOWAYOUT_INIT_STATUS; @@ -222,7 +223,7 @@ static int da9063_wdt_probe(struct platform_device *pdev) set_bit(WDOG_HW_RUNNING, &wdd->status); } - return devm_watchdog_register_device(&pdev->dev, wdd); + return devm_watchdog_register_device(dev, wdd); } static struct platform_driver da9063_wdt_driver = { From patchwork Mon Apr 8 19:38:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890005 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 24DEC1669 for ; Mon, 8 Apr 2019 19:39:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CC152851A for ; Mon, 8 Apr 2019 19:39:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00C502858E; Mon, 8 Apr 2019 19:39:58 +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 7A9992851A for ; Mon, 8 Apr 2019 19:39:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728894AbfDHTj5 (ORCPT ); Mon, 8 Apr 2019 15:39:57 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35064 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728810AbfDHTj4 (ORCPT ); Mon, 8 Apr 2019 15:39:56 -0400 Received: by mail-pf1-f195.google.com with SMTP id t21so5899982pfh.2; Mon, 08 Apr 2019 12:39:55 -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=pw3HtNip1IHtP8y+sCxbjAno2YKsFoKwmHCwnLCGi7I=; b=C+F8vW7sqTWrE02DXh+S4hq4pT+Ec/222R8DUTuIyEO31DZgRWsAZqRldj9e1OfK0K Vmwan4KIvDy0tRGLW0L0mk17nv0VoF5v+x/k2Q89fP7YnpFiv8nH+qsqGhJn85hnWkSr 32QXR/xXfiZHtgcgOsoYHJchiazQfQ0JIl4hazWWkKFuYCyHxvMhSbVJD/bT2M710bBs q83kiy3P0tf3LsCx84IqC5374Z/HiGBljpFGiSJ82hUwsgbL+k7H0pZ6GYhKYIKUryaY CrozDomweZYBhdMd5i9z84OCvtOLnBG5NgwvZCEyeiuxvJ+m94XBenOWpYvegNqsckTG dO1w== 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=pw3HtNip1IHtP8y+sCxbjAno2YKsFoKwmHCwnLCGi7I=; b=PeP2kAiHrJJ4JIejnDFy1xXXukK9lmN3BtkYfy9pnHP/fwUQBBzQWdyMuYaq8cIAD2 ybx5qZH9YOXejAhfa9r4/80fzVllNIu/Lv3RKLh3x5kz4tIKvuoRtjq4ygT6aPYHmX7c LPg5zMv+8wLURGMSthZcFjk2quVcZ4J/RX4NH53vOzQhR+dCsmshp/C20UlJVRxeEJxA VgrI5Gj6g2M57UxbuDs+tmBasfq5M3xGQZtJxkwOnqITIlZb2jnQqYiIxBXloOuo2rsX QXJ4dtXGbna75oDZ3Ncwul81rFUdeDAIlmEtG91qeB838iviE8MxGJ3A6kmDUe4J17gP FUXg== X-Gm-Message-State: APjAAAUGzVfEa58bWAH8dM9xnLPleNQZEGG5AH+CQ6voHTOE0xS3vopV cxB9ETQMLrRw1hn2vRMhJys= X-Google-Smtp-Source: APXvYqxjtF8jnrnSnuBJi/TnsZseD4NxSwoPwmGlQKxBuhtw5SPJJBOnqJDwSYwYZzvSTLQdGBfiAQ== X-Received: by 2002:aa7:90ca:: with SMTP id k10mr31884363pfk.144.1554752395493; Mon, 08 Apr 2019 12:39:55 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id j9sm25315182pfc.43.2019.04.08.12.39.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:55 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 13/22] watchdog: davinci_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:37 -0700 Message-Id: <1554752326-13319-14-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 unnecessary braces around conditional return statements - Drop empty remove function - Use devm_add_action_or_reset() for calls to clk_disable_unprepare - Use local variable 'struct device *dev' consistently - Use devm_watchdog_register_driver() to register watchdog device Signed-off-by: Guenter Roeck --- drivers/watchdog/davinci_wdt.c | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c index 7daa15df74a5..7b2ee35b5ffd 100644 --- a/drivers/watchdog/davinci_wdt.c +++ b/drivers/watchdog/davinci_wdt.c @@ -191,6 +191,11 @@ static const struct watchdog_ops davinci_wdt_ops = { .restart = davinci_wdt_restart, }; +static void davinci_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int davinci_wdt_probe(struct platform_device *pdev) { int ret = 0; @@ -206,15 +211,19 @@ static int davinci_wdt_probe(struct platform_device *pdev) if (IS_ERR(davinci_wdt->clk)) { if (PTR_ERR(davinci_wdt->clk) != -EPROBE_DEFER) - dev_err(&pdev->dev, "failed to get clock node\n"); + dev_err(dev, "failed to get clock node\n"); return PTR_ERR(davinci_wdt->clk); } ret = clk_prepare_enable(davinci_wdt->clk); if (ret) { - dev_err(&pdev->dev, "failed to prepare clock\n"); + dev_err(dev, "failed to prepare clock\n"); return ret; } + ret = devm_add_action_or_reset(dev, davinci_clk_disable_unprepare, + davinci_wdt->clk); + if (ret) + return ret; platform_set_drvdata(pdev, davinci_wdt); @@ -224,7 +233,7 @@ static int davinci_wdt_probe(struct platform_device *pdev) wdd->min_timeout = 1; wdd->max_timeout = MAX_HEARTBEAT; wdd->timeout = DEFAULT_HEARTBEAT; - wdd->parent = &pdev->dev; + wdd->parent = dev; watchdog_init_timeout(wdd, heartbeat, dev); @@ -235,33 +244,16 @@ static int davinci_wdt_probe(struct platform_device *pdev) watchdog_set_restart_priority(wdd, 128); davinci_wdt->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(davinci_wdt->base)) { - ret = PTR_ERR(davinci_wdt->base); - goto err_clk_disable; - } + if (IS_ERR(davinci_wdt->base)) + return PTR_ERR(davinci_wdt->base); - ret = watchdog_register_device(wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) { dev_err(dev, "cannot register watchdog device\n"); - goto err_clk_disable; + return ret; } return 0; - -err_clk_disable: - clk_disable_unprepare(davinci_wdt->clk); - - return ret; -} - -static int davinci_wdt_remove(struct platform_device *pdev) -{ - struct davinci_wdt_device *davinci_wdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(&davinci_wdt->wdd); - clk_disable_unprepare(davinci_wdt->clk); - - return 0; } static const struct of_device_id davinci_wdt_of_match[] = { @@ -276,7 +268,6 @@ static struct platform_driver platform_wdt_driver = { .of_match_table = davinci_wdt_of_match, }, .probe = davinci_wdt_probe, - .remove = davinci_wdt_remove, }; module_platform_driver(platform_wdt_driver); From patchwork Mon Apr 8 19:38:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890007 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 DA0DD1669 for ; Mon, 8 Apr 2019 19:39:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C41032851A for ; Mon, 8 Apr 2019 19:39:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B82F728573; Mon, 8 Apr 2019 19:39:59 +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 A9E5A28569 for ; Mon, 8 Apr 2019 19:39:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728909AbfDHTj6 (ORCPT ); Mon, 8 Apr 2019 15:39:58 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34245 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728901AbfDHTj5 (ORCPT ); Mon, 8 Apr 2019 15:39:57 -0400 Received: by mail-pf1-f193.google.com with SMTP id b3so8222534pfd.1; Mon, 08 Apr 2019 12:39:57 -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=ERMFdfRvh7kZl1Kk7yPs6AsCvVFzP42gT21bBI7whoA=; b=jAZ4BRql/9NJk8pWEtGVC+l+pevg+dMYpP8pJXmw5XFiP8esW55M0gyNVUKwMQjqah Y1O8xxX+igDrNNGbnuhcNO1l/rGLna9OuL4mt4tY70C96y9oTIkNVYVMyn2+zieeY1JB bF1Pb2DzFNHk7JONU1+TrfkODiF2QyCkgiRTiJzMPgXvLtp7aFMlCkMZfX5k/WrsTlSe FRKPqtnlZJUab4WPIhetBTEVDopuATW3zmV5ErdmRUPZTpRzloNR8aGmpko9J7NBnG1Z ff5jVHPrFtK05qF7XCjkhYHXpfpay3u7khatGUoUkIBBsGLuQnc7EkCekQYUeL3h9klS bsdA== 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=ERMFdfRvh7kZl1Kk7yPs6AsCvVFzP42gT21bBI7whoA=; b=r5URLiWFHW6EAW8qY4egf3XTnPhlTG0ZBLcGLlDa1aqLDMt5altIOd2heql4JEAwD7 irSTmx6hjFC24ZDhDn5eZ6QVDf5BavkFppRl3ByhsKZMpJCVbvTpIK92fUmnUFi5oWxP u5Y7EIlkkEa10fTTBF47VVwOzNeI1Io1V0wwOpPQDPfBZ1qjm6NirqxgHqCQu8wFDVzU B+dwb1tmTcTEHs7Xw2FArXJQRUTVnRp05mbTyeWsEr79cacMMYdOnhlZhljW7BCai0pT j2oTUn7hk2achaq2uXq99jaERF0XyKukxogrhQd6M1kMo6xWpUjzfT0aBm3Cg9SBvfHB voZA== X-Gm-Message-State: APjAAAWrSipOlpVS4IH5SmX19n5tt/l7AQ6CEl+x4EIra6etyA+Itih4 Lnyt+WSDNtElPlzdh81qkfY= X-Google-Smtp-Source: APXvYqyH7xbTPuNXARFRppdpZyz/ZsYmLQNKBPqKADeU0rCIwWWo8wLpgHJN1Kp11E+jcUJNU4LCpg== X-Received: by 2002:a63:185a:: with SMTP id 26mr3809215pgy.337.1554752396788; Mon, 08 Apr 2019 12:39:56 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id v12sm40836857pfe.148.2019.04.08.12.39.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:56 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 14/22] watchdog: ep93xx_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Mon, 8 Apr 2019 12:38:38 -0700 Message-Id: <1554752326-13319-15-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly. 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 Signed-off-by: Guenter Roeck --- drivers/watchdog/ep93xx_wdt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/watchdog/ep93xx_wdt.c b/drivers/watchdog/ep93xx_wdt.c index 1e721c2f9eac..38e26f160b9a 100644 --- a/drivers/watchdog/ep93xx_wdt.c +++ b/drivers/watchdog/ep93xx_wdt.c @@ -89,12 +89,13 @@ static const struct watchdog_ops ep93xx_wdt_ops = { static int ep93xx_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct ep93xx_wdt_priv *priv; struct watchdog_device *wdd; unsigned long val; int ret; - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -110,21 +111,21 @@ static int ep93xx_wdt_probe(struct platform_device *pdev) wdd->ops = &ep93xx_wdt_ops; wdd->min_timeout = 1; wdd->max_hw_heartbeat_ms = 200; - wdd->parent = &pdev->dev; + wdd->parent = dev; watchdog_set_nowayout(wdd, nowayout); wdd->timeout = WDT_TIMEOUT; - watchdog_init_timeout(wdd, timeout, &pdev->dev); + watchdog_init_timeout(wdd, timeout, dev); watchdog_set_drvdata(wdd, priv); - ret = devm_watchdog_register_device(&pdev->dev, wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) return ret; - dev_info(&pdev->dev, "EP93XX watchdog driver %s\n", - (val & 0x08) ? " (nCS1 disable detected)" : ""); + dev_info(dev, "EP93XX watchdog driver %s\n", + (val & 0x08) ? " (nCS1 disable detected)" : ""); return 0; } From patchwork Mon Apr 8 19:38:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890025 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 A2CD21669 for ; Mon, 8 Apr 2019 19:40:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D245285A4 for ; Mon, 8 Apr 2019 19:40:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8172E286FE; Mon, 8 Apr 2019 19:40:53 +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 23BB1285A4 for ; Mon, 8 Apr 2019 19:40:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729278AbfDHTks (ORCPT ); Mon, 8 Apr 2019 15:40:48 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:40820 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728917AbfDHTj6 (ORCPT ); Mon, 8 Apr 2019 15:39:58 -0400 Received: by mail-pl1-f196.google.com with SMTP id b3so7903573plr.7; Mon, 08 Apr 2019 12:39:58 -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=jqPXp0iBEFCnb3no5w/iR1we3MDq7vr6GEB66fBaE5Y=; b=j3/RF5WAM1wCQ0DLzUpWd/5ixzId/0mDWrKgTn/EjvS874ELVqpE0LGrEL4bCWk7Xb KJlLhbEOflBQdtrCSXuqMtnXl5XIJIgIy+b5YQIi1vNiLXxWOBBFEqUqMLqnT1Y5fZl2 PIZw7HaJuz/x8OKUN4wmTZDg/UMmmYWIeQ1bDxgeg3kzWOLM3rVzQ/oXetjJNmEGl9GY VZ4OJOekSxhnxeAmIrvbhOOXZlGUQPGT5wTPT4s2EsVR9dmAi5biOwwysbSc1uzpjFvu wwIXYj+FA9ciDDKUC9w4KwA8hOIhcc1Qk+rXFTd2DGdYnbkppuFW26Ra650kRO1jDqCO ZwIw== 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=jqPXp0iBEFCnb3no5w/iR1we3MDq7vr6GEB66fBaE5Y=; b=mzLFNR9JK2VF7eUOAPlhb19aRMyNSoM8E3YfqLdBfC4Tq0QTA/sCm3eXmzB8S7K+rA cd+cBIcMUkUPAjxHd4QcpRmFqaJ/XD59f+HV9TOFithZgYX9EjUDxtB3Oc5usiLQ2HFj U+5zgHL2tdBiXJz0YOVk7Kx4y/NF2YvzwkSrll/Kyd06iewncEhO2oIXSU3ACEUnvaN7 A8OwNvXAigUra8ZUZzBRZm/kHnb7WTOWfCy3fglekuBz4oRo8ZrL5+Gw1dWEpIc39Rk9 t6VA86VfR9h0vASU4No6IWCLrm8oq5f6B9eaGN9oOQd1Bqu20+7M/kwBVBNchBnztY8k V72w== X-Gm-Message-State: APjAAAUFVdWuNL0C2L9qZSRLurnxnypbKY9023dzJot+16m9rSxUD0rN pQ20MWsJGaRbavmpfAty07k= X-Google-Smtp-Source: APXvYqzKa1gehAiNWUuVbLk4x+Pb7P6Aka9tjtI+Th71oA4N8J0ud0EW9kZuY8Hc91ZvWgnWb4Bf+w== X-Received: by 2002:a17:902:110c:: with SMTP id d12mr6041054pla.47.1554752398258; Mon, 08 Apr 2019 12:39:58 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id f65sm49173051pff.21.2019.04.08.12.39.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:57 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 15/22] watchdog: ftwdt010_wdt: Use 'dev' consistently Date: Mon, 8 Apr 2019 12:38:39 -0700 Message-Id: <1554752326-13319-16-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 local variable 'dev' consistently. 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 Signed-off-by: Guenter Roeck --- drivers/watchdog/ftwdt010_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/ftwdt010_wdt.c b/drivers/watchdog/ftwdt010_wdt.c index ecb32c42e839..9ea0e56fa7ee 100644 --- a/drivers/watchdog/ftwdt010_wdt.c +++ b/drivers/watchdog/ftwdt010_wdt.c @@ -169,7 +169,7 @@ static int ftwdt010_wdt_probe(struct platform_device *pdev) ret = devm_watchdog_register_device(dev, &gwdt->wdd); if (ret) { - dev_err(&pdev->dev, "failed to register watchdog\n"); + dev_err(dev, "failed to register watchdog\n"); return ret; } From patchwork Mon Apr 8 19:38:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890023 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 D16FB1669 for ; Mon, 8 Apr 2019 19:40:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9593285A4 for ; Mon, 8 Apr 2019 19:40:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA95F286FE; Mon, 8 Apr 2019 19:40:45 +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 4F734285A4 for ; Mon, 8 Apr 2019 19:40:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727324AbfDHTkk (ORCPT ); Mon, 8 Apr 2019 15:40:40 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40215 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728931AbfDHTkA (ORCPT ); Mon, 8 Apr 2019 15:40:00 -0400 Received: by mail-pf1-f195.google.com with SMTP id c207so8211360pfc.7; Mon, 08 Apr 2019 12:40:00 -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=PykYAkk8RSwT35YgeR0OtSm82fJq863ebQpRt9L2OPc=; b=n106AwkDvNxW8yoOchoLeo48fc0TaSXdlP1V07nTdWAEizcO6I+dDUb+0eJ4x8CsTz kTczAc9EKZYKa9SVEVHvBmIYdDec2oQVvIkJoKZryfDzAJX8poMk1Wk6u0zNsVvvgKpq 3bhGgCnxoefXCwEh//W0V36IyYQkPqg2YvZKBZrCiIkHoogS87/wFnbyXc71CL3MqELW OLR1g0+aIzJjRkEhadvS2HiBAuaQJwDeaXzulxOAGwx/qNP5zeCMwyRfkP6fiq8LBmIF y/HEHjsh7RNypskEtMVqSunJipnezXTjQTcDShRNyN3f1+VZO0AKWySZzIvSAIg21VrQ 9KVA== 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=PykYAkk8RSwT35YgeR0OtSm82fJq863ebQpRt9L2OPc=; b=IVSC5+Q0TqKjaCGwd2miFUZRtf6f2upYSq013K/PC+waM2w3CU8uQZzVkETepvqn3K M3SAYf5WgOgCrdEEEo63woIjQIou1fapnWyJo3Ye49GBYwME7QGSZQLNtfloiHhfgupL 2YFR3H+uyNNdK0ddeQm9X8Reb1WQaGCxwLNw5nZDT2eyXt8BSSrLLGAPaN06jlMNKCnr pOSKDJxUkvHllzTYjAVGeZs/JOA9f+gI5R7W1RF8bOXaASYxqgDGzJVWTW8LgRJHurFx 8AeJx1ltPulG2i/zvRyJm+MnMh+TpO52k6Y2L65h2zL0YEZxplwnbLXD1ZN6vjWSsTwS IO/A== X-Gm-Message-State: APjAAAW70CPGi90kzqWB4iRinCt1xHZZ7AWYthY0sOB+y4GQEksDp7wG O/ICgHBiZneEWRgeN4sIw8Y= X-Google-Smtp-Source: APXvYqxc5S02+2sTiKk7in55riXMLX69eadiRzm0UY2KTNfJbGuE22cgcpt3/o+YDnBMNR6CQrfgig== X-Received: by 2002:a63:5a1d:: with SMTP id o29mr29985996pgb.320.1554752399673; Mon, 08 Apr 2019 12:39:59 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id x66sm18406342pfb.78.2019.04.08.12.39.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:39:59 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 16/22] watchdog: gpio_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:40 -0700 Message-Id: <1554752326-13319-17-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 Signed-off-by: Guenter Roeck --- drivers/watchdog/gpio_wdt.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c index ea77cae03c9d..bc24674b4d9e 100644 --- a/drivers/watchdog/gpio_wdt.c +++ b/drivers/watchdog/gpio_wdt.c @@ -154,25 +154,14 @@ static int gpio_wdt_probe(struct platform_device *pdev) priv->wdd.parent = dev; priv->wdd.timeout = SOFT_TIMEOUT_DEF; - watchdog_init_timeout(&priv->wdd, 0, &pdev->dev); + watchdog_init_timeout(&priv->wdd, 0, dev); watchdog_stop_on_reboot(&priv->wdd); if (priv->always_running) gpio_wdt_start(&priv->wdd); - ret = watchdog_register_device(&priv->wdd); - - return ret; -} - -static int gpio_wdt_remove(struct platform_device *pdev) -{ - struct gpio_wdt_priv *priv = platform_get_drvdata(pdev); - - watchdog_unregister_device(&priv->wdd); - - return 0; + return devm_watchdog_register_device(dev, &priv->wdd); } static const struct of_device_id gpio_wdt_dt_ids[] = { @@ -187,7 +176,6 @@ static struct platform_driver gpio_wdt_driver = { .of_match_table = gpio_wdt_dt_ids, }, .probe = gpio_wdt_probe, - .remove = gpio_wdt_remove, }; #ifdef CONFIG_GPIO_WATCHDOG_ARCH_INITCALL From patchwork Mon Apr 8 19:38:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890019 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 6D216922 for ; Mon, 8 Apr 2019 19:40:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5674C285A4 for ; Mon, 8 Apr 2019 19:40:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4ADEF286FE; Mon, 8 Apr 2019 19:40:34 +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 E7E0A285A4 for ; Mon, 8 Apr 2019 19:40:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728908AbfDHTkc (ORCPT ); Mon, 8 Apr 2019 15:40:32 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33620 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728973AbfDHTkB (ORCPT ); Mon, 8 Apr 2019 15:40:01 -0400 Received: by mail-pg1-f193.google.com with SMTP id k19so7896648pgh.0; Mon, 08 Apr 2019 12:40:01 -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=IPmXWb96ab6qvHWkVTNbeUB9IFTYvMvkFCL+VTS1Hvg=; b=U45ifiFbSifUd79X6Op6LKecZqFgNu18jChNk76xxt+LqYys3OkwUtdwWQiIckcA8b QPy3+67aqM5Mza3iPFXHqRgPxEnowWPmyK2CBKGBvNYZQWMl8343J1x701h/tTf32Ptx x1NgLbWyIjExOzENHyYk0YINIuk2i2uh65aktXPXBWSgFE0CRqRxGkbq7RaOth0hXh3b qMZQFDDBEv3a0pNsmIeHmN704/OEtcd28wc/ag1errGOuc1Hj1nIe0grU4mFkjCmkANo kRPbbAm96x93hLTzoNhY4c5iACRxLYN4Pmmx5ul3Th9v+kKzv6HN2iY7/r/PMnUoL9Tg WR0w== 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=IPmXWb96ab6qvHWkVTNbeUB9IFTYvMvkFCL+VTS1Hvg=; b=aWa4k08AK2X8RDgEA+ke8EwIKL/BWMjop7UNoKAc2sjUi+avzmZwFCmkhf4cvMoS5T hm40JUJe1JMmMzjk2cw5yQxSU1n1oChOV0XmU+GHdl70EhvwWSCEomyzi5yzcm8QZtZF gGZO6uNkDX579DpweQ0ioNFlCPCY9EWebv/M+aSCF7KOymoyxEX51OnGfBCS0BIJmnCR QJaWHzZr71oUgYIdHzw9PTIbGEL4on9D+oIjpjMhhXUy8Z9v+NcZqvwaRcn1wh0CC3Ii qn12gg6xWpM8l8PkX0kH81mh5u5jBckYpPIFnAezcPgia9ClgIx4pl2pYfKZ+2hK84Yu HpmQ== X-Gm-Message-State: APjAAAVmLqwP5W8Y03fcZSe2cctqSdGGwtTpAz2F4T7Y7LlSAMidZGP1 GClYobEWzshlif/wM7664f4= X-Google-Smtp-Source: APXvYqyPBQI+qf55rCe5VGj8miavjJ6JUhNGY1HJlsVe5sZ4K7+UcwtckLX8oEtZKdxZ/NWwnYse5g== X-Received: by 2002:aa7:9095:: with SMTP id i21mr31640467pfa.134.1554752401061; Mon, 08 Apr 2019 12:40:01 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id g64sm70975351pfg.13.2019.04.08.12.40.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:40:00 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 17/22] watchdog: iTCO_wdt: Various improvements Date: Mon, 8 Apr 2019 12:38:41 -0700 Message-Id: <1554752326-13319-18-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 Various coccinelle driven transformations as detailed 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 - Use watchdog_stop_on_unregister to stop the watchdog on remove - Drop assignments to otherwise unused variables - Drop empty remove function Signed-off-by: Guenter Roeck --- drivers/watchdog/iTCO_wdt.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c index 0a5318b7865e..89cea6ce9a08 100644 --- a/drivers/watchdog/iTCO_wdt.c +++ b/drivers/watchdog/iTCO_wdt.c @@ -545,6 +545,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev) } watchdog_stop_on_reboot(&p->wddev); + watchdog_stop_on_unregister(&p->wddev); ret = devm_watchdog_register_device(dev, &p->wddev); if (ret != 0) { pr_err("cannot register watchdog device (err=%d)\n", ret); @@ -557,17 +558,6 @@ static int iTCO_wdt_probe(struct platform_device *pdev) return 0; } -static int iTCO_wdt_remove(struct platform_device *pdev) -{ - struct iTCO_wdt_private *p = platform_get_drvdata(pdev); - - /* Stop the timer before we leave */ - if (!nowayout) - iTCO_wdt_stop(&p->wddev); - - return 0; -} - #ifdef CONFIG_PM_SLEEP /* * Suspend-to-idle requires this, because it stops the ticks and timekeeping, so @@ -620,7 +610,6 @@ static const struct dev_pm_ops iTCO_wdt_pm = { static struct platform_driver iTCO_wdt_driver = { .probe = iTCO_wdt_probe, - .remove = iTCO_wdt_remove, .driver = { .name = DRV_NAME, .pm = ITCO_WDT_PM_OPS, From patchwork Mon Apr 8 19:38:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890017 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 353F41805 for ; Mon, 8 Apr 2019 19:40:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E89A28595 for ; Mon, 8 Apr 2019 19:40:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 126C9285A4; Mon, 8 Apr 2019 19:40:30 +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 725D3286FE for ; Mon, 8 Apr 2019 19:40:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729045AbfDHTkE (ORCPT ); Mon, 8 Apr 2019 15:40:04 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37208 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729042AbfDHTkD (ORCPT ); Mon, 8 Apr 2019 15:40:03 -0400 Received: by mail-pg1-f193.google.com with SMTP id e6so7881049pgc.4; Mon, 08 Apr 2019 12:40:02 -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=7THh9qsnCmidCNLaJzA4Mcp6adtL0OU5E3d8WEfwEdg=; b=hsNB/CZn/LdC5lYgP1F5SKG++4XATZEIpPQ4fS2xvzKgvl81GfVqB7kvW/L/pSXPCz JqWPIjo13jDes7CVn/MwT44NMRNr+CJGrBnTYtVMHBEv+0bhEgY+Gq87zElTQvc1IFcn Z+JH8X+NrqMvoKplyuEXuMmV8v8w22ixmHkxmSAo99vNeOERE0YAiPT+GBM9cFu77vPQ LUU+5WegxsVaaVw/whOpWx+UaGupUOWKSqJFTSfPr63PGWy1xYag7dNChnIl2VUipuXM fizS/f5hHShZeDfobIoRSxBin83trhsX5B2BJV89+PukPcGwfTgwPTctZURt+ccPOh4i 1dqQ== 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=7THh9qsnCmidCNLaJzA4Mcp6adtL0OU5E3d8WEfwEdg=; b=N6sK1MTABBr4/SA3xi+UkYwtGC3avfd+qlDkPguHC2dLOdA6om+LGrbsMeib5TI5Cv 9kXd7nr6dV3kU1HDYSLcTiSuMieBULhZF3F1DMVSka+CCGzveLrQDCNLmUqoWcw3/H+1 //3+tFXkjC4qsCPm26cWhfWG5qJpCwxU73AmUgLVxUTaqdX2tSFS/y3E/xTR5UWSP04T RLnaTAzXeVe9SPF62HQdrIfcfIpndctuX3/ncxKK3LMKWBNgaBlt1SQIjPyIpgehXWtG 6qMD+jtYkaR67niIw4kxPj8z3bVXG8Msnd6aQyQEMNPZrwo7GWf5UFatucYrvgAwrhYR hrsA== X-Gm-Message-State: APjAAAUKqJSIrlbjzfXyCveJuX54ucYPvhzBhkW4CtY6/oRo+LZHG/wy ogUw3IlFWAb3sa2Ths/ZgdQ= X-Google-Smtp-Source: APXvYqyA7yGKHn60b8Hc0KAj6jwBPG5avvELRuvuYKb5+A3mb4iiRg3vs7Kekq0NxmZsmiMpGD/Esw== X-Received: by 2002:a62:12c9:: with SMTP id 70mr32152540pfs.156.1554752402547; Mon, 08 Apr 2019 12:40:02 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 4sm49326074pgx.68.2019.04.08.12.40.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:40:01 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 18/22] watchdog: imgpdc_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:42 -0700 Message-Id: <1554752326-13319-19-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 devm_add_action_or_reset() for calls to clk_disable_unprepare - 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/imgpdc_wdt.c | 91 +++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 55 deletions(-) diff --git a/drivers/watchdog/imgpdc_wdt.c b/drivers/watchdog/imgpdc_wdt.c index 84c9fb905072..0fc31aadeee3 100644 --- a/drivers/watchdog/imgpdc_wdt.c +++ b/drivers/watchdog/imgpdc_wdt.c @@ -178,14 +178,20 @@ static const struct watchdog_ops pdc_wdt_ops = { .restart = pdc_wdt_restart, }; +static void pdc_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int pdc_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; u64 div; int ret, val; unsigned long clk_rate; struct pdc_wdt_dev *pdc_wdt; - pdc_wdt = devm_kzalloc(&pdev->dev, sizeof(*pdc_wdt), GFP_KERNEL); + pdc_wdt = devm_kzalloc(dev, sizeof(*pdc_wdt), GFP_KERNEL); if (!pdc_wdt) return -ENOMEM; @@ -193,42 +199,48 @@ static int pdc_wdt_probe(struct platform_device *pdev) if (IS_ERR(pdc_wdt->base)) return PTR_ERR(pdc_wdt->base); - pdc_wdt->sys_clk = devm_clk_get(&pdev->dev, "sys"); + pdc_wdt->sys_clk = devm_clk_get(dev, "sys"); if (IS_ERR(pdc_wdt->sys_clk)) { - dev_err(&pdev->dev, "failed to get the sys clock\n"); + dev_err(dev, "failed to get the sys clock\n"); return PTR_ERR(pdc_wdt->sys_clk); } - pdc_wdt->wdt_clk = devm_clk_get(&pdev->dev, "wdt"); + pdc_wdt->wdt_clk = devm_clk_get(dev, "wdt"); if (IS_ERR(pdc_wdt->wdt_clk)) { - dev_err(&pdev->dev, "failed to get the wdt clock\n"); + dev_err(dev, "failed to get the wdt clock\n"); return PTR_ERR(pdc_wdt->wdt_clk); } ret = clk_prepare_enable(pdc_wdt->sys_clk); if (ret) { - dev_err(&pdev->dev, "could not prepare or enable sys clock\n"); + dev_err(dev, "could not prepare or enable sys clock\n"); return ret; } + ret = devm_add_action_or_reset(dev, pdc_clk_disable_unprepare, + pdc_wdt->sys_clk); + if (ret) + return ret; ret = clk_prepare_enable(pdc_wdt->wdt_clk); if (ret) { - dev_err(&pdev->dev, "could not prepare or enable wdt clock\n"); - goto disable_sys_clk; + dev_err(dev, "could not prepare or enable wdt clock\n"); + return ret; } + ret = devm_add_action_or_reset(dev, pdc_clk_disable_unprepare, + pdc_wdt->wdt_clk); + if (ret) + return ret; /* We use the clock rate to calculate the max timeout */ clk_rate = clk_get_rate(pdc_wdt->wdt_clk); if (clk_rate == 0) { - dev_err(&pdev->dev, "failed to get clock rate\n"); - ret = -EINVAL; - goto disable_wdt_clk; + dev_err(dev, "failed to get clock rate\n"); + return -EINVAL; } if (order_base_2(clk_rate) > PDC_WDT_CONFIG_DELAY_MASK + 1) { - dev_err(&pdev->dev, "invalid clock rate\n"); - ret = -EINVAL; - goto disable_wdt_clk; + dev_err(dev, "invalid clock rate\n"); + return -EINVAL; } if (order_base_2(clk_rate) == 0) @@ -243,10 +255,10 @@ static int pdc_wdt_probe(struct platform_device *pdev) do_div(div, clk_rate); pdc_wdt->wdt_dev.max_timeout = div; pdc_wdt->wdt_dev.timeout = PDC_WDT_DEF_TIMEOUT; - pdc_wdt->wdt_dev.parent = &pdev->dev; + pdc_wdt->wdt_dev.parent = dev; watchdog_set_drvdata(&pdc_wdt->wdt_dev, pdc_wdt); - watchdog_init_timeout(&pdc_wdt->wdt_dev, heartbeat, &pdev->dev); + watchdog_init_timeout(&pdc_wdt->wdt_dev, heartbeat, dev); pdc_wdt_stop(&pdc_wdt->wdt_dev); @@ -257,24 +269,22 @@ static int pdc_wdt_probe(struct platform_device *pdev) case PDC_WDT_TICKLE_STATUS_TICKLE: case PDC_WDT_TICKLE_STATUS_TIMEOUT: pdc_wdt->wdt_dev.bootstatus |= WDIOF_CARDRESET; - dev_info(&pdev->dev, - "watchdog module last reset due to timeout\n"); + dev_info(dev, "watchdog module last reset due to timeout\n"); break; case PDC_WDT_TICKLE_STATUS_HRESET: - dev_info(&pdev->dev, + dev_info(dev, "watchdog module last reset due to hard reset\n"); break; case PDC_WDT_TICKLE_STATUS_SRESET: - dev_info(&pdev->dev, + dev_info(dev, "watchdog module last reset due to soft reset\n"); break; case PDC_WDT_TICKLE_STATUS_USER: - dev_info(&pdev->dev, + dev_info(dev, "watchdog module last reset due to user reset\n"); break; default: - dev_info(&pdev->dev, - "contains an illegal status code (%08x)\n", val); + dev_info(dev, "contains an illegal status code (%08x)\n", val); break; } @@ -283,36 +293,9 @@ static int pdc_wdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pdc_wdt); - ret = watchdog_register_device(&pdc_wdt->wdt_dev); - if (ret) - goto disable_wdt_clk; - - return 0; - -disable_wdt_clk: - clk_disable_unprepare(pdc_wdt->wdt_clk); -disable_sys_clk: - clk_disable_unprepare(pdc_wdt->sys_clk); - return ret; -} - -static void pdc_wdt_shutdown(struct platform_device *pdev) -{ - struct pdc_wdt_dev *pdc_wdt = platform_get_drvdata(pdev); - - pdc_wdt_stop(&pdc_wdt->wdt_dev); -} - -static int pdc_wdt_remove(struct platform_device *pdev) -{ - struct pdc_wdt_dev *pdc_wdt = platform_get_drvdata(pdev); - - pdc_wdt_stop(&pdc_wdt->wdt_dev); - watchdog_unregister_device(&pdc_wdt->wdt_dev); - clk_disable_unprepare(pdc_wdt->wdt_clk); - clk_disable_unprepare(pdc_wdt->sys_clk); - - return 0; + watchdog_stop_on_reboot(&pdc_wdt->wdt_dev); + watchdog_stop_on_unregister(&pdc_wdt->wdt_dev); + return devm_watchdog_register_device(dev, &pdc_wdt->wdt_dev); } static const struct of_device_id pdc_wdt_match[] = { @@ -327,8 +310,6 @@ static struct platform_driver pdc_wdt_driver = { .of_match_table = pdc_wdt_match, }, .probe = pdc_wdt_probe, - .remove = pdc_wdt_remove, - .shutdown = pdc_wdt_shutdown, }; module_platform_driver(pdc_wdt_driver); From patchwork Mon Apr 8 19:38:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890015 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 799DD922 for ; Mon, 8 Apr 2019 19:40:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 635B928595 for ; Mon, 8 Apr 2019 19:40:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57C03285EB; Mon, 8 Apr 2019 19:40:29 +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 EC25C28595 for ; Mon, 8 Apr 2019 19:40:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbfDHTkY (ORCPT ); Mon, 8 Apr 2019 15:40:24 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46209 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729047AbfDHTkE (ORCPT ); Mon, 8 Apr 2019 15:40:04 -0400 Received: by mail-pl1-f195.google.com with SMTP id y6so7895690pll.13; Mon, 08 Apr 2019 12:40:04 -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=xIRF9jSr1iNa9wj40bY49yAz39Ev5BypASacngynVKY=; b=DkYJ+EYTf815hQkznGXsTK/3ux2iVlO9yJfiA0ug79lnboY+XxN/yKswcZXFZrD1AQ B2maCLy0YKH7MfFRz5pbOm+sq5xAa518jjoGc76Zn/HEB7FZOL8U0sQFtBnfG80oqJ/a dRjzE3mKjBsa8GM8TsuXYq3s28XTcpWzyoruYQVIpXmV4FJKY3LN5v9LdLg6BgV/QQ16 UkHdVHtrZHcW9MKcT9X0oU+zYDZ4mnJ1ooTtV5WdxMokAiqvStuaGTTV+vBNFomV/NNd o/GEdvJLIKccECGg0GxHn6fndRubdzh9Gq3vAsNupD6rApD5w3DYdyudqTp97u0M0Qzy rzVg== 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=xIRF9jSr1iNa9wj40bY49yAz39Ev5BypASacngynVKY=; b=l6iuMggWke+unfAm3hLMDNKe5t19IunlJfwk//tY9Te2FYEV7Lp+b2Wpy3u9g10+Yi ApTmYbnfHq+Gin1G2Ty0mDDY5VBwMjf6bT8f4OUJbCa+ujeNqXl1x4FpoK4nznQE62iy YhPgLMVvDLiACRXGz/ME2Wjo8LLRw+Gk9QS7dXBPnX8B3G2ZGum4ltIrxEnMBCDQidui yjQA/GUwWey2NyAtSfXFeKGRcEjl3X3IPuPAuNVwIKekfzJKlri8paDV3n5sLMpClpGX 6oeyxiKP3xIHapezl9KgjU6Bd6SyUuA2m2oAG5K74v6KIb4q6UCH57KmvUyG80iOkfm5 3vBg== X-Gm-Message-State: APjAAAXPffXZJAZZxQvYM9doJQWa/HPk9qRcf/mtaunZ3rAScP5+RcCl SVw6ipWBbKxJhezyBk8tjuo= X-Google-Smtp-Source: APXvYqzK9BG3tKmqXh2yElYBXeannXSCvdvlTYkVnAiMVM0cATsZG8PjrIgwYlDmglmJPrDF0l5h8g== X-Received: by 2002:a17:902:76c1:: with SMTP id j1mr5024988plt.98.1554752403952; Mon, 08 Apr 2019 12:40:03 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k186sm19536778pfc.137.2019.04.08.12.40.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:40:03 -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: intel-mid_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Mon, 8 Apr 2019 12:38:43 -0700 Message-Id: <1554752326-13319-20-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly. 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 Signed-off-by: Guenter Roeck --- drivers/watchdog/intel-mid_wdt.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/watchdog/intel-mid_wdt.c b/drivers/watchdog/intel-mid_wdt.c index 72c108a12c19..6cf7cc1ff615 100644 --- a/drivers/watchdog/intel-mid_wdt.c +++ b/drivers/watchdog/intel-mid_wdt.c @@ -110,12 +110,13 @@ static const struct watchdog_ops mid_wdt_ops = { static int mid_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct watchdog_device *wdt_dev; - struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data; + struct intel_mid_wdt_pdata *pdata = dev->platform_data; int ret; if (!pdata) { - dev_err(&pdev->dev, "missing platform data\n"); + dev_err(dev, "missing platform data\n"); return -EINVAL; } @@ -125,7 +126,7 @@ static int mid_wdt_probe(struct platform_device *pdev) return ret; } - wdt_dev = devm_kzalloc(&pdev->dev, sizeof(*wdt_dev), GFP_KERNEL); + wdt_dev = devm_kzalloc(dev, sizeof(*wdt_dev), GFP_KERNEL); if (!wdt_dev) return -ENOMEM; @@ -134,16 +135,15 @@ static int mid_wdt_probe(struct platform_device *pdev) wdt_dev->min_timeout = MID_WDT_TIMEOUT_MIN; wdt_dev->max_timeout = MID_WDT_TIMEOUT_MAX; wdt_dev->timeout = MID_WDT_DEFAULT_TIMEOUT; - wdt_dev->parent = &pdev->dev; + wdt_dev->parent = dev; - watchdog_set_drvdata(wdt_dev, &pdev->dev); + watchdog_set_drvdata(wdt_dev, dev); - ret = devm_request_irq(&pdev->dev, pdata->irq, mid_wdt_irq, + ret = devm_request_irq(dev, pdata->irq, mid_wdt_irq, IRQF_SHARED | IRQF_NO_SUSPEND, "watchdog", wdt_dev); if (ret) { - dev_err(&pdev->dev, "error requesting warning irq %d\n", - pdata->irq); + dev_err(dev, "error requesting warning irq %d\n", pdata->irq); return ret; } @@ -163,13 +163,13 @@ static int mid_wdt_probe(struct platform_device *pdev) /* Make sure the watchdog is serviced */ set_bit(WDOG_HW_RUNNING, &wdt_dev->status); - ret = devm_watchdog_register_device(&pdev->dev, wdt_dev); + ret = devm_watchdog_register_device(dev, wdt_dev); if (ret) { - dev_err(&pdev->dev, "error registering watchdog device\n"); + dev_err(dev, "error registering watchdog device\n"); return ret; } - dev_info(&pdev->dev, "Intel MID watchdog device probed\n"); + dev_info(dev, "Intel MID watchdog device probed\n"); return 0; } From patchwork Mon Apr 8 19:38:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890011 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 1E9351669 for ; Mon, 8 Apr 2019 19:40:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0811828595 for ; Mon, 8 Apr 2019 19:40:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F08DB285EB; Mon, 8 Apr 2019 19:40:18 +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 DC07E28595 for ; Mon, 8 Apr 2019 19:40:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726796AbfDHTkG (ORCPT ); Mon, 8 Apr 2019 15:40:06 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:37237 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729088AbfDHTkG (ORCPT ); Mon, 8 Apr 2019 15:40:06 -0400 Received: by mail-pf1-f193.google.com with SMTP id 8so8219146pfr.4; Mon, 08 Apr 2019 12:40:05 -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=CdCl5pjlsRcAsU57NrbNiVOKzAX3GmE0CFq2biJi1zk=; b=hRMAKpMYPT1uKmhMyNuWRvV87mWrm9EB2zy+sRzfgW1AHi4WQfSsk/vaIosAdDV6yo JzklwgPYwvelastFJHhc/t134mMFytkMwuMwqUOXIR/wHSkAbqn2JCbRMkmECZgQQ9ZL FEzqotbb/PKeNdOWf2s4pzCiC3Z3Z+QiGaKmdGP/DtFvL8URsXQeEemAhvUt20hCH4o0 Gq01w67+WlMAetAshfzglfPTbcoumV7+pfxdHr/uPuqvDfqV0vf2aOdsXPUoMAiZgBNH L9+H45A1gCfh4g0uXuZfAG1mzMsgbUqi3yDL+Lh9/fr1zRbqhqjx5DEOOjs5AzREd51r 7FOw== 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=CdCl5pjlsRcAsU57NrbNiVOKzAX3GmE0CFq2biJi1zk=; b=laTINGspdGvT6JALRQh7/ObDHeJPum2cP69iHRzGxzzwbRtjHEPVFljEJd3kEJWXQc 2mefJjR5An3A3dJgZnOtXShqDJumsMrEJb3FXGYhaEpnR7VFZpCsswPHLzsIOt/t6vII n0vCKB4Zq4WA4aZ2DhtTjOvh7vGKYcAUnQWOYqnlcPDAU8D64gQpEmL/w3xclbOJV+BP rBGKV0lYCR4ifrvBCUVvhRgwAWf9MqpMDL9E1NpcpgGm3W9/GoQwLnmEOOcESeEFk55P z3slTwJqPpL+D8EkGYx3O+iha7zdvhsolBw3cHiVKSfd1xtyCMXKjlx4R/oeVVvwAwFw tR7A== X-Gm-Message-State: APjAAAXuFnnlr6IUNPpSzXFoJTQhT2hm+SMdyND8Z6mU+2b9VrIfeAn3 gHbvGDeOO9Mq7mdKSDq2GXI= X-Google-Smtp-Source: APXvYqzOSr1mvWulxUyZgVrCO0LW6xaXm+IYDobQ/PM0QMfMk5Rgeboy6YeQ7+MIiwtuZsssdhRkag== X-Received: by 2002:aa7:8289:: with SMTP id s9mr31537977pfm.208.1554752405297; Mon, 08 Apr 2019 12:40:05 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e4sm51663594pfh.146.2019.04.08.12.40.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:40:04 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 20/22] watchdog: kempld_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:44 -0700 Message-Id: <1554752326-13319-21-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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/kempld_wdt.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/watchdog/kempld_wdt.c b/drivers/watchdog/kempld_wdt.c index e268add43010..543eb0f27a42 100644 --- a/drivers/watchdog/kempld_wdt.c +++ b/drivers/watchdog/kempld_wdt.c @@ -467,7 +467,7 @@ static int kempld_wdt_probe(struct platform_device *pdev) KEMPLD_WDT_CFG_GLOBAL_LOCK)) { if (!nowayout) dev_warn(dev, - "Forcing nowayout - watchdog lock enabled!\n"); + "Forcing nowayout - watchdog lock enabled!\n"); nowayout = true; } @@ -492,7 +492,9 @@ static int kempld_wdt_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, wdt_data); - ret = watchdog_register_device(wdd); + watchdog_stop_on_reboot(wdd); + watchdog_stop_on_unregister(wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) return ret; @@ -501,26 +503,6 @@ static int kempld_wdt_probe(struct platform_device *pdev) return 0; } -static void kempld_wdt_shutdown(struct platform_device *pdev) -{ - struct kempld_wdt_data *wdt_data = platform_get_drvdata(pdev); - - kempld_wdt_stop(&wdt_data->wdd); -} - -static int kempld_wdt_remove(struct platform_device *pdev) -{ - struct kempld_wdt_data *wdt_data = platform_get_drvdata(pdev); - struct watchdog_device *wdd = &wdt_data->wdd; - int ret = 0; - - if (!nowayout) - ret = kempld_wdt_stop(wdd); - watchdog_unregister_device(wdd); - - return ret; -} - #ifdef CONFIG_PM /* Disable watchdog if it is active during suspend */ static int kempld_wdt_suspend(struct platform_device *pdev, @@ -567,8 +549,6 @@ static struct platform_driver kempld_wdt_driver = { .name = "kempld-wdt", }, .probe = kempld_wdt_probe, - .remove = kempld_wdt_remove, - .shutdown = kempld_wdt_shutdown, .suspend = kempld_wdt_suspend, .resume = kempld_wdt_resume, }; From patchwork Mon Apr 8 19:38:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890013 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 A5870922 for ; Mon, 8 Apr 2019 19:40:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ED4728595 for ; Mon, 8 Apr 2019 19:40:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80CA6285EB; Mon, 8 Apr 2019 19:40:24 +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 5510528595 for ; Mon, 8 Apr 2019 19:40:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729178AbfDHTkR (ORCPT ); Mon, 8 Apr 2019 15:40:17 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35556 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729042AbfDHTkH (ORCPT ); Mon, 8 Apr 2019 15:40:07 -0400 Received: by mail-pg1-f193.google.com with SMTP id g8so7886798pgf.2; Mon, 08 Apr 2019 12:40:07 -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=8MkCNyjFg+P+pMxDYmTJBU3ZbWVK/GY3Ec8mlqC2fOk=; b=sDn0cM1XDp8iKXLCfAt4nxPQy3AyKBv+w6PI6PdYGnn0gfHFWugxQhN17yRv4P4RGR kzO7KjouFiA+nByg+oqaiJOelAWRIRSAbnE4ukN9rE/egap8X4hyJwRSL9Cgkc1qEPKN MK9Kw6NSYWpebqoNBeld8l3xdO24f1BryqVqHwRVw5LPWpOKGepVzpKTU3DGBqU5LvDE R8y1K+ppxQJkeUmrDl7zLDDVZ/larvs1Db7HP9bU+BzGc7sdSU8RPciRprlN2Xku+ebv 8DFCsEBoHkktl4FN1ASah3Jrk7/4X8bxh/lVLKSF5lIfUYBv4oJBBRFxoWpNE/0mhod8 ipxQ== 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=8MkCNyjFg+P+pMxDYmTJBU3ZbWVK/GY3Ec8mlqC2fOk=; b=c7455gHcv2+JyRkmtTjtCPK8QoKzar/SWj3SlYV3qa/OWIi43G+4bndAq4I5T4G3FK CVr5CNGJyO4LCCvEJ1ZcG9wX2diy3L2th6N0z7a/QCQH17rmddzpBMJ6yQ47rkhGJzI4 bLgsoqB98UrXuqQiSLVOLxLkG2Y4LsdQoI35C4H+Ou80W2/zS6yTz9YHVuy7PhpJhIW+ EGkyABWksEYwZ2aGEulNB9qfeJ9xIEEzSxtBAFrPEq0cczAlaiz83T6TlyDwh1v+Zzgf KsDP28gcOLP3zDDaliNgsmR9PoWkYdwv7yXBSbTP3bIRs7CHkKUPHd3/BNehQAB7hZZS 2pVQ== X-Gm-Message-State: APjAAAUEDGMBrevXF4Au90EMjjM8oZuLoIfRZ6Qja4weP+WJlEPXX/R4 xS7rmW0vZruTwuYATh4AmGoJHgi+ X-Google-Smtp-Source: APXvYqx5HKVp/RxawXqu2jZLQyBfL4d+jyATxGOpCIdy2UdmCZCwuv90TfoiIUC7+Q1NAAUjh1Khsg== X-Received: by 2002:a62:5144:: with SMTP id f65mr32128637pfb.13.1554752406654; Mon, 08 Apr 2019 12:40:06 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id y20sm24486530pfe.188.2019.04.08.12.40.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:40:06 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Vladimir Zapolskiy Subject: [PATCH 21/22] watchdog: lpc18xx_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:45 -0700 Message-Id: <1554752326-13319-22-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 - Use devm_add_action_or_reset() for calls to clk_disable_unprepare - 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() Cc: Vladimir Zapolskiy Signed-off-by: Guenter Roeck --- drivers/watchdog/lpc18xx_wdt.c | 43 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/drivers/watchdog/lpc18xx_wdt.c b/drivers/watchdog/lpc18xx_wdt.c index f6f66634cedf..0e82abd71d35 100644 --- a/drivers/watchdog/lpc18xx_wdt.c +++ b/drivers/watchdog/lpc18xx_wdt.c @@ -200,6 +200,11 @@ static const struct watchdog_ops lpc18xx_wdt_ops = { .restart = lpc18xx_wdt_restart, }; +static void lpc18xx_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int lpc18xx_wdt_probe(struct platform_device *pdev) { struct lpc18xx_wdt_dev *lpc18xx_wdt; @@ -231,19 +236,26 @@ static int lpc18xx_wdt_probe(struct platform_device *pdev) dev_err(dev, "could not prepare or enable sys clock\n"); return ret; } + ret = devm_add_action_or_reset(dev, lpc18xx_clk_disable_unprepare, + lpc18xx_wdt->reg_clk); + if (ret) + return ret; ret = clk_prepare_enable(lpc18xx_wdt->wdt_clk); if (ret) { dev_err(dev, "could not prepare or enable wdt clock\n"); - goto disable_reg_clk; + return ret; } + ret = devm_add_action_or_reset(dev, lpc18xx_clk_disable_unprepare, + lpc18xx_wdt->wdt_clk); + if (ret) + return ret; /* We use the clock rate to calculate timeouts */ lpc18xx_wdt->clk_rate = clk_get_rate(lpc18xx_wdt->wdt_clk); if (lpc18xx_wdt->clk_rate == 0) { dev_err(dev, "failed to get clock rate\n"); - ret = -EINVAL; - goto disable_wdt_clk; + return -EINVAL; } lpc18xx_wdt->wdt_dev.info = &lpc18xx_wdt_info; @@ -274,24 +286,8 @@ static int lpc18xx_wdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, lpc18xx_wdt); - ret = watchdog_register_device(&lpc18xx_wdt->wdt_dev); - if (ret) - goto disable_wdt_clk; - - return 0; - -disable_wdt_clk: - clk_disable_unprepare(lpc18xx_wdt->wdt_clk); -disable_reg_clk: - clk_disable_unprepare(lpc18xx_wdt->reg_clk); - return ret; -} - -static void lpc18xx_wdt_shutdown(struct platform_device *pdev) -{ - struct lpc18xx_wdt_dev *lpc18xx_wdt = platform_get_drvdata(pdev); - - lpc18xx_wdt_stop(&lpc18xx_wdt->wdt_dev); + watchdog_stop_on_reboot(&lpc18xx_wdt->wdt_dev); + return devm_watchdog_register_device(dev, &lpc18xx_wdt->wdt_dev); } static int lpc18xx_wdt_remove(struct platform_device *pdev) @@ -301,10 +297,6 @@ static int lpc18xx_wdt_remove(struct platform_device *pdev) dev_warn(&pdev->dev, "I quit now, hardware will probably reboot!\n"); del_timer(&lpc18xx_wdt->timer); - watchdog_unregister_device(&lpc18xx_wdt->wdt_dev); - clk_disable_unprepare(lpc18xx_wdt->wdt_clk); - clk_disable_unprepare(lpc18xx_wdt->reg_clk); - return 0; } @@ -321,7 +313,6 @@ static struct platform_driver lpc18xx_wdt_driver = { }, .probe = lpc18xx_wdt_probe, .remove = lpc18xx_wdt_remove, - .shutdown = lpc18xx_wdt_shutdown, }; module_platform_driver(lpc18xx_wdt_driver); From patchwork Mon Apr 8 19:38:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10890009 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 866AB1669 for ; Mon, 8 Apr 2019 19:40:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F84D28595 for ; Mon, 8 Apr 2019 19:40:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62532285EB; Mon, 8 Apr 2019 19:40:17 +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 C195528595 for ; Mon, 8 Apr 2019 19:40:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729140AbfDHTkL (ORCPT ); Mon, 8 Apr 2019 15:40:11 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42325 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729125AbfDHTkI (ORCPT ); Mon, 8 Apr 2019 15:40:08 -0400 Received: by mail-pf1-f194.google.com with SMTP id w25so6762432pfi.9; Mon, 08 Apr 2019 12:40:08 -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=dhq23W063Hg+OizeeK28CfYTYMrp8EDUYCfhW6z14sY=; b=bLElhYcYFIHUI4PMLwo+mkkxO1LdYxsFvtg8QtUX72PU72XksZD8ID77vf1r8FIEXB qHyQqeGM5QO1ZMcTpAFyF7fdoN8ox6W8an4WuOmcuhk5hLbtspDGhCluxB0CAwOHbMxf X3pcKjgBn4ux7pe638ktbKNbp+6izk36gJCL4VyyakriwMrmaVLnVISC3ZhyNYlGbI/E dsHn7lxqi8GIJfTlhvE+r8hJdtAzC8xz49iqE6HSHqKSp1PML2F2OfImg68PnZR+YbcD +ftkcheXb5nwxWoKwrLmr04rTqEZw2F2XRCPECI2IN/HqGZmo2Z1jZJWCkILB3FmqPg9 0dPA== 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=dhq23W063Hg+OizeeK28CfYTYMrp8EDUYCfhW6z14sY=; b=Mgy1LrJZ8AavhXmUjX/4Qsv0A6RvvaDtz0GU27ClFF4LrgUcMf+CnR6Bl/l+VGsEHu 0Am7cuz9/Ucz/RgJBAiZzIjlLbHByWcMBH9syJNTllS3SGEQO6PKE3I8OPHP2cTC4woB ZbfrWE3+ywo9SSkAbF2BwU6BaUzfZ/iiwRTxNoNFkiplj1BNqF+ZXTaEks5Z4ocQmKc9 FJdNz72wNitCItuAYXSLtwDtgKbzMcv+6z8LqkTHXthuI0F0Jm8FkE0vdEYEKEfF0mml +u4jkx7DyJKVRrHDQtq/3v1Ypz9t0BtR2cugT9CcbulM+mKlWSVm7M88P87dA+l8//80 DQ8Q== X-Gm-Message-State: APjAAAV22Gk+YoY8AnFBxUyFZQOQGmOEmQ2yibPeVSQxzzKLSP9XXIGY 1MIM4tEvkE1XfBosXkzH3Os= X-Google-Smtp-Source: APXvYqwQmcY55dNXBsesBAW6bKAszhKxj2s0FvNY0YD40M7Qp6VT8yysYpntoBAN2hox4RVH20tKJw== X-Received: by 2002:a63:1918:: with SMTP id z24mr28803475pgl.406.1554752408016; Mon, 08 Apr 2019 12:40:08 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e4sm51663676pfh.146.2019.04.08.12.40.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:40:07 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 22/22] watchdog: max63xx_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:46 -0700 Message-Id: <1554752326-13319-23-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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 - Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly - Use devm_watchdog_register_driver() to register watchdog device Signed-off-by: Guenter Roeck --- drivers/watchdog/max63xx_wdt.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c index 5aaf13e5115a..3a899628a834 100644 --- a/drivers/watchdog/max63xx_wdt.c +++ b/drivers/watchdog/max63xx_wdt.c @@ -200,11 +200,12 @@ static int max63xx_mmap_init(struct platform_device *p, struct max63xx_wdt *wdt) static int max63xx_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct max63xx_wdt *wdt; struct max63xx_timeout *table; int err; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -215,7 +216,7 @@ static int max63xx_wdt_probe(struct platform_device *pdev) wdt->timeout = max63xx_select_timeout(table, heartbeat); if (!wdt->timeout) { - dev_err(&pdev->dev, "unable to satisfy %ds heartbeat request\n", + dev_err(dev, "unable to satisfy %ds heartbeat request\n", heartbeat); return -EINVAL; } @@ -227,30 +228,22 @@ static int max63xx_wdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &wdt->wdd); watchdog_set_drvdata(&wdt->wdd, wdt); - wdt->wdd.parent = &pdev->dev; + wdt->wdd.parent = dev; wdt->wdd.timeout = wdt->timeout->twd; wdt->wdd.info = &max63xx_wdt_info; wdt->wdd.ops = &max63xx_wdt_ops; watchdog_set_nowayout(&wdt->wdd, nowayout); - err = watchdog_register_device(&wdt->wdd); + err = devm_watchdog_register_device(dev, &wdt->wdd); if (err) return err; - dev_info(&pdev->dev, "using %ds heartbeat with %ds initial delay\n", + dev_info(dev, "using %ds heartbeat with %ds initial delay\n", wdt->timeout->twd, wdt->timeout->tdelay); return 0; } -static int max63xx_wdt_remove(struct platform_device *pdev) -{ - struct watchdog_device *wdd = platform_get_drvdata(pdev); - - watchdog_unregister_device(wdd); - return 0; -} - static const struct platform_device_id max63xx_id_table[] = { { "max6369_wdt", (kernel_ulong_t)max6369_table, }, { "max6370_wdt", (kernel_ulong_t)max6369_table, }, @@ -264,7 +257,6 @@ MODULE_DEVICE_TABLE(platform, max63xx_id_table); static struct platform_driver max63xx_wdt_driver = { .probe = max63xx_wdt_probe, - .remove = max63xx_wdt_remove, .id_table = max63xx_id_table, .driver = { .name = "max63xx_wdt",