From patchwork Wed Apr 10 16:27: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: 10894393 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 47F9D13B5 for ; Wed, 10 Apr 2019 16:30:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 325F228B6B for ; Wed, 10 Apr 2019 16:30:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C0D428A1E; Wed, 10 Apr 2019 16:30: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 7EC8328A1E for ; Wed, 10 Apr 2019 16:30:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387821AbfDJQ2O (ORCPT ); Wed, 10 Apr 2019 12:28:14 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46776 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728875AbfDJQ2K (ORCPT ); Wed, 10 Apr 2019 12:28:10 -0400 Received: by mail-pf1-f195.google.com with SMTP id 9so1762976pfj.13; Wed, 10 Apr 2019 09:28:09 -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=zrDUSZL8oOFl0c6GbsQEbRckVQXbnwOfvuwFmAPymj8=; b=l+15h4ldd1iec8qB4IrPTh4ZGMcUXZTucTr0LjXaSBnMDl2ssY88y3Izj1Vo0KB/or gNtDFienJiWKkQ5TEk+T87d37d13XjyRq7xxWlqnj9yXJpqdfmxJJ/f6ewhLGNTqrOwm 5x+HDwCZ2psknY/TDUY8S2xqZILg7S6yaK45UNCCKL84hHpzgdbWxM1fNB7YUWJa+D/Y Do0AuNoCrYE84o0xpcV7Sbnh0ZEWJpqy25VtgMdoRuHveCTPxojmxI+1hVgVxAlw3Wz4 ItY8AoLVnPQGriRhUf+9bgnyxKRUNF+1YRZN+778/6WWWM6Ah2z7fVRP/+ZfZFSabJBt zJuQ== 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=zrDUSZL8oOFl0c6GbsQEbRckVQXbnwOfvuwFmAPymj8=; b=BD3iKbdbOAhhA2oMu12SDLKiV2gMURRplZkkVlyTlfKI4EVxrQS9SpoSCdAYF2HPx9 yQA4exwtqO/8Uk7NtW4MspAN0ocNl624CwTi0j4vsJbfr6HvAYdMiqhbletLP93+EUON G9ypa0x9tdmpV4amZ4DRdDMLF+4QZCXk4QmzI9uiinwf8t4YRFMq4QbehTZ1+1WDNEmE 4EMc4GVN6Sqz4EyIzLjYprfmNZW1sj4X7yfstF7tvo8EiXTJa0fdhrUrzixNyWVpYYyg CZgnVwqTMvRh9PryGURqk5HhpY0pI7qHy/jVeeFsBypxg50bFLL9orrJTq0bLqqQ7mn8 fSbA== X-Gm-Message-State: APjAAAUVzfYC0I7RiP8qAsOw45upG5dOAEL7LvdFrNY4NER8cPd2Gbw9 2ZORioG2f9Z3I3L+vw5BdPk= X-Google-Smtp-Source: APXvYqwNLFXTygwYO3O6xLlZHRI7ExSyZk8N/cFj3Ig5PQ9zvvBLHQAwT4Y2AeXEkx7CpkJzXcdZiQ== X-Received: by 2002:a63:6907:: with SMTP id e7mr34269308pgc.209.1554913689373; Wed, 10 Apr 2019 09:28:09 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id t13sm27159345pgo.14.2019.04.10.09.28.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:08 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Thierry Reding , Jonathan Hunter Subject: [PATCH 01/22] watchdog: tegra_wdt: Use watchdog_stop_on_unregister and other improvements Date: Wed, 10 Apr 2019 09:27:42 -0700 Message-Id: <1554913683-25454-2-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use watchdog_stop_on_unregister() in probe instead of calling tegra_wdt_stop() in the remove function. Also introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly. Finally, drop the now empty remove function. 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: Thierry Reding Cc: Jonathan Hunter Signed-off-by: Guenter Roeck --- drivers/watchdog/tegra_wdt.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/watchdog/tegra_wdt.c b/drivers/watchdog/tegra_wdt.c index fc3cf5edf6c7..a58b000acc4f 100644 --- a/drivers/watchdog/tegra_wdt.c +++ b/drivers/watchdog/tegra_wdt.c @@ -181,6 +181,7 @@ static const struct watchdog_ops tegra_wdt_ops = { static int tegra_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct watchdog_device *wdd; struct tegra_wdt *wdt; void __iomem *regs; @@ -195,7 +196,7 @@ static int tegra_wdt_probe(struct platform_device *pdev) * Allocate our watchdog driver data, which has the * struct watchdog_device nested within it. */ - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -210,39 +211,27 @@ static int tegra_wdt_probe(struct platform_device *pdev) wdd->ops = &tegra_wdt_ops; wdd->min_timeout = MIN_WDT_TIMEOUT; wdd->max_timeout = MAX_WDT_TIMEOUT; - wdd->parent = &pdev->dev; + wdd->parent = dev; watchdog_set_drvdata(wdd, wdt); watchdog_set_nowayout(wdd, nowayout); - ret = devm_watchdog_register_device(&pdev->dev, wdd); + watchdog_stop_on_unregister(wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) { - dev_err(&pdev->dev, - "failed to register watchdog device\n"); + dev_err(dev, "failed to register watchdog device\n"); return ret; } platform_set_drvdata(pdev, wdt); - dev_info(&pdev->dev, - "initialized (heartbeat = %d sec, nowayout = %d)\n", + dev_info(dev, "initialized (heartbeat = %d sec, nowayout = %d)\n", heartbeat, nowayout); return 0; } -static int tegra_wdt_remove(struct platform_device *pdev) -{ - struct tegra_wdt *wdt = platform_get_drvdata(pdev); - - tegra_wdt_stop(&wdt->wdd); - - dev_info(&pdev->dev, "removed wdt\n"); - - return 0; -} - #ifdef CONFIG_PM_SLEEP static int tegra_wdt_runtime_suspend(struct device *dev) { @@ -278,7 +267,6 @@ static const struct dev_pm_ops tegra_wdt_pm_ops = { static struct platform_driver tegra_wdt_driver = { .probe = tegra_wdt_probe, - .remove = tegra_wdt_remove, .driver = { .name = "tegra-wdt", .pm = &tegra_wdt_pm_ops, From patchwork Wed Apr 10 16:27: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: 10894395 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 63DF617E0 for ; Wed, 10 Apr 2019 16:30:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46B7C28B20 for ; Wed, 10 Apr 2019 16:30:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4519928B24; Wed, 10 Apr 2019 16:30: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 A865528B37 for ; Wed, 10 Apr 2019 16:30:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387818AbfDJQ2O (ORCPT ); Wed, 10 Apr 2019 12:28:14 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45710 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387812AbfDJQ2L (ORCPT ); Wed, 10 Apr 2019 12:28:11 -0400 Received: by mail-pl1-f194.google.com with SMTP id bf11so1716845plb.12; Wed, 10 Apr 2019 09:28:11 -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=t3iZkPj/7QCSXgrBm7/GlIk+twTdtIQx1Nhm2nRrQHg=; b=tkPqN11s969TlYPx3VFZ2A3McPaHTkOy4MsIFU1DOC+BsBvlSipzYD7wELfzaw7s9I j1slMpZIvPm5+VQN7qc2eZWKjb+duuGvPnUa/Pf8S1haN4xfXnuiNHrtpJVq53S2iXTz V5sCdIFZOkYN/Lm31o0Koms+2Y0yFpDgOV2OdHpDSqVfimblpGHDXRlIkEItua4PLCF/ o6l98JmnG13/VmX+8yHbZLPjvMdztrnidV1uZb0BUu4WmoJOnAORT8gq1Sii87jkq1NM ieTedG9TT0XM4ZxCodZ9b8Wk6M7tqDpH8MDKsatEdkc+A31ayneXjzQ1jJVzkdX/C2ne 8VeA== 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=t3iZkPj/7QCSXgrBm7/GlIk+twTdtIQx1Nhm2nRrQHg=; b=LVxljmFy7xM+Jr8e5wd6hFrSQTPoSRu73hdCFgVs53LHTekJfFL5aEN8MjsHctjHMc JL9T6sjVbwCCjicJhCjnKYENbg/G569YbyK55/aq0X7OTpt62U01w8KzmisrX6Go8xW1 vKXAPxrDUUe4uxGJVG/LWwAqlzD218QFqLZkG03HKzHF4sLnfmLoQfodUg+HW8VO2PDB a2cm+NCbzYmKWzowLwIXDhSiYd82zR+BEDT+jzlMsqm8tZX0wk3N12dxk33+Lcx7KiAj 4ZH+qbWFqOJ3gvkwbLCajiSMCtSFMHk1OmRARGkvsOErB5iLCALwucWc74UhgScMN6IV pseg== X-Gm-Message-State: APjAAAVuEHdoBO2tWaFLL3K3RbkxSyNN3v0/tbeUqQx7sk2D/Bm/uWAz 3/znB1BHs/5nHV2M6a1Soac= X-Google-Smtp-Source: APXvYqxeklMPCnCSirHPjI0gup8IyZvEBoC+EMNKwfezsgxQfVBeWhDJfQQ2v+f/wRAJoCNE6sQu0Q== X-Received: by 2002:a17:902:b089:: with SMTP id p9mr19938275plr.185.1554913690705; Wed, 10 Apr 2019 09:28:10 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id m25sm49166154pfa.175.2019.04.10.09.28.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:10 -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: tqmx86_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Wed, 10 Apr 2019 09:27:43 -0700 Message-Id: <1554913683-25454-3-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/tqmx86_wdt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/tqmx86_wdt.c b/drivers/watchdog/tqmx86_wdt.c index 52941207a12a..72d0b0adde38 100644 --- a/drivers/watchdog/tqmx86_wdt.c +++ b/drivers/watchdog/tqmx86_wdt.c @@ -70,11 +70,12 @@ static struct watchdog_ops tqmx86_wdt_ops = { static int tqmx86_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct tqmx86_wdt *priv; struct resource *res; int err; - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -82,14 +83,13 @@ static int tqmx86_wdt_probe(struct platform_device *pdev) if (!res) return -ENODEV; - priv->io_base = devm_ioport_map(&pdev->dev, res->start, - resource_size(res)); + priv->io_base = devm_ioport_map(dev, res->start, resource_size(res)); if (!priv->io_base) return -ENOMEM; watchdog_set_drvdata(&priv->wdd, priv); - priv->wdd.parent = &pdev->dev; + priv->wdd.parent = dev; priv->wdd.info = &tqmx86_wdt_info; priv->wdd.ops = &tqmx86_wdt_ops; priv->wdd.min_timeout = 1; @@ -97,16 +97,16 @@ static int tqmx86_wdt_probe(struct platform_device *pdev) priv->wdd.max_hw_heartbeat_ms = 4096*1000; priv->wdd.timeout = WDT_TIMEOUT; - watchdog_init_timeout(&priv->wdd, timeout, &pdev->dev); + watchdog_init_timeout(&priv->wdd, timeout, dev); watchdog_set_nowayout(&priv->wdd, WATCHDOG_NOWAYOUT); tqmx86_wdt_set_timeout(&priv->wdd, priv->wdd.timeout); - err = devm_watchdog_register_device(&pdev->dev, &priv->wdd); + err = devm_watchdog_register_device(dev, &priv->wdd); if (err) return err; - dev_info(&pdev->dev, "TQMx86 watchdog\n"); + dev_info(dev, "TQMx86 watchdog\n"); return 0; } From patchwork Wed Apr 10 16:27: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: 10894353 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 ACCF817E0 for ; Wed, 10 Apr 2019 16:28:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 995A828BC6 for ; Wed, 10 Apr 2019 16:28:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D9FB28BA8; Wed, 10 Apr 2019 16:28:15 +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 0C64A28B95 for ; Wed, 10 Apr 2019 16:28:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387815AbfDJQ2O (ORCPT ); Wed, 10 Apr 2019 12:28:14 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:35756 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731977AbfDJQ2N (ORCPT ); Wed, 10 Apr 2019 12:28:13 -0400 Received: by mail-pf1-f194.google.com with SMTP id t21so1800253pfh.2; Wed, 10 Apr 2019 09:28:12 -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=3IlgT7nY07HPFlMA+WrAZzzctpP7991Q2yQyFRscuWw=; b=raT8M/tM7l611F0M2XPq9Iu8xGx43KTlbeKmxJwEsLZJ7eNg4nHXwgQmly1OWHAhrw APMC6l1gjBZsb9ECHGaVEl3MAu+HVrBROQxRb8T/uGM9Y+c+clEG6tR5t7+LUBAfMCD3 bZgXTHoB72BpvD/8DkHHV2aecbwgpibDMSeb1gd6ILEqaC5SIjqB+NJ4yfKy2wZPClxs Cvlogxhtx4ONLXJyNEXo1Pcq+JrGTkqcZr3DASNaI9w0I5zWKWZGkxiIdFH2HQr9nm7b PnHCoZ4gBohCJwEXWtiKAwl6A5ZJ+9wyNTDBQlmSDpJoI0zfLj+35RKtAo5GtmxYVVv2 yKiQ== 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=3IlgT7nY07HPFlMA+WrAZzzctpP7991Q2yQyFRscuWw=; b=I8CZFDZ/cGNZFbAoSnJ72yOrT/JbTqMWrDxBwsafPl+zBh2fU0PVV8dbIlUDc+bPo1 0ojdROue5p1IFintTbq+ejfl1oHZRJWZq660vJa/os2Ynf7c13bccplWIv715NXs2rYE D/4UTR2zamxy7cVusY15dKqaG/EcC41esv2AAJItRED8Z/in8XnB77q1sYw5xj4N4zDl Lco6EoXqWX0EEdQ0zQtWr+R3HnAXuOB3/YJqG6+gvU1xo3qJopbSFK5K0hx24b5Ai9Kx cxvMScRFC4zFoFotdzdpo+Zyj5iVxdk03DnBJCf6UPMTBM25gc+K7HkYvuCh33OELIL4 +UjQ== X-Gm-Message-State: APjAAAW6hcInixcJ1lJoqd2ZXSie/8EQ9Q14UXkxVrrCz9u/Djr7HVn4 YYcKfHEHJIns4OugoMoUcOI= X-Google-Smtp-Source: APXvYqxyv6BTQFrrkV9Xb+gRkQUmsuO/4/tAqUxjHyfyxbCZ5lfLPt3lWzaVlZlQcQuKNkc1attHLQ== X-Received: by 2002:a63:1f52:: with SMTP id q18mr42969142pgm.134.1554913692074; Wed, 10 Apr 2019 09:28:12 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id p2sm113221936pfi.73.2019.04.10.09.28.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:11 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 03/22] watchdog: ts4800_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:44 -0700 Message-Id: <1554913683-25454-4-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop empty remove function - 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/ts4800_wdt.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/watchdog/ts4800_wdt.c b/drivers/watchdog/ts4800_wdt.c index 89843b16b04a..9dc6d7f45806 100644 --- a/drivers/watchdog/ts4800_wdt.c +++ b/drivers/watchdog/ts4800_wdt.c @@ -108,7 +108,8 @@ static const struct watchdog_info ts4800_wdt_info = { static int ts4800_wdt_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; struct device_node *syscon_np; struct watchdog_device *wdd; struct ts4800_wdt *wdt; @@ -117,18 +118,18 @@ static int ts4800_wdt_probe(struct platform_device *pdev) syscon_np = of_parse_phandle(np, "syscon", 0); if (!syscon_np) { - dev_err(&pdev->dev, "no syscon property\n"); + dev_err(dev, "no syscon property\n"); return -ENODEV; } ret = of_property_read_u32_index(np, "syscon", 1, ®); if (ret < 0) { - dev_err(&pdev->dev, "no offset in syscon\n"); + dev_err(dev, "no offset in syscon\n"); return ret; } /* allocate memory for watchdog struct */ - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -137,13 +138,13 @@ static int ts4800_wdt_probe(struct platform_device *pdev) wdt->regmap = syscon_node_to_regmap(syscon_np); of_node_put(syscon_np); if (IS_ERR(wdt->regmap)) { - dev_err(&pdev->dev, "cannot get parent's regmap\n"); + dev_err(dev, "cannot get parent's regmap\n"); return PTR_ERR(wdt->regmap); } /* Initialize struct watchdog_device */ wdd = &wdt->wdd; - wdd->parent = &pdev->dev; + wdd->parent = dev; wdd->info = &ts4800_wdt_info; wdd->ops = &ts4800_wdt_ops; wdd->min_timeout = ts4800_wdt_map[0].timeout; @@ -151,7 +152,7 @@ static int ts4800_wdt_probe(struct platform_device *pdev) watchdog_set_drvdata(wdd, wdt); watchdog_set_nowayout(wdd, nowayout); - watchdog_init_timeout(wdd, 0, &pdev->dev); + watchdog_init_timeout(wdd, 0, dev); /* * As this watchdog supports only a few values, ts4800_wdt_set_timeout @@ -169,31 +170,20 @@ static int ts4800_wdt_probe(struct platform_device *pdev) */ ts4800_wdt_stop(wdd); - ret = watchdog_register_device(wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) { - dev_err(&pdev->dev, - "failed to register watchdog device\n"); + dev_err(dev, "failed to register watchdog device\n"); return ret; } platform_set_drvdata(pdev, wdt); - dev_info(&pdev->dev, - "initialized (timeout = %d sec, nowayout = %d)\n", + dev_info(dev, "initialized (timeout = %d sec, nowayout = %d)\n", wdd->timeout, nowayout); return 0; } -static int ts4800_wdt_remove(struct platform_device *pdev) -{ - struct ts4800_wdt *wdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(&wdt->wdd); - - return 0; -} - static const struct of_device_id ts4800_wdt_of_match[] = { { .compatible = "technologic,ts4800-wdt", }, { }, @@ -202,7 +192,6 @@ MODULE_DEVICE_TABLE(of, ts4800_wdt_of_match); static struct platform_driver ts4800_wdt_driver = { .probe = ts4800_wdt_probe, - .remove = ts4800_wdt_remove, .driver = { .name = "ts4800_wdt", .of_match_table = ts4800_wdt_of_match, From patchwork Wed Apr 10 16:27: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: 10894391 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 0B719186D for ; Wed, 10 Apr 2019 16:30:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA0EF28AF8 for ; Wed, 10 Apr 2019 16:30:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E83EA28B68; Wed, 10 Apr 2019 16:30:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 9016828B75 for ; Wed, 10 Apr 2019 16:30:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387823AbfDJQ2P (ORCPT ); Wed, 10 Apr 2019 12:28:15 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45066 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387813AbfDJQ2O (ORCPT ); Wed, 10 Apr 2019 12:28:14 -0400 Received: by mail-pg1-f196.google.com with SMTP id y3so1841775pgk.12; Wed, 10 Apr 2019 09:28:13 -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=3medKjGV47ZOPN+yjhvR37qQjE3neDO4pCs+uQdUuow=; b=SiLoy+uv58kts4jBEs48iVumvE/HLvagIxBjXPUYtsQfKZqe5qcnM2+ig+ooKiSkFn E4gpQViNBSDQtQ3aI6Vg3lsVguei+TftF02nCcUy4IaSZxkddkgNWK3cE8B5RxAHiGZW OcmAx99CJ8QpL+kLOikMEi0fGtQmjAwAnjDrg5Jx3Ju1Ui9wOJ/bYaVEplEIwAP1+8/r uI54dkYcR8NQZZY/prbkdhUPq78mEmIm7P+s6jKZl8LtSQCAP7cIwMHyBq+WgZCvVGQ0 AMtmTqXU/jnAiQcDL9vgJzxmHng+xOSEx2h9y0FoYaXvd5u9OFQjP9KSLreNQ389k1ng fBMQ== 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=3medKjGV47ZOPN+yjhvR37qQjE3neDO4pCs+uQdUuow=; b=VEN6hN7Mh5K4kNiLMsusNXgX1qiV3Mzkg0o6yeimR38zBta6g8PM4hJR84gHoQM6q6 S77eWxjKUCvbT0/6/37kYcuRqjEwXoeHisxwM4DEcvDEILHPfo98NUL28PzEfvBL4Zek CzbKm1cQL8XA6GP13y27yUX6UK/foN5IZYnp+KJ32eUSp3U/Ct4IRm12bqkRI5NUT702 a4XdC/w9J4UDLFgD645i8ysKGgcMVYpH92s4F4u0m/3QcoyiY1kWHUNBD9zPFo8HiHn5 JR6WSupG/HmJtQd+sgg+SXhrY0BGvIJoTQUZoSlQ5hXC/QIz/66/6lqWJTkqv+KBLoNa UjEQ== X-Gm-Message-State: APjAAAV/JVnt/tsrcydxkVSpyaOAmhpVxOJRbWCnZGM378C/8fE/5bbJ RBFuSUS5tSclFJkrq5lkAksw1aVW X-Google-Smtp-Source: APXvYqwMD17pV8HqfUE8FecYaD+ZJ4CqA71db2mZ8Z139UVyRSd5PdhoUU73zQHncAnoHK1ZOvBzoA== X-Received: by 2002:a63:6849:: with SMTP id d70mr41635996pgc.21.1554913693429; Wed, 10 Apr 2019 09:28:13 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k124sm61321660pgc.65.2019.04.10.09.28.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:12 -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: ts72xx_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Wed, 10 Apr 2019 09:27:45 -0700 Message-Id: <1554913683-25454-5-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/ts72xx_wdt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/ts72xx_wdt.c b/drivers/watchdog/ts72xx_wdt.c index 3aa11c84dea9..bf918f5fa131 100644 --- a/drivers/watchdog/ts72xx_wdt.c +++ b/drivers/watchdog/ts72xx_wdt.c @@ -122,11 +122,12 @@ static const struct watchdog_ops ts72xx_wdt_ops = { static int ts72xx_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct ts72xx_wdt_priv *priv; struct watchdog_device *wdd; int ret; - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -143,20 +144,20 @@ static int ts72xx_wdt_probe(struct platform_device *pdev) wdd->ops = &ts72xx_wdt_ops; wdd->min_timeout = 1; wdd->max_hw_heartbeat_ms = 8000; - wdd->parent = &pdev->dev; + wdd->parent = dev; watchdog_set_nowayout(wdd, nowayout); wdd->timeout = TS72XX_WDT_DEFAULT_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, "TS-72xx Watchdog driver\n"); + dev_info(dev, "TS-72xx Watchdog driver\n"); return 0; } From patchwork Wed Apr 10 16:27: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: 10894389 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 8275F13B5 for ; Wed, 10 Apr 2019 16:30:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C0F228AC0 for ; Wed, 10 Apr 2019 16:30:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A10B28B2D; Wed, 10 Apr 2019 16:30:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 F385228B67 for ; Wed, 10 Apr 2019 16:30:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732424AbfDJQaG (ORCPT ); Wed, 10 Apr 2019 12:30:06 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34163 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387826AbfDJQ2P (ORCPT ); Wed, 10 Apr 2019 12:28:15 -0400 Received: by mail-pg1-f195.google.com with SMTP id v12so1877911pgq.1; Wed, 10 Apr 2019 09:28:15 -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=7d8y9AaFPQzWfMw+rRzXEYOrli0Bj0Hj+AuP2Kt4PtY=; b=PFsQFKHPY7fZi5sHcitxzm8lzcIf3CbKyaLPucO7NXshFKZHyg5ca4llgbbnUlTQU6 HeAurxc/iQhctxiIuPbX3l0XO69QjGoMa6bY8hKvXiLMtJSrjzhN8aDOKFUyhz4ReVga 2h70mgrrnwlTOYz+gnnVRw6CjdIS28hCNi/RnitrxvlSoh63bmaxbQn+ScPCG0uQbt6A dyOvr9dB+fk3A5J+oY+C2oeAnTXoGMJH32oWW3p5oG9JE4T2NDkeLIy9SDEkGLkj0xbL LfTajllZwcYaaXExukomxlEbrBbtGKKPgBiycfusdEPAmqePDUx7WrJ22rD0QyJECgeq RZyg== 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=7d8y9AaFPQzWfMw+rRzXEYOrli0Bj0Hj+AuP2Kt4PtY=; b=SOaBPzW5qbHO7u5ehf2HVYWe+ar/P4inp4BFmz3/qCIv/YOAhG5V6WOFtKXz4D5Ngx LQJImuDAwWuzA47d+YRq5beW7f79dnoJ4hJ+P5fyVu+/d5v+Td9J5qW2c/n8a3ST9hY1 yjrcGW3fbwE3uHloMa018tCGYegCTBP7xJklX/2Hnj2Q+VJqWzO1raO+Q5WbFgP0EaJU 7qqDfwGyJr6lC00rGS73G240Dy1E4wD6eAzddQ8jw5jbFrVUmpex5/br1AG9J8g+Hd2X ZjPrtOWHOOdqIdsGvkrYJDe6DjPSctdqa4N98aInMdsO10Hz9ei4Vp8IUpx0OKRhycyF twRg== X-Gm-Message-State: APjAAAX6GBb37AF77s77IYTQR5qxjkXJGbpSXdg1/wKfXIE103qX43sl Pt9c1ixV7CsD8bOfat0pN7bFiYdY X-Google-Smtp-Source: APXvYqwQc4XE5V6f4wnfvXH/Emk+pwYA4neiEWr2Ald8g4SZNB4yhNihE8LzzRbV1LC7MwLtZqV/pQ== X-Received: by 2002:a62:4602:: with SMTP id t2mr44116656pfa.26.1554913694884; Wed, 10 Apr 2019 09:28:14 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id x8sm28585202pgp.48.2019.04.10.09.28.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:14 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 05/22] watchdog: twl4030_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:46 -0700 Message-Id: <1554913683-25454-6-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop empty remove function - 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/twl4030_wdt.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c index 569fe85e52da..74c5737cd934 100644 --- a/drivers/watchdog/twl4030_wdt.c +++ b/drivers/watchdog/twl4030_wdt.c @@ -70,10 +70,10 @@ static const struct watchdog_ops twl4030_wdt_ops = { static int twl4030_wdt_probe(struct platform_device *pdev) { - int ret = 0; + struct device *dev = &pdev->dev; struct watchdog_device *wdt; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -83,27 +83,14 @@ static int twl4030_wdt_probe(struct platform_device *pdev) wdt->timeout = 30; wdt->min_timeout = 1; wdt->max_timeout = 30; - wdt->parent = &pdev->dev; + wdt->parent = dev; watchdog_set_nowayout(wdt, nowayout); platform_set_drvdata(pdev, wdt); twl4030_wdt_stop(wdt); - ret = watchdog_register_device(wdt); - if (ret) - return ret; - - return 0; -} - -static int twl4030_wdt_remove(struct platform_device *pdev) -{ - struct watchdog_device *wdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(wdt); - - return 0; + return devm_watchdog_register_device(dev, wdt); } #ifdef CONFIG_PM @@ -137,7 +124,6 @@ MODULE_DEVICE_TABLE(of, twl_wdt_of_match); static struct platform_driver twl4030_wdt_driver = { .probe = twl4030_wdt_probe, - .remove = twl4030_wdt_remove, .suspend = twl4030_wdt_suspend, .resume = twl4030_wdt_resume, .driver = { From patchwork Wed Apr 10 16:27:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894387 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 89BAF13B5 for ; Wed, 10 Apr 2019 16:30:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7495628A0C for ; Wed, 10 Apr 2019 16:30:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 693CA28757; Wed, 10 Apr 2019 16:30:06 +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 EC31A28844 for ; Wed, 10 Apr 2019 16:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731915AbfDJQaA (ORCPT ); Wed, 10 Apr 2019 12:30:00 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43606 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731977AbfDJQ2Q (ORCPT ); Wed, 10 Apr 2019 12:28:16 -0400 Received: by mail-pl1-f196.google.com with SMTP id n8so1719128plp.10; Wed, 10 Apr 2019 09:28:16 -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=n2dbwiTzjex313CSAoOauK9n+B2nkUG9p1gWKyCrLDw=; b=MBy0ULhcPapht1HIARJ+gUc8r5fKZG8nKEYFvd6MAjP3G+QkK9PG5CB3Ip5T2LMUvb ZfLjfJmBnXsQTsrPd0BfVjUZCYi6BQEom+EMsH8GhyyxML81ABmhRSeL6klHeF0nHPz2 ipit3lT1GBFm3RmY0gFjFTLc5dVtrYbmCc1a/l5FRLxVrK3vja8ZO1FpQyBGpGIG9mdg waddcDYBRzNl2GJ6+pSuAMf54pyJa+Frsx5mnrYSuNAqB1oHVgm7JXR64Dqm9GIhkU9s 6MxH19IxPVoteCQnEwQtElB7a0KTCVlL3b9Ym8vN1P4wnxjy6COJvQDbvAjmfrDlZU8i LuhQ== 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=n2dbwiTzjex313CSAoOauK9n+B2nkUG9p1gWKyCrLDw=; b=N9jat8XY542vKT3AM2LZfOMcIiPbDM0byOZGVY6+Q0O0k7w8BPP8fmwYjkMWNncyvp gg7h3FysBmC+ovXY4m3/CcHMApzkOTepDgDafOR0tgax1rjL6LG5K8/1ohVmv8t26gLm Oq48d+gmV5tzLRa3enIE8rC8ubC1ipzhtMgfXhbo+bswQ8ujvi1KuoneAJ5uRmIZtbzN t2Jc0PBEac85UY0eWnpFLDUWQ9BlScdfKc4Q5SYR65VMLi3yvRvGvARNQlqf4yH5Ema/ /ZdrRj2hGY/wUvHeyf51JfX5noQQxrntGAE5sWnoD3hvYWFi38IxvgzcnWJy4bioifwk 5GNg== X-Gm-Message-State: APjAAAX8n/XxzZhpc4XmEvp6PWNhKsIZtRsEtjg2UQ+WXlqeacJ+aaBt Z9Eqzo/zBXd6APSMBy88aZcA0ge4 X-Google-Smtp-Source: APXvYqyU1/TNYpqmcyM4bvl0fnIMtbnL/QMtSHjYKqTnuVvH8fTnz5zIi8e7Ha0+TDqOQA9Yg02shQ== X-Received: by 2002:a17:902:110b:: with SMTP id d11mr6750867pla.275.1554913696222; Wed, 10 Apr 2019 09:28:16 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id g2sm54659978pfd.134.2019.04.10.09.28.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:15 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Masahiro Yamada Subject: [PATCH 06/22] watchdog: uniphier_wdt: drop platform_set_drvdata Date: Wed, 10 Apr 2019 09:27:47 -0700 Message-Id: <1554913683-25454-7-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is no call to dev_get_drvdata() or platform_get_drvdata() in the driver. Drop the unnecessary call to platform_set_drvdata(). 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: Masahiro Yamada Signed-off-by: Guenter Roeck --- drivers/watchdog/uniphier_wdt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/watchdog/uniphier_wdt.c b/drivers/watchdog/uniphier_wdt.c index e20a7a459d69..8e9242c23022 100644 --- a/drivers/watchdog/uniphier_wdt.c +++ b/drivers/watchdog/uniphier_wdt.c @@ -191,8 +191,6 @@ static int uniphier_wdt_probe(struct platform_device *pdev) if (!wdev) return -ENOMEM; - platform_set_drvdata(pdev, wdev); - parent = of_get_parent(dev->of_node); /* parent should be syscon node */ regmap = syscon_node_to_regmap(parent); of_node_put(parent); From patchwork Wed Apr 10 16:27:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894381 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 C25D1139A for ; Wed, 10 Apr 2019 16:29:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC0A9286B4 for ; Wed, 10 Apr 2019 16:29:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA38828806; Wed, 10 Apr 2019 16:29:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F257287FB for ; Wed, 10 Apr 2019 16:29:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387856AbfDJQ2V (ORCPT ); Wed, 10 Apr 2019 12:28:21 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:38610 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387850AbfDJQ2S (ORCPT ); Wed, 10 Apr 2019 12:28:18 -0400 Received: by mail-pg1-f195.google.com with SMTP id j26so1864837pgl.5; Wed, 10 Apr 2019 09:28:17 -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=QwAPcVTaRjeqfsFr8XXwNRJEpE416YFfDiIeqJBF43g=; b=jif+mwfAxK/aeRxRT38GaXeBRHVweFZMnOQEl05ep50rY+Zuc0QFpqVrAxAdvcP4iV QpM8w2sKG7Zyr5ZRAM16LKowPTImWCxz7PJJeyjWT4skraSYlMHQ9O+qYwMmMLkFyao8 HcFx+uSvaeyLnFnJyVjqgDquDkgWrcAtxeASdn/RBo1DtLDuKXejoQxGWdVIUOKEulH3 ZcXyAJj3on663R40l+1TtuG66KlEatd/rG6qOhRCbCD6NG2E+gN8ZJ4zG+RatZ7ac1+J ihtloAKtbOsERn80OhnIIWVCsfZgalTRgFnRDlZZrTq47lt9rrG0wCBS4DFt/RZugDoa aBgg== 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=QwAPcVTaRjeqfsFr8XXwNRJEpE416YFfDiIeqJBF43g=; b=h0Z0WQEyIUBKdOMkPL4YoD+fttSH9DsenIRSEOh1g6Ih/V418Q8SJ9KgUdzl7wToKG yEqPOE0L6XBBP4HP/yTjEnqFeYnD1Jcw9SCqCc2k0AA4tIQ5BK7TWPp5oE0hO3PUnwUR WBks96GA1R8XcPU6mXGBXyINpw09/IAaBWdzlq0Goyw1UnA+EkResKkp074Y98aDf8Pr 2DUCDRu8ZFjQS68ByXiJ7Z6FC9QN26dbapDNydA0iFkYpTVbsqr0FI8C/b+dtd8hc7II uH/NEqh+mwOENqJYKMPg7TlbnGUOf78PpFQUbM+2y+rIt33EXxz99BkJlENgfyId6OAG 1tDA== X-Gm-Message-State: APjAAAVG45VM4nxhmSzxO38qxeb62yFy8pATSa32n+bXpeD1B+nQegjv 9+mptDQ+QqtqNBH19YyqEBc= X-Google-Smtp-Source: APXvYqwqhw4nFCU7IjLHo/biDMFNZzKeeocxwx64eAHs4qDA5c/oPvV+aDBqBj0OODLQg2/hx3v+LQ== X-Received: by 2002:a63:195f:: with SMTP id 31mr42145008pgz.116.1554913697545; Wed, 10 Apr 2019 09:28:17 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id r145sm82062726pgr.84.2019.04.10.09.28.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:17 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 07/22] watchdog: wdat_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Wed, 10 Apr 2019 09:27:48 -0700 Message-Id: <1554913683-25454-8-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/wdat_wdt.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c index 387892fe63b4..430ee4e9b185 100644 --- a/drivers/watchdog/wdat_wdt.c +++ b/drivers/watchdog/wdat_wdt.c @@ -308,6 +308,7 @@ static const struct watchdog_ops wdat_wdt_ops = { static int wdat_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; const struct acpi_wdat_entry *entries; const struct acpi_table_wdat *tbl; struct wdat_wdt *wdat; @@ -321,11 +322,11 @@ static int wdat_wdt_probe(struct platform_device *pdev) if (ACPI_FAILURE(status)) return -ENODEV; - wdat = devm_kzalloc(&pdev->dev, sizeof(*wdat), GFP_KERNEL); + wdat = devm_kzalloc(dev, sizeof(*wdat), GFP_KERNEL); if (!wdat) return -ENOMEM; - regs = devm_kcalloc(&pdev->dev, pdev->num_resources, sizeof(*regs), + regs = devm_kcalloc(dev, pdev->num_resources, sizeof(*regs), GFP_KERNEL); if (!regs) return -ENOMEM; @@ -350,15 +351,15 @@ static int wdat_wdt_probe(struct platform_device *pdev) res = &pdev->resource[i]; if (resource_type(res) == IORESOURCE_MEM) { - reg = devm_ioremap_resource(&pdev->dev, res); + reg = devm_ioremap_resource(dev, res); if (IS_ERR(reg)) return PTR_ERR(reg); } else if (resource_type(res) == IORESOURCE_IO) { - reg = devm_ioport_map(&pdev->dev, res->start, 1); + reg = devm_ioport_map(dev, res->start, 1); if (!reg) return -ENOMEM; } else { - dev_err(&pdev->dev, "Unsupported resource\n"); + dev_err(dev, "Unsupported resource\n"); return -EINVAL; } @@ -376,12 +377,11 @@ static int wdat_wdt_probe(struct platform_device *pdev) action = entries[i].action; if (action >= MAX_WDAT_ACTIONS) { - dev_dbg(&pdev->dev, "Skipping unknown action: %u\n", - action); + dev_dbg(dev, "Skipping unknown action: %u\n", action); continue; } - instr = devm_kzalloc(&pdev->dev, sizeof(*instr), GFP_KERNEL); + instr = devm_kzalloc(dev, sizeof(*instr), GFP_KERNEL); if (!instr) return -ENOMEM; @@ -398,7 +398,7 @@ static int wdat_wdt_probe(struct platform_device *pdev) } else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { r.flags = IORESOURCE_IO; } else { - dev_dbg(&pdev->dev, "Unsupported address space: %d\n", + dev_dbg(dev, "Unsupported address space: %d\n", gas->space_id); continue; } @@ -413,14 +413,15 @@ static int wdat_wdt_probe(struct platform_device *pdev) } if (!instr->reg) { - dev_err(&pdev->dev, "I/O resource not found\n"); + dev_err(dev, "I/O resource not found\n"); return -EINVAL; } instructions = wdat->instructions[action]; if (!instructions) { - instructions = devm_kzalloc(&pdev->dev, - sizeof(*instructions), GFP_KERNEL); + instructions = devm_kzalloc(dev, + sizeof(*instructions), + GFP_KERNEL); if (!instructions) return -ENOMEM; @@ -441,7 +442,7 @@ static int wdat_wdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, wdat); watchdog_set_nowayout(&wdat->wdd, nowayout); - return devm_watchdog_register_device(&pdev->dev, &wdat->wdd); + return devm_watchdog_register_device(dev, &wdat->wdd); } #ifdef CONFIG_PM_SLEEP From patchwork Wed Apr 10 16:27:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894385 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 A5EA417E0 for ; Wed, 10 Apr 2019 16:29:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 902B828844 for ; Wed, 10 Apr 2019 16:29:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79CA0288C3; Wed, 10 Apr 2019 16:29:57 +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 DF406288C3 for ; Wed, 10 Apr 2019 16:29:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387855AbfDJQ3v (ORCPT ); Wed, 10 Apr 2019 12:29:51 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:36424 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387854AbfDJQ2T (ORCPT ); Wed, 10 Apr 2019 12:28:19 -0400 Received: by mail-pf1-f196.google.com with SMTP id z5so1798098pfn.3; Wed, 10 Apr 2019 09:28:19 -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=seHjBqaBud1mYkVOqcRVoUipgYEoJz3N4GGlHqlC5Ho=; b=fhnCtIi/YM7sz501nGK9jfCOfSn5uGcPccRiGXqQsNdL8CphFvZdvZ+t+x3wiPxf7p 9tSdt2QnVruhXY9X7CpSPCvboTQWbLC6yblGnLSVCt7LlHu2GtY/1kxtolcV30OM7AZU r4J+tIbAUGLWRXb+wwDVcYBWEykK1ZqoT8nTsSfFl5OaRMlWu5M6QCe6pbL9clUqfYWd 6WJXpBhQtXFuvUoX8/PDvvWtWT5eyTCqvrcOHrfr+NQsEKs+1MMv9U2AhXweMtENDHRg wq1q/7O0tyCpEWk/BFl9o1zk4s5idfVxzaThEZV+rSJSZwSOi9dW6b3FsKnCrzOmdw/8 MTiw== 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=seHjBqaBud1mYkVOqcRVoUipgYEoJz3N4GGlHqlC5Ho=; b=RrPg6WsXUFhqjWi4hmv4OtfN4KNDILweSkuHA+wVylOojB5+b4U+S4Em0+EyJurifx fXb/DN0h0Xzy7LZoa8oTa3CGb6NEfMj+WKWcor+BszNGJGII929rHKl2SgiSzkuhzxsU 3Krv38bwJYa0sFqMNfd/2LCy49QGddo4zEQx8aXT3JPGqiMAYbn3g1E21iSoGlYQZ/vP 3DNzIJDtN7ZIvHcgx+kl4Qzfzg/b+y4YtBFZ/8NJgMgMyCNLquit3D0qw0O1HURIgCRH KE/e6nPOcUGc9taPsHh/KJfpULoV5nxRIxXNp6AY+ahHQrQehJUJUGlIRLOEBZEX8uDQ VBfQ== X-Gm-Message-State: APjAAAXx/iLKLlA/6moTtW2DNdYQ2cZl5aJQZxpXssXG2qunizvWHFs2 WM5ZutQ44Lw13dYNPY77XvU= X-Google-Smtp-Source: APXvYqzTyaALieo4zGPvtCFTNsVd2VNQz1hrvpZxEH9Wh+I2YsiK3p8l0Vnt/ZhqPkUwlGD+xSEe2g== X-Received: by 2002:a63:ef4c:: with SMTP id c12mr29053510pgk.43.1554913699097; Wed, 10 Apr 2019 09:28:19 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id j12sm43483028pgg.79.2019.04.10.09.28.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:18 -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: wm831x_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Wed, 10 Apr 2019 09:27:49 -0700 Message-Id: <1554913683-25454-9-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/wm831x_wdt.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/watchdog/wm831x_wdt.c b/drivers/watchdog/wm831x_wdt.c index 116c2f47b463..9b6565a3fab4 100644 --- a/drivers/watchdog/wm831x_wdt.c +++ b/drivers/watchdog/wm831x_wdt.c @@ -180,8 +180,9 @@ static const struct watchdog_ops wm831x_wdt_ops = { static int wm831x_wdt_probe(struct platform_device *pdev) { - struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); - struct wm831x_pdata *chip_pdata = dev_get_platdata(pdev->dev.parent); + struct device *dev = &pdev->dev; + struct wm831x *wm831x = dev_get_drvdata(dev->parent); + struct wm831x_pdata *chip_pdata = dev_get_platdata(dev->parent); struct wm831x_watchdog_pdata *pdata; struct wm831x_wdt_drvdata *driver_data; struct watchdog_device *wm831x_wdt; @@ -198,8 +199,7 @@ static int wm831x_wdt_probe(struct platform_device *pdev) if (reg & WM831X_WDOG_DEBUG) dev_warn(wm831x->dev, "Watchdog is paused\n"); - 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; @@ -210,7 +210,7 @@ static int wm831x_wdt_probe(struct platform_device *pdev) wm831x_wdt->info = &wm831x_wdt_info; wm831x_wdt->ops = &wm831x_wdt_ops; - wm831x_wdt->parent = &pdev->dev; + wm831x_wdt->parent = dev; watchdog_set_nowayout(wm831x_wdt, nowayout); watchdog_set_drvdata(wm831x_wdt, driver_data); @@ -240,10 +240,9 @@ static int wm831x_wdt_probe(struct platform_device *pdev) reg |= pdata->software << WM831X_WDOG_RST_SRC_SHIFT; if (pdata->update_gpio) { - ret = devm_gpio_request_one(&pdev->dev, - pdata->update_gpio, - GPIOF_OUT_INIT_LOW, - "Watchdog update"); + ret = devm_gpio_request_one(dev, pdata->update_gpio, + GPIOF_OUT_INIT_LOW, + "Watchdog update"); if (ret < 0) { dev_err(wm831x->dev, "Failed to request update GPIO: %d\n", @@ -268,7 +267,7 @@ static int wm831x_wdt_probe(struct platform_device *pdev) } } - ret = devm_watchdog_register_device(&pdev->dev, &driver_data->wdt); + ret = devm_watchdog_register_device(dev, &driver_data->wdt); if (ret != 0) { dev_err(wm831x->dev, "watchdog_register_device() failed: %d\n", ret); From patchwork Wed Apr 10 16:27:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894383 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 24B7017EF for ; Wed, 10 Apr 2019 16:29:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10056286B4 for ; Wed, 10 Apr 2019 16:29:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03F3A287FD; Wed, 10 Apr 2019 16:29:47 +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 9EE57286BD for ; Wed, 10 Apr 2019 16:29:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732582AbfDJQ3q (ORCPT ); Wed, 10 Apr 2019 12:29:46 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37280 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387855AbfDJQ2V (ORCPT ); Wed, 10 Apr 2019 12:28:21 -0400 Received: by mail-pl1-f195.google.com with SMTP id w23so1736640ply.4; Wed, 10 Apr 2019 09:28:20 -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=+OYZTkxC1btQoTo+CXY+tiiGNBQ6X0e0abBF8L5gRR4=; b=u3I1vWgIYAG1nPvzX26Da5tisPuNKB9cxwqh1pMkGSbCPoBJBp6tZQTS3go9ZrYbyt y2jNQKjFXDsVC9OIiEnrK932Nh2sfkXubCpxzcf/joQrXfSfIzqeYW3z3m2GTFtCwSAI zLFW3D5cNam26XALxRMRsEEbR1BQkSQGHHlj7lA7qCu09iKlMB9Z4HxTLVb3SfHR11ME FMarREPQH8X0YKuuSgnbi3Ecwh0qj0lOc5giip+kBpRZfsij8xCkhXDpNUAbncDApulQ C3c8bRCMN5mxrDBXp2lbIQptjrnGMRx8uAAQq/qmIM8VsNnSJKcfCa62z8VX0nOwDTSS jfkw== 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=+OYZTkxC1btQoTo+CXY+tiiGNBQ6X0e0abBF8L5gRR4=; b=ITTeloJN7g/G5ihv86KB+S255h6+8+mn8rG4Ysr4Nvg7h+suWfc+kynKYp0GN/5XEl /r/vMIuSL5wBD3+io2S1eK1j+f7XZ6lkRDmD9YgXzUzX4HjXSPm0spZMwnEgORHlc3iE c4HOCSug9tx5n0aBpNJXljVtFFhcxNYVBKfQd1i8noGXDubjN+ETSPnWmJiFsZkjLd2B 6dK8fYpwP8YN5pkqcoDebaAL36nvefWD/bMtMU3oszcXvEnx6YIfWr9WG0vMBtspPjC7 7h3LVtvL+jXo/aJ5lhVaU1TsBYgeKpjztnQhnMRpZxACGpHDX3vedtntVj+zxwzm50PP 0Rgw== X-Gm-Message-State: APjAAAWemLFcyD//LuHkfXegcuD4Q0Y9y8wQcbomVVk940krJd668hnS MASSANlteUuJehAH/y4p+D7NHsGt X-Google-Smtp-Source: APXvYqw/YrilPAqum7c4xuLJSrII8eI42TVZgzHkeyWwyBnBEQOlx/p3EQ+pLq1TxrBO5xxWc6WyVQ== X-Received: by 2002:a17:902:362:: with SMTP id 89mr45258536pld.172.1554913700597; Wed, 10 Apr 2019 09:28:20 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id m2sm59541605pgr.74.2019.04.10.09.28.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:19 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 09/22] watchdog: xen_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Wed, 10 Apr 2019 09:27:50 -0700 Message-Id: <1554913683-25454-10-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/xen_wdt.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/watchdog/xen_wdt.c b/drivers/watchdog/xen_wdt.c index f1c016d015b3..6c1ca1f31cbc 100644 --- a/drivers/watchdog/xen_wdt.c +++ b/drivers/watchdog/xen_wdt.c @@ -122,35 +122,35 @@ static struct watchdog_device xen_wdt_dev = { static int xen_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct sched_watchdog wd = { .id = ~0 }; int ret = HYPERVISOR_sched_op(SCHEDOP_watchdog, &wd); if (ret == -ENOSYS) { - dev_err(&pdev->dev, "watchdog not supported by hypervisor\n"); + dev_err(dev, "watchdog not supported by hypervisor\n"); return -ENODEV; } if (ret != -EINVAL) { - dev_err(&pdev->dev, "unexpected hypervisor error (%d)\n", ret); + dev_err(dev, "unexpected hypervisor error (%d)\n", ret); return -ENODEV; } if (watchdog_init_timeout(&xen_wdt_dev, timeout, NULL)) - dev_info(&pdev->dev, "timeout value invalid, using %d\n", - xen_wdt_dev.timeout); + dev_info(dev, "timeout value invalid, using %d\n", + xen_wdt_dev.timeout); watchdog_set_nowayout(&xen_wdt_dev, nowayout); watchdog_stop_on_reboot(&xen_wdt_dev); watchdog_stop_on_unregister(&xen_wdt_dev); - ret = devm_watchdog_register_device(&pdev->dev, &xen_wdt_dev); + ret = devm_watchdog_register_device(dev, &xen_wdt_dev); if (ret) { - dev_err(&pdev->dev, "cannot register watchdog device (%d)\n", - ret); + dev_err(dev, "cannot register watchdog device (%d)\n", ret); return ret; } - dev_info(&pdev->dev, "initialized (timeout=%ds, nowayout=%d)\n", - xen_wdt_dev.timeout, nowayout); + dev_info(dev, "initialized (timeout=%ds, nowayout=%d)\n", + xen_wdt_dev.timeout, nowayout); return 0; } From patchwork Wed Apr 10 16:27:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894377 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 4A84D17E0 for ; Wed, 10 Apr 2019 16:29:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3696C28600 for ; Wed, 10 Apr 2019 16:29:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B1B6287DA; Wed, 10 Apr 2019 16:29:41 +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 C428D28600 for ; Wed, 10 Apr 2019 16:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387865AbfDJQ2Y (ORCPT ); Wed, 10 Apr 2019 12:28:24 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:44681 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387860AbfDJQ2W (ORCPT ); Wed, 10 Apr 2019 12:28:22 -0400 Received: by mail-pg1-f194.google.com with SMTP id i2so1845033pgj.11; Wed, 10 Apr 2019 09:28:22 -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=jsfm7LCM8d51wy7QbSzyHhCcp61nfHGejXB4g2c1IIg=; b=PAV+KB4V+Qdx5iBwU9mDMigyahZjt2ONZB466UKGbiP1Tps2IgtM6SyRuUfi/LRqAL Kkwtw9mOBIOKkG+n644tALN6WTyGbseCF+L7FYOgVCvKEtCL9LyKAEEKPGw7tGJCoKhu ak5xdwvYMggVsEq4JzD0OoOKm0QNVZ8MIKjwPuO48quSZZht2S/YLa4ZUL91rIn8Sj+W YXoEssAQWpOn1EEDGnGDfeA3NGeTh3GOjfl+nUpMoo7jxEesdmY+AKfXFkF27i9XHcC3 whiUl2dvexLxyVaECrvRBIOB89Ymwrmfb/PfkItHEObZI7uXBCUJpysRElf0IYi8YKhz aCVA== 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=jsfm7LCM8d51wy7QbSzyHhCcp61nfHGejXB4g2c1IIg=; b=gK9o+VEAToxWNHKhx8JswjyItx5MJcLc6RDXBN2j6+WNwrUQJlTXK4uBDSRPXAw6W2 Wq/+lXUCa+WUbPagdivPC89xBLoYIaAWZQjAtSYn56hg+8Gv38i22Rd+HedwK5wo64Ry W74wjyDFnwRNcoOj8lGZlBazAqkS+RBtMT7e77vjRZiRvhC5NtuX8kwrQXqzFh2y5T0o j+jGBQj+qiFxagrq7CBg6NYnHP5acOpnoYd6banfyEcS1eUIWH/i/iEpt3vr3uY9hNUB OouUcNittmsdFX4f7o2mnP2f2trzGOr33QddYcOB81/FVIDxU/nRaIGAgh9pkj7cXJHk +dcA== X-Gm-Message-State: APjAAAUE0w/An/nRYj5J5OCn5RcNHHMSUMzFcO1GBdDimHH0xcaIW6F4 xs76M829/tY/xd3ciSAobHM= X-Google-Smtp-Source: APXvYqwUhKNJ3dcspIyvPvRpxMPpqAqydynO+j7OTMauoosZ3rLfU6wCV8kAATbFLPAd7bcVJCaBlA== X-Received: by 2002:a65:5304:: with SMTP id m4mr41319400pgq.281.1554913702000; Wed, 10 Apr 2019 09:28:22 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d38sm42024691pgd.40.2019.04.10.09.28.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:21 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Subject: [PATCH 10/22] watchdog: imx_sc_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Wed, 10 Apr 2019 09:27:51 -0700 Message-Id: <1554913683-25454-11-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Shawn Guo Cc: Sascha Hauer Cc: Pengutronix Kernel Team Cc: Fabio Estevam Cc: NXP Linux Team Signed-off-by: Guenter Roeck Acked-by: Shawn Guo --- drivers/watchdog/imx_sc_wdt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/watchdog/imx_sc_wdt.c b/drivers/watchdog/imx_sc_wdt.c index 86c2722f2a09..d154f66e659a 100644 --- a/drivers/watchdog/imx_sc_wdt.c +++ b/drivers/watchdog/imx_sc_wdt.c @@ -101,10 +101,11 @@ static const struct watchdog_info imx_sc_wdt_info = { static int imx_sc_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct watchdog_device *imx_sc_wdd; int ret; - imx_sc_wdd = devm_kzalloc(&pdev->dev, sizeof(*imx_sc_wdd), GFP_KERNEL); + imx_sc_wdd = devm_kzalloc(dev, sizeof(*imx_sc_wdd), GFP_KERNEL); if (!imx_sc_wdd) return -ENOMEM; @@ -114,19 +115,19 @@ static int imx_sc_wdt_probe(struct platform_device *pdev) imx_sc_wdd->ops = &imx_sc_wdt_ops; imx_sc_wdd->min_timeout = 1; imx_sc_wdd->max_timeout = MAX_TIMEOUT; - imx_sc_wdd->parent = &pdev->dev; + imx_sc_wdd->parent = dev; imx_sc_wdd->timeout = DEFAULT_TIMEOUT; - ret = watchdog_init_timeout(imx_sc_wdd, 0, &pdev->dev); + ret = watchdog_init_timeout(imx_sc_wdd, 0, dev); if (ret) - dev_warn(&pdev->dev, "Failed to set timeout value, using default\n"); + dev_warn(dev, "Failed to set timeout value, using default\n"); watchdog_stop_on_reboot(imx_sc_wdd); watchdog_stop_on_unregister(imx_sc_wdd); - ret = devm_watchdog_register_device(&pdev->dev, imx_sc_wdd); + ret = devm_watchdog_register_device(dev, imx_sc_wdd); if (ret) { - dev_err(&pdev->dev, "Failed to register watchdog device\n"); + dev_err(dev, "Failed to register watchdog device\n"); return ret; } From patchwork Wed Apr 10 16:27:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E9B317E0 for ; Wed, 10 Apr 2019 16:29:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AAEB2885F for ; Wed, 10 Apr 2019 16:29:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F39C288CF; Wed, 10 Apr 2019 16:29:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED6CA286BD for ; Wed, 10 Apr 2019 16:29:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731763AbfDJQ3k (ORCPT ); Wed, 10 Apr 2019 12:29:40 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:42694 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387862AbfDJQ2Y (ORCPT ); Wed, 10 Apr 2019 12:28:24 -0400 Received: by mail-pl1-f194.google.com with SMTP id cv12so1733478plb.9; Wed, 10 Apr 2019 09:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=A8S7XSTI64ZGz7QExfklYyYSF03nx6KnqMOGBDym5s0=; b=JMQnMd0jgU/sfz3TH4kN8lc9efu1s4ojoJzK+hZapgzO2uNoLa5R5REyfo4/pbWIqo 3Bg98SiLvffA66jqYCDMEU5aLqPfWWYqgEQ2uiIzXVk0LDYLG08dm0L9arn3fGFtrnlb jIxov/WJdunwemW/Vh17ayT8aXISK7Ama6IzcmKK0Jz8J7Y4009uFj7/5xm/5C+EBAr3 5xf2o9fhpMbVlEbIwZxP0WM+fh0kIlC7m0EClSDHEqSOk6RJSqOmWZ0/syjq2gNPrmsD uay8TT93oUnfBH6xccDFckp/yDHZAS8qT1DMEfvwRBu6YSvlRC9HZ7gxxI+BVKmyb6IS GUYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=A8S7XSTI64ZGz7QExfklYyYSF03nx6KnqMOGBDym5s0=; b=CJzMOYwRK6pnr7+5UDvUbMEbROY+1rq/5oBNvVaw71ewamMcoX6okaqtwmkjiolQ2N x/QG17FZOPC156PS6gPnIbQEU5XbqoIKOul5czgFXOMAtIrGmTVNuZ7k/Iq3Jmdx7qXp lgCwHT7Xm31CiKSyGjbLKQK6T7yamH3Uj/dBcRlUsylz1NYzwjw4x/vi2jeUyfO2f0Zx feyIEpEsBWZPch+qfxPDqrQZSW7mEP9bOEnWrnbq7yldb8lXi8OKWu6LYz1SlReKzxWI K2DKTTc/g6qdhPuqWMg2tj+00FClnqzA7RD4DBWvTRlsVt3Wlvvh6YhfQrQshE3On1x3 Ef9g== X-Gm-Message-State: APjAAAWUKRAabe9crOMZDETJo9p6FPyybNRDz96gfIE+ztRG8T2Fgvha sDTWrBHQXYi29ePGvTZAsoY= X-Google-Smtp-Source: APXvYqxepkhR3FUPAhTEmfCpxVe8OwgJcM7oSnH0Oe6TpcQFP43WDl7lBVa05nAGT0iGXFtvYsEB3g== X-Received: by 2002:a17:902:da4:: with SMTP id 33mr13142734plv.20.1554913703373; Wed, 10 Apr 2019 09:28:23 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id f71sm51876276pfc.109.2019.04.10.09.28.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:22 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 11/22] watchdog: sbsa_gwdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:52 -0700 Message-Id: <1554913683-25454-12-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop empty remove function - Use local variable 'struct device *dev' consistently - Use devm_watchdog_register_driver() to register watchdog device - Replace shutdown function with call to watchdog_stop_on_reboot() Signed-off-by: Guenter Roeck --- drivers/watchdog/sbsa_gwdt.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c index 68aff828bf7e..e17af8939c93 100644 --- a/drivers/watchdog/sbsa_gwdt.c +++ b/drivers/watchdog/sbsa_gwdt.c @@ -310,7 +310,8 @@ static int sbsa_gwdt_probe(struct platform_device *pdev) */ sbsa_gwdt_set_timeout(wdd, wdd->timeout); - ret = watchdog_register_device(wdd); + watchdog_stop_on_reboot(wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) return ret; @@ -321,22 +322,6 @@ static int sbsa_gwdt_probe(struct platform_device *pdev) return 0; } -static void sbsa_gwdt_shutdown(struct platform_device *pdev) -{ - struct sbsa_gwdt *gwdt = platform_get_drvdata(pdev); - - sbsa_gwdt_stop(&gwdt->wdd); -} - -static int sbsa_gwdt_remove(struct platform_device *pdev) -{ - struct sbsa_gwdt *gwdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(&gwdt->wdd); - - return 0; -} - /* Disable watchdog if it is active during suspend */ static int __maybe_unused sbsa_gwdt_suspend(struct device *dev) { @@ -382,8 +367,6 @@ static struct platform_driver sbsa_gwdt_driver = { .of_match_table = sbsa_gwdt_of_match, }, .probe = sbsa_gwdt_probe, - .remove = sbsa_gwdt_remove, - .shutdown = sbsa_gwdt_shutdown, .id_table = sbsa_gwdt_pdev_match, }; From patchwork Wed Apr 10 16:27:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894375 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 12807139A for ; Wed, 10 Apr 2019 16:29:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1DAB288CF for ; Wed, 10 Apr 2019 16:29:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6651287C5; Wed, 10 Apr 2019 16:29: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 65CF2287B8 for ; Wed, 10 Apr 2019 16:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731936AbfDJQ3b (ORCPT ); Wed, 10 Apr 2019 12:29:31 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36479 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387877AbfDJQ2Z (ORCPT ); Wed, 10 Apr 2019 12:28:25 -0400 Received: by mail-pg1-f193.google.com with SMTP id 85so1871047pgc.3; Wed, 10 Apr 2019 09:28:25 -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=c2FEfcVttbNCfJqC2hCYAaLdDZL89jf2XIDcZsihWPM=; b=g9f3lkU59N+uE6DpaaWLGIA9SIwrj/sxem3hLSydb3IiDmVVSRGek+LpNi6HaTHHfa YNXJ3wf6mSvZ3dHxOq+0l+3bwcfIq22573tm/HCmJdaMut3qd8+36xPFxfsmh5HM+Rbq Zes9fQiADEN7VWibEgfNUOhgOndNtJrHVlEcY8HD+dO/QUWt4FdlRy2Jj1EBwwZJUMtE IONQ6aYXp1BHl+w1sAfkTnbMcNwEH9EoiLgTvqBN3xWJAOgKZc1OFupvskd6/WmFfjLu MYiiS/YFwdddgGU6o/s0pCaDRT6Y3h/bFtx9TDw6JcJ5ljZiSTmoRdAjaDixNnvzDUBA zu+Q== 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=c2FEfcVttbNCfJqC2hCYAaLdDZL89jf2XIDcZsihWPM=; b=CMt10TDLNlPy4WgXJSfha4hpaSNdtlbG5y1o0B/MySQdtgP689g2QL3w31jdDQye2H Hf4MQLiRJ40959ozCVXg0kqpNbqA3LN9wqsplEG7iwVPVbEvqNF9gv25Rf40LLiBmBzH s7ZFOyJg/bCH9MFoR3Qz3sEilz6FFm9ty3yUFWNWULut7Gcd+atSNDWLlk2aECjKsYbt 64Idha75rTaIOtW/U+18LGoZjbS+TVjMd2C2Dk2kOjgTcKOoxhFdGtXt03brSBlD//y3 3FxYk6gE5ueWa2C1YcvIj/TzdOCZ+dFxiIH2RyNZti2KM24T6UmpkQDeLPnhfHX6bf6g KE7w== X-Gm-Message-State: APjAAAXiPMQwsFGpmunEfi7OFbicf1O1diofVoGwyVBx/s6dixWEuROT mCIobN7ZauxyScxHM5asNxI= X-Google-Smtp-Source: APXvYqwH07qiZMrOhchAQWnu9rp9fNTxesBTNLq5dtBo21Ev7zC+mNkO08CKanU5OvYbisK5ESC8Rw== X-Received: by 2002:a62:1d0d:: with SMTP id d13mr44593907pfd.96.1554913704771; Wed, 10 Apr 2019 09:28:24 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id i1sm68511373pgc.63.2019.04.10.09.28.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:24 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Jun Nie , Shawn Guo Subject: [PATCH 12/22] watchdog: zx2967_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:53 -0700 Message-Id: <1554913683-25454-13-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop empty remove function - Use 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 Cc: Jun Nie Cc: Shawn Guo Signed-off-by: Guenter Roeck Acked-by: Shawn Guo --- drivers/watchdog/zx2967_wdt.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/watchdog/zx2967_wdt.c b/drivers/watchdog/zx2967_wdt.c index 9ccc83f526f3..c8549bf07cc9 100644 --- a/drivers/watchdog/zx2967_wdt.c +++ b/drivers/watchdog/zx2967_wdt.c @@ -188,6 +188,11 @@ static void zx2967_wdt_reset_sysctrl(struct device *dev) of_node_put(out_args.np); } +static void zx2967_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int zx2967_wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -206,7 +211,7 @@ static int zx2967_wdt_probe(struct platform_device *pdev) wdt->wdt_device.timeout = ZX2967_WDT_DEFAULT_TIMEOUT; wdt->wdt_device.max_timeout = ZX2967_WDT_MAX_TIMEOUT; wdt->wdt_device.min_timeout = ZX2967_WDT_MIN_TIMEOUT; - wdt->wdt_device.parent = &pdev->dev; + wdt->wdt_device.parent = dev; wdt->reg_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(wdt->reg_base)) @@ -225,13 +230,16 @@ static int zx2967_wdt_probe(struct platform_device *pdev) dev_err(dev, "failed to enable clock\n"); return ret; } + ret = devm_add_action_or_reset(dev, zx2967_clk_disable_unprepare, + wdt->clock); + if (ret) + return ret; clk_set_rate(wdt->clock, ZX2967_WDT_CLK_FREQ); rstc = devm_reset_control_get_exclusive(dev, NULL); if (IS_ERR(rstc)) { dev_err(dev, "failed to get rstc"); - ret = PTR_ERR(rstc); - goto err; + return PTR_ERR(rstc); } reset_control_assert(rstc); @@ -242,28 +250,14 @@ static int zx2967_wdt_probe(struct platform_device *pdev) ZX2967_WDT_DEFAULT_TIMEOUT, dev); watchdog_set_nowayout(&wdt->wdt_device, WATCHDOG_NOWAYOUT); - ret = watchdog_register_device(&wdt->wdt_device); + ret = devm_watchdog_register_device(dev, &wdt->wdt_device); if (ret) - goto err; + return ret; dev_info(dev, "watchdog enabled (timeout=%d sec, nowayout=%d)", wdt->wdt_device.timeout, WATCHDOG_NOWAYOUT); return 0; - -err: - clk_disable_unprepare(wdt->clock); - return ret; -} - -static int zx2967_wdt_remove(struct platform_device *pdev) -{ - struct zx2967_wdt *wdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(&wdt->wdt_device); - clk_disable_unprepare(wdt->clock); - - return 0; } static const struct of_device_id zx2967_wdt_match[] = { @@ -274,7 +268,6 @@ MODULE_DEVICE_TABLE(of, zx2967_wdt_match); static struct platform_driver zx2967_wdt_driver = { .probe = zx2967_wdt_probe, - .remove = zx2967_wdt_remove, .driver = { .name = "zx2967-wdt", .of_match_table = of_match_ptr(zx2967_wdt_match), From patchwork Wed Apr 10 16:27:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894355 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 BB360139A for ; Wed, 10 Apr 2019 16:28:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A697628B61 for ; Wed, 10 Apr 2019 16:28:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AA5428BA8; Wed, 10 Apr 2019 16:28: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 104EA28B20 for ; Wed, 10 Apr 2019 16:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387886AbfDJQ21 (ORCPT ); Wed, 10 Apr 2019 12:28:27 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44770 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387884AbfDJQ20 (ORCPT ); Wed, 10 Apr 2019 12:28:26 -0400 Received: by mail-pf1-f194.google.com with SMTP id y13so1775129pfm.11; Wed, 10 Apr 2019 09:28:26 -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=orMF7rYuBW2QAgocXGhNUAGTXbgVNrgKUN3myFTKYbI=; b=hXw7C9KCi6C5kI5hpR/VW7d1TTVAbP32+DfiunuKtqgqY+QY3fb1K7cuKaUjfkXZ+G ZjkBqBJyEy3tXdU112kk2wChv3bk2jnctjbYuu+elfI4tEnKrOcZGK/5cen+GZqkUDLO OsiaUt2LpS2DTKDUe0V+kdugcpfFO3E5xRtC9R37LSkgygtJWHEAUgUNL6wx8ivAvwHJ PF3z7vh7B6zuqV3e+439tbKsTYuBss6mb2m8JlEeVMpO9sZfF955HKjHIrJ37/YD6GZO mBsDjqIHxom9Xa8DPlmISiVtwpzIG2wcafrcOEew7oKkLmwHZhmEo2fOh17+GsFwcUdp ASEQ== 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=orMF7rYuBW2QAgocXGhNUAGTXbgVNrgKUN3myFTKYbI=; b=XJs3spII8w7F6ZW/tnEHA6OWi8SrjkxexfBJc5NtQLa91zkw5x7nSoejgRv0S2OSwG VO1B/nV7GwjuQPK/SUbTqjrEgFRlfMICYW9eKf5bVenNoDAkZU8P17FUd9aKCOPiFhU6 vd0JGJZ3W5zsWz91RKHNS0PYCgxBgIJXkMsYOCnFbMdLJ96YFdw1EEi332GddcMIel9B wyZO1BRYfeleJVPEGGdKs+ABUfVFUm199fy9l/I5neDNSlcNq3KJymZWRKAu1pOX/zm0 6pl6s+rYQoEfAvw4yDOFnKc1FB8yikWeCXjm6j2uVH4wvKPAIuGdmJhsX3LTDFBh373r fGqA== X-Gm-Message-State: APjAAAVX8NeXeYmstHkPjy2ruycbnpKzc7AKlI3DXQMNw9RTCo1rPexO 19kOoZKehlSOAkQgZ7vji38= X-Google-Smtp-Source: APXvYqzNmSxAlAVUAJ99Y9aLmZPx74E6fY+UOzkOVIRVwUEjP4DK9aoIKg8WV+kO6T7XHqXkQq6Pow== X-Received: by 2002:aa7:91c8:: with SMTP id z8mr44553612pfa.110.1554913706126; Wed, 10 Apr 2019 09:28:26 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id q87sm55726631pfa.133.2019.04.10.09.28.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:25 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Maxime Coquelin , Alexandre Torgue Subject: [PATCH 13/22] watchdog: stm32_iwdg: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:54 -0700 Message-Id: <1554913683-25454-14-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop empty remove function - Use 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 Cc: Maxime Coquelin Cc: Alexandre Torgue Signed-off-by: Guenter Roeck --- drivers/watchdog/stm32_iwdg.c | 65 +++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c index 309563e002b8..68756a40eb36 100644 --- a/drivers/watchdog/stm32_iwdg.c +++ b/drivers/watchdog/stm32_iwdg.c @@ -138,38 +138,52 @@ static int stm32_iwdg_set_timeout(struct watchdog_device *wdd, return 0; } +static void stm32_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int stm32_iwdg_clk_init(struct platform_device *pdev, struct stm32_iwdg *wdt) { + struct device *dev = &pdev->dev; u32 ret; - wdt->clk_lsi = devm_clk_get(&pdev->dev, "lsi"); + wdt->clk_lsi = devm_clk_get(dev, "lsi"); if (IS_ERR(wdt->clk_lsi)) { - dev_err(&pdev->dev, "Unable to get lsi clock\n"); + dev_err(dev, "Unable to get lsi clock\n"); return PTR_ERR(wdt->clk_lsi); } /* optional peripheral clock */ if (wdt->has_pclk) { - wdt->clk_pclk = devm_clk_get(&pdev->dev, "pclk"); + wdt->clk_pclk = devm_clk_get(dev, "pclk"); if (IS_ERR(wdt->clk_pclk)) { - dev_err(&pdev->dev, "Unable to get pclk clock\n"); + dev_err(dev, "Unable to get pclk clock\n"); return PTR_ERR(wdt->clk_pclk); } ret = clk_prepare_enable(wdt->clk_pclk); if (ret) { - dev_err(&pdev->dev, "Unable to prepare pclk clock\n"); + dev_err(dev, "Unable to prepare pclk clock\n"); return ret; } + ret = devm_add_action_or_reset(dev, + stm32_clk_disable_unprepare, + wdt->clk_pclk); + if (ret) + return ret; } ret = clk_prepare_enable(wdt->clk_lsi); if (ret) { - dev_err(&pdev->dev, "Unable to prepare lsi clock\n"); - clk_disable_unprepare(wdt->clk_pclk); + dev_err(dev, "Unable to prepare lsi clock\n"); return ret; } + ret = devm_add_action_or_reset(dev, stm32_clk_disable_unprepare, + wdt->clk_lsi); + if (ret) + return ret; wdt->rate = clk_get_rate(wdt->clk_lsi); @@ -199,16 +213,17 @@ MODULE_DEVICE_TABLE(of, stm32_iwdg_of_match); static int stm32_iwdg_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct watchdog_device *wdd; const struct of_device_id *match; struct stm32_iwdg *wdt; int ret; - match = of_match_device(stm32_iwdg_of_match, &pdev->dev); + match = of_match_device(stm32_iwdg_of_match, dev); if (!match) return -ENODEV; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -217,7 +232,7 @@ static int stm32_iwdg_probe(struct platform_device *pdev) /* This is the timer base. */ wdt->regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(wdt->regs)) { - dev_err(&pdev->dev, "Could not get resource\n"); + dev_err(dev, "Could not get resource\n"); return PTR_ERR(wdt->regs); } @@ -231,46 +246,28 @@ static int stm32_iwdg_probe(struct platform_device *pdev) wdd->ops = &stm32_iwdg_ops; wdd->min_timeout = ((RLR_MIN + 1) * 256) / wdt->rate; wdd->max_hw_heartbeat_ms = ((RLR_MAX + 1) * 256 * 1000) / wdt->rate; - wdd->parent = &pdev->dev; + wdd->parent = dev; watchdog_set_drvdata(wdd, wdt); watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT); - ret = watchdog_init_timeout(wdd, 0, &pdev->dev); + ret = watchdog_init_timeout(wdd, 0, dev); if (ret) - dev_warn(&pdev->dev, - "unable to set timeout value, using default\n"); + dev_warn(dev, "unable to set timeout value, using default\n"); - ret = watchdog_register_device(wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) { - dev_err(&pdev->dev, "failed to register watchdog device\n"); - goto err; + dev_err(dev, "failed to register watchdog device\n"); + return ret; } platform_set_drvdata(pdev, wdt); return 0; -err: - clk_disable_unprepare(wdt->clk_lsi); - clk_disable_unprepare(wdt->clk_pclk); - - return ret; -} - -static int stm32_iwdg_remove(struct platform_device *pdev) -{ - struct stm32_iwdg *wdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(&wdt->wdd); - clk_disable_unprepare(wdt->clk_lsi); - clk_disable_unprepare(wdt->clk_pclk); - - return 0; } static struct platform_driver stm32_iwdg_driver = { .probe = stm32_iwdg_probe, - .remove = stm32_iwdg_remove, .driver = { .name = "iwdg", .of_match_table = of_match_ptr(stm32_iwdg_of_match), From patchwork Wed Apr 10 16:27:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894373 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 98B42139A for ; Wed, 10 Apr 2019 16:29:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82A2428BB6 for ; Wed, 10 Apr 2019 16:29:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76D4C28B09; Wed, 10 Apr 2019 16:29:27 +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 0BCDF28BBC for ; Wed, 10 Apr 2019 16:29:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387964AbfDJQ3V (ORCPT ); Wed, 10 Apr 2019 12:29:21 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43129 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387888AbfDJQ22 (ORCPT ); Wed, 10 Apr 2019 12:28:28 -0400 Received: by mail-pg1-f194.google.com with SMTP id z9so1848328pgu.10; Wed, 10 Apr 2019 09:28:27 -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=ni05DFO6BTYbaFzG8C2LxYO4iAiA1+2nom8reemvhW0=; b=BHV49RXlJ+LnAtzJUDLJPBhI6oftKO6ggo/tYg0beVFFgGFAW16TVzGY40c/oJEEgk vNeuc8lzC9LA6gxb/yJVVXncXZIxI7+g8OfLcSTJX1UGp8Gm8ezKtli/pWus7gxFUPOn zbVrFOxv1EOooPOAP9RvsHipose3la9DuBlPhJ9Qxbr6wAiTufnE8mi8c2Eu8bH7JEKg xveVNLFEoxWiWTSUncEbE9fs1UGE1htExMsX9EBKONdSnzezcgLVcYDlzxFb1/IkDOCP LgllhIPyUALWJMClljI4d68Xhq7A8rl5EX0YcBCe+DObGvQx91zzXvJK6O4vlyeZtu8+ 5yxg== 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=ni05DFO6BTYbaFzG8C2LxYO4iAiA1+2nom8reemvhW0=; b=K7bPFDxEU0lWI9pWT28aqe9A1IaBsQk8NgikJnPq5xDhYCaFwcarZKw1EZkorWqnK3 hk9MDK9nffxe13iYduw+r6ZEvxUkFG8RcL5Fh7dYvIkfX6u/1SoRu5LwMdQO2aGc5yGC UvESxwWK+sSorQELtsV3O/bMcw/tj6Tt2S16y5ofPueNls7DBR3c5fevNrF+nN2sSQfY cuH6bAW7K0rTcfUquKM7psQN4h7xdlrTfpyl30ol7sgfFuI7aB1hB23Nm5yFlQKgH728 Yls9f+0Nwy8wTfWTiWeuOJIxXSrZMUiT97+NJKUCku0Ja08DOZDnGkZYzLws65K0mJPk AFzw== X-Gm-Message-State: APjAAAVxGGtXj6DP2z43zeDnyOsHvrkgadXSsEjT8/c8kS122SxI3LWp mn0cDL/sWtYwyDFGn+mE+Sg= X-Google-Smtp-Source: APXvYqzlUuzCp8ECHII9y6rvtUAlfUbEEsdz7C4EwgFLGvJZb0uDu69XYrk8PoDaikhoTPD1w9Rq2A== X-Received: by 2002:aa7:943b:: with SMTP id y27mr20615184pfo.59.1554913707408; Wed, 10 Apr 2019 09:28:27 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id m23sm54815037pfa.117.2019.04.10.09.28.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:26 -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: ux500_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:55 -0700 Message-Id: <1554913683-25454-15-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop 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/ux500_wdt.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/watchdog/ux500_wdt.c b/drivers/watchdog/ux500_wdt.c index 37c084353cce..9fa7f95f7554 100644 --- a/drivers/watchdog/ux500_wdt.c +++ b/drivers/watchdog/ux500_wdt.c @@ -86,8 +86,9 @@ static struct watchdog_device ux500_wdt = { static int ux500_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; - struct ux500_wdt_data *pdata = dev_get_platdata(&pdev->dev); + struct ux500_wdt_data *pdata = dev_get_platdata(dev); if (pdata) { if (pdata->timeout > 0) @@ -96,7 +97,7 @@ static int ux500_wdt_probe(struct platform_device *pdev) ux500_wdt.max_timeout = WATCHDOG_MAX28; } - ux500_wdt.parent = &pdev->dev; + ux500_wdt.parent = dev; watchdog_set_nowayout(&ux500_wdt, nowayout); /* disable auto off on sleep */ @@ -105,18 +106,11 @@ static int ux500_wdt_probe(struct platform_device *pdev) /* set HW initial value */ prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); - ret = watchdog_register_device(&ux500_wdt); + ret = devm_watchdog_register_device(dev, &ux500_wdt); if (ret) return ret; - dev_info(&pdev->dev, "initialized\n"); - - return 0; -} - -static int ux500_wdt_remove(struct platform_device *dev) -{ - watchdog_unregister_device(&ux500_wdt); + dev_info(dev, "initialized\n"); return 0; } @@ -153,7 +147,6 @@ static int ux500_wdt_resume(struct platform_device *pdev) static struct platform_driver ux500_wdt_driver = { .probe = ux500_wdt_probe, - .remove = ux500_wdt_remove, .suspend = ux500_wdt_suspend, .resume = ux500_wdt_resume, .driver = { From patchwork Wed Apr 10 16:27:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894371 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 AACA2139A for ; Wed, 10 Apr 2019 16:29:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94A7228B09 for ; Wed, 10 Apr 2019 16:29:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8916528BB6; Wed, 10 Apr 2019 16:29: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 0908528B09 for ; Wed, 10 Apr 2019 16:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731790AbfDJQ3M (ORCPT ); Wed, 10 Apr 2019 12:29:12 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40159 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387860AbfDJQ23 (ORCPT ); Wed, 10 Apr 2019 12:28:29 -0400 Received: by mail-pg1-f193.google.com with SMTP id d31so1859178pgl.7; Wed, 10 Apr 2019 09:28:29 -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=Y0Tfyx52U1gnhb4CI3YOiBgsMKA1CP/i626KdchFSTE=; b=Q82NDTlG9wa7YzLyMSjoMyx+H3vIH5Gr6IOtw6nucPu9SuUIvoChdsKT1VyBKkznAH 5VLx6o+SbV6gPQf5Mg8OWJdJQA1SgfLjydJMgXamTK7bXhhwB6dJ0O4SlyS6hb/GBmTv lYuzmriuwamizvLnENTg781vYK0RaZShttYctKL7E29puRk+28eSCxx+dZ0XGrYmftVQ 0LPKSitONLSAIN5Zc8c4xUpgk4UYM5SjwsXby68g5YluvXtizQEfVp+dvMj4WiDfxEfS HOCm01Ou2LmldGwx0Ur9SlrY8k+JqMQE9L38WL6eHAnoz+PDnweGhCzfGpNwrbtbhq62 gGoQ== 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=Y0Tfyx52U1gnhb4CI3YOiBgsMKA1CP/i626KdchFSTE=; b=hLqCKkM2WO1hPPXSoE68C6gUHAfq/oXkKIuJ7V3rtCgtngvwg/5VKhRLsmVmNAmtnG x9ia6kTKDt94f2GnjAlD0TBg2unVm3Inxd4RRqgxmZ5rcshEUKEpC385wXTMRpqfR9TZ vGsOB77/x8S/Hkc176+re7NrHCmh7J2GL8ekzwycsTRlyaWRB79WHv9dQv9GhUh0JzYf sTOuM71VsHYl4pFBC40su7gbjJ36XvYXmud26YKXuD1LEkAoGdMsSrIrEvuQXB0WW04k fWPPO0h5KEbQg5ycl4kDXw+c0bCRYGQ7zQy1IIihQ0JCieFcFAGAb9x6ybfuJmVlpwbX /8Yw== X-Gm-Message-State: APjAAAVOrGwKbd3tRNWh++BkKlNlBw+8EbbqG2OYszJgo5dEcOst4EuP B5j9S7U9vFtwQQXAXSBVVm0= X-Google-Smtp-Source: APXvYqy3+NLX6FD5hO4V3KoLt+72aXQmJJf2KB1W3ugIJDjX1FQt6aXKCVGUrXanhV+bq5NcWrJy6Q== X-Received: by 2002:a63:7141:: with SMTP id b1mr41779549pgn.331.1554913708702; Wed, 10 Apr 2019 09:28:28 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id z13sm51605956pgc.25.2019.04.10.09.28.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:28 -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: pic32-dmt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:56 -0700 Message-Id: <1554913683-25454-16-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop empty remove function - Use 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 Signed-off-by: Guenter Roeck --- drivers/watchdog/pic32-dmt.c | 46 ++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/drivers/watchdog/pic32-dmt.c b/drivers/watchdog/pic32-dmt.c index 052751c224fd..9a3c53e03c60 100644 --- a/drivers/watchdog/pic32-dmt.c +++ b/drivers/watchdog/pic32-dmt.c @@ -168,13 +168,19 @@ static struct watchdog_device pic32_dmt_wdd = { .ops = &pic32_dmt_fops, }; +static void pic32_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int pic32_dmt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; struct pic32_dmt *dmt; struct watchdog_device *wdd = &pic32_dmt_wdd; - dmt = devm_kzalloc(&pdev->dev, sizeof(*dmt), GFP_KERNEL); + dmt = devm_kzalloc(dev, sizeof(*dmt), GFP_KERNEL); if (!dmt) return -ENOMEM; @@ -182,54 +188,41 @@ static int pic32_dmt_probe(struct platform_device *pdev) if (IS_ERR(dmt->regs)) return PTR_ERR(dmt->regs); - dmt->clk = devm_clk_get(&pdev->dev, NULL); + dmt->clk = devm_clk_get(dev, NULL); if (IS_ERR(dmt->clk)) { - dev_err(&pdev->dev, "clk not found\n"); + dev_err(dev, "clk not found\n"); return PTR_ERR(dmt->clk); } ret = clk_prepare_enable(dmt->clk); if (ret) return ret; + ret = devm_add_action_or_reset(dev, pic32_clk_disable_unprepare, + dmt->clk); + if (ret) + return ret; wdd->timeout = pic32_dmt_get_timeout_secs(dmt); if (!wdd->timeout) { - dev_err(&pdev->dev, - "failed to read watchdog register timeout\n"); - ret = -EINVAL; - goto out_disable_clk; + dev_err(dev, "failed to read watchdog register timeout\n"); + return -EINVAL; } - dev_info(&pdev->dev, "timeout %d\n", wdd->timeout); + dev_info(dev, "timeout %d\n", wdd->timeout); wdd->bootstatus = pic32_dmt_bootstatus(dmt) ? WDIOF_CARDRESET : 0; watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT); watchdog_set_drvdata(wdd, dmt); - ret = watchdog_register_device(wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) { - dev_err(&pdev->dev, "watchdog register failed, err %d\n", ret); - goto out_disable_clk; + dev_err(dev, "watchdog register failed, err %d\n", ret); + return ret; } platform_set_drvdata(pdev, wdd); return 0; - -out_disable_clk: - clk_disable_unprepare(dmt->clk); - return ret; -} - -static int pic32_dmt_remove(struct platform_device *pdev) -{ - struct watchdog_device *wdd = platform_get_drvdata(pdev); - struct pic32_dmt *dmt = watchdog_get_drvdata(wdd); - - watchdog_unregister_device(wdd); - clk_disable_unprepare(dmt->clk); - - return 0; } static const struct of_device_id pic32_dmt_of_ids[] = { @@ -240,7 +233,6 @@ MODULE_DEVICE_TABLE(of, pic32_dmt_of_ids); static struct platform_driver pic32_dmt_driver = { .probe = pic32_dmt_probe, - .remove = pic32_dmt_remove, .driver = { .name = "pic32-dmt", .of_match_table = of_match_ptr(pic32_dmt_of_ids), From patchwork Wed Apr 10 16:27:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894369 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 97AAD139A for ; Wed, 10 Apr 2019 16:29:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79FF528B24 for ; Wed, 10 Apr 2019 16:29:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EEC528BA9; Wed, 10 Apr 2019 16:29:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 DBC9B28B24 for ; Wed, 10 Apr 2019 16:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387918AbfDJQ2b (ORCPT ); Wed, 10 Apr 2019 12:28:31 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:44917 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387916AbfDJQ2a (ORCPT ); Wed, 10 Apr 2019 12:28:30 -0400 Received: by mail-pl1-f193.google.com with SMTP id g12so1719955pll.11; Wed, 10 Apr 2019 09:28:30 -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=25JklC8A4qyogv/IaoK9AgYKIsQkHJeUki9cBit+3VU=; b=ak4DoercFbxPpvsydlQjYOWYxP6CgPEp7VabpBizbOoeTsDVhWGEakU61rc48z81TR nMZctSX+j1dy9JzIZkpdXQ9KJQuq1hhkLdiGsdSlyCxzW7B+J7YzWi2EUvwO6GKv5CUf s24PQqvBI0ObnWoALxtD7bfBUSfUNLACagvnK0HFIpowVB3kIjSgYWb8nfMVUwjIrtpB IuWETP/c0yvLLvl5hrfsb/KHuO4RDqmh9ipTMRdfm5WdjlEYRaIdGEoGEbqaA5qt9sXU ADj3DBCDDG8EqkphoAfZpNE/9TW5/Ix+GFxw9s9TjAOSaA9lOJNO7R0mqDWNbRcf3jyd s5Tw== 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=25JklC8A4qyogv/IaoK9AgYKIsQkHJeUki9cBit+3VU=; b=FIDZbsAEBQwpwuKrI/SjUN/cWU0N+qCPti43aj6orGqIHrIc5MgiPpDqZquSmcb+ZU VDE9qhs4BXuZ48vd7dPDs8H6zW0LQPuZVOOBqHHk9lVjMvtJYG2DGMgLnPknH3LpN6EL oEBpg4bqTiB02u4aOJ3L9LbhHjXqvjzJYPb+Kkyr19rpggk+x6QX8S+go73HiGl/Le+t A425asEII9BxAAZvRTpJA1ExoSffK1ouzuCLjfooUYl+EtCcpMEvcCFpjLfVL899m7lD nNmbNOmlLWFFftZxRf/xI/N0LgD1E32re+T8Ob5A/kcS+GbNnfEFhZeYTRYvGmpfyKvZ H4BA== X-Gm-Message-State: APjAAAU/cconsd4+kosIHb03Ilsy1nruVW6ukKMgMUZi6XBBYgBxDCYq ZRznDHvfjG2Iwpxh6F5uZitLFQQo X-Google-Smtp-Source: APXvYqxMz2E8UD9M1MOcqbN79WjCl0SKlTe8lYKGzBnvquwMX6vXODB+lbv8eA8NvroqkfS7bACy9w== X-Received: by 2002:a17:902:9a4a:: with SMTP id x10mr45274440plv.113.1554913710028; Wed, 10 Apr 2019 09:28:30 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id p17sm48206877pfn.157.2019.04.10.09.28.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:29 -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: pic32-wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:57 -0700 Message-Id: <1554913683-25454-17-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop empty remove function - Use 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 Signed-off-by: Guenter Roeck --- drivers/watchdog/pic32-wdt.c | 58 ++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/drivers/watchdog/pic32-wdt.c b/drivers/watchdog/pic32-wdt.c index 455ec38363a6..540500940cc0 100644 --- a/drivers/watchdog/pic32-wdt.c +++ b/drivers/watchdog/pic32-wdt.c @@ -166,13 +166,19 @@ static const struct of_device_id pic32_wdt_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, pic32_wdt_dt_ids); +static void pic32_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int pic32_wdt_drv_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; struct watchdog_device *wdd = &pic32_wdd; struct pic32_wdt *wdt; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -180,73 +186,57 @@ static int pic32_wdt_drv_probe(struct platform_device *pdev) if (IS_ERR(wdt->regs)) return PTR_ERR(wdt->regs); - wdt->rst_base = devm_ioremap(&pdev->dev, PIC32_BASE_RESET, 0x10); + wdt->rst_base = devm_ioremap(dev, PIC32_BASE_RESET, 0x10); if (!wdt->rst_base) return -ENOMEM; - wdt->clk = devm_clk_get(&pdev->dev, NULL); + wdt->clk = devm_clk_get(dev, NULL); if (IS_ERR(wdt->clk)) { - dev_err(&pdev->dev, "clk not found\n"); + dev_err(dev, "clk not found\n"); return PTR_ERR(wdt->clk); } ret = clk_prepare_enable(wdt->clk); if (ret) { - dev_err(&pdev->dev, "clk enable failed\n"); + dev_err(dev, "clk enable failed\n"); return ret; } + ret = devm_add_action_or_reset(dev, pic32_clk_disable_unprepare, + wdt->clk); + if (ret) + return ret; if (pic32_wdt_is_win_enabled(wdt)) { - dev_err(&pdev->dev, "windowed-clear mode is not supported.\n"); - ret = -ENODEV; - goto out_disable_clk; + dev_err(dev, "windowed-clear mode is not supported.\n"); + return -ENODEV; } - wdd->timeout = pic32_wdt_get_timeout_secs(wdt, &pdev->dev); + wdd->timeout = pic32_wdt_get_timeout_secs(wdt, dev); if (!wdd->timeout) { - dev_err(&pdev->dev, - "failed to read watchdog register timeout\n"); - ret = -EINVAL; - goto out_disable_clk; + dev_err(dev, "failed to read watchdog register timeout\n"); + return -EINVAL; } - dev_info(&pdev->dev, "timeout %d\n", wdd->timeout); + dev_info(dev, "timeout %d\n", wdd->timeout); wdd->bootstatus = pic32_wdt_bootstatus(wdt) ? WDIOF_CARDRESET : 0; watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT); watchdog_set_drvdata(wdd, wdt); - ret = watchdog_register_device(wdd); + ret = devm_watchdog_register_device(dev, wdd); if (ret) { - dev_err(&pdev->dev, "watchdog register failed, err %d\n", ret); - goto out_disable_clk; + dev_err(dev, "watchdog register failed, err %d\n", ret); + return ret; } platform_set_drvdata(pdev, wdd); return 0; - -out_disable_clk: - clk_disable_unprepare(wdt->clk); - - return ret; -} - -static int pic32_wdt_drv_remove(struct platform_device *pdev) -{ - struct watchdog_device *wdd = platform_get_drvdata(pdev); - struct pic32_wdt *wdt = watchdog_get_drvdata(wdd); - - watchdog_unregister_device(wdd); - clk_disable_unprepare(wdt->clk); - - return 0; } static struct platform_driver pic32_wdt_driver = { .probe = pic32_wdt_drv_probe, - .remove = pic32_wdt_drv_remove, .driver = { .name = "pic32-wdt", .of_match_table = of_match_ptr(pic32_wdt_dt_ids), From patchwork Wed Apr 10 16:27:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894367 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 3215717E0 for ; Wed, 10 Apr 2019 16:29:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 181B428B5A for ; Wed, 10 Apr 2019 16:29:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C85428BA9; Wed, 10 Apr 2019 16:29:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 C606528B5A for ; Wed, 10 Apr 2019 16:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387924AbfDJQ2c (ORCPT ); Wed, 10 Apr 2019 12:28:32 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41342 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387884AbfDJQ2c (ORCPT ); Wed, 10 Apr 2019 12:28:32 -0400 Received: by mail-pg1-f195.google.com with SMTP id f6so1856016pgs.8; Wed, 10 Apr 2019 09:28:31 -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=JFv/8qpijJBi/9fN4f4BgoRTl0I89T7cUIqnwNgfi5A=; b=cyKbWJwEIouqNYxadt+0H1pjEPe1zG8jT/lZkrFPingsqh2a8NK8jER/bUy6OGpqMy qFsV4+GNoq3P1g/C9HmzUEqL7GEdTPt1aJS2fP0ucYkoWzXzI6YfCKZlw8jF3KxkfOZJ gN5PCdHV2HcK4hvNIxNBmZpNI3e04PdeWB4ogeC4LWcIZG5IZRsvJffhRtciuE9nHV/w aty3VBCDQdPYRJ4pYON+p/Q3w5kwRKnbdpqmV0MVeMkeobzomEAEzx7opteuDiudH8b6 ee61GwOw9alfAs90DRGdIPNETqCcA6akyohfKbLErQXi600YEHERbkbawgcPorRFFq74 niWQ== 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=JFv/8qpijJBi/9fN4f4BgoRTl0I89T7cUIqnwNgfi5A=; b=VbH5nvc07wYlVKCoCAYa9tqQJ9XRMMyAF8/+u4OqaZHRd7+WGrKJ+GRvfA0NMpUFS0 eyjD8pjxtGv2QQTEEql3AxFO+Otr2Awif6ur6yxHxeIutKYunESwtsyyCALK0tmIyEP/ 0LJOMoREmaT332elcYvpUsNDsM0ovp2d2EYgxYAUEIPwopIE9LUBTJ3CUp/YWbqwQCGH YxsCITDP73MyPcKzqC1qip2xLhLqt4u9z4hgpEITe6NJ/vLMuA6cxDISHgiCnNfE+4pq oUEYYFIZDhXIn3jIrDxhK4rDLsBFoKN+TQNDiccGcDMCbZ5WF7lF8ddvCvJv2+bNUmwD lOmQ== X-Gm-Message-State: APjAAAVeDhWOKPIQMQ2kk9WJiV8T6oVF4Xz4I8Lsgvncrz9uFaIL6adB VhiWqLmE00cIfoGV+zLzAHE= X-Google-Smtp-Source: APXvYqxKvKwV403NJxB3coP59geUiwZbzyTbPDCSujVLzZlaV3Uw17VFIBe3YwlfiH3cTIoKyqOJ4w== X-Received: by 2002:a65:608a:: with SMTP id t10mr30773110pgu.125.1554913711421; Wed, 10 Apr 2019 09:28:31 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id n3sm63468609pfa.99.2019.04.10.09.28.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:30 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Keguang Zhang Subject: [PATCH 17/22] watchdog: loongson1_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:58 -0700 Message-Id: <1554913683-25454-18-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop unnecessary braces around conditional return statements - 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 Cc: Keguang Zhang Signed-off-by: Guenter Roeck --- drivers/watchdog/loongson1_wdt.c | 48 ++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/drivers/watchdog/loongson1_wdt.c b/drivers/watchdog/loongson1_wdt.c index 1119634b5c87..d8075e2affa7 100644 --- a/drivers/watchdog/loongson1_wdt.c +++ b/drivers/watchdog/loongson1_wdt.c @@ -83,14 +83,20 @@ static const struct watchdog_ops ls1x_wdt_ops = { .set_timeout = ls1x_wdt_set_timeout, }; +static void ls1x_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int ls1x_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct ls1x_wdt_drvdata *drvdata; struct watchdog_device *ls1x_wdt; unsigned long clk_rate; int err; - drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -98,21 +104,23 @@ static int ls1x_wdt_probe(struct platform_device *pdev) if (IS_ERR(drvdata->base)) return PTR_ERR(drvdata->base); - drvdata->clk = devm_clk_get(&pdev->dev, pdev->name); + drvdata->clk = devm_clk_get(dev, pdev->name); if (IS_ERR(drvdata->clk)) return PTR_ERR(drvdata->clk); err = clk_prepare_enable(drvdata->clk); if (err) { - dev_err(&pdev->dev, "clk enable failed\n"); + dev_err(dev, "clk enable failed\n"); return err; } + err = devm_add_action_or_reset(dev, ls1x_clk_disable_unprepare, + drvdata->clk); + if (err) + return err; clk_rate = clk_get_rate(drvdata->clk); - if (!clk_rate) { - err = -EINVAL; - goto err0; - } + if (!clk_rate) + return -EINVAL; drvdata->clk_rate = clk_rate; ls1x_wdt = &drvdata->wdt; @@ -121,41 +129,27 @@ static int ls1x_wdt_probe(struct platform_device *pdev) ls1x_wdt->timeout = DEFAULT_HEARTBEAT; ls1x_wdt->min_timeout = 1; ls1x_wdt->max_hw_heartbeat_ms = U32_MAX / clk_rate * 1000; - ls1x_wdt->parent = &pdev->dev; + ls1x_wdt->parent = dev; - watchdog_init_timeout(ls1x_wdt, heartbeat, &pdev->dev); + watchdog_init_timeout(ls1x_wdt, heartbeat, dev); watchdog_set_nowayout(ls1x_wdt, nowayout); watchdog_set_drvdata(ls1x_wdt, drvdata); - err = watchdog_register_device(&drvdata->wdt); + err = devm_watchdog_register_device(dev, &drvdata->wdt); if (err) { - dev_err(&pdev->dev, "failed to register watchdog device\n"); - goto err0; + dev_err(dev, "failed to register watchdog device\n"); + return err; } platform_set_drvdata(pdev, drvdata); - dev_info(&pdev->dev, "Loongson1 Watchdog driver registered\n"); - - return 0; -err0: - clk_disable_unprepare(drvdata->clk); - return err; -} - -static int ls1x_wdt_remove(struct platform_device *pdev) -{ - struct ls1x_wdt_drvdata *drvdata = platform_get_drvdata(pdev); - - watchdog_unregister_device(&drvdata->wdt); - clk_disable_unprepare(drvdata->clk); + dev_info(dev, "Loongson1 Watchdog driver registered\n"); return 0; } static struct platform_driver ls1x_wdt_driver = { .probe = ls1x_wdt_probe, - .remove = ls1x_wdt_remove, .driver = { .name = "ls1x-wdt", }, From patchwork Wed Apr 10 16:27:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894365 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 2168E17E0 for ; Wed, 10 Apr 2019 16:29:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E0D328A03 for ; Wed, 10 Apr 2019 16:29:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02CA828BA8; Wed, 10 Apr 2019 16:29:09 +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 9F8BF28BBE for ; Wed, 10 Apr 2019 16:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731786AbfDJQ3C (ORCPT ); Wed, 10 Apr 2019 12:29:02 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41627 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387925AbfDJQ2d (ORCPT ); Wed, 10 Apr 2019 12:28:33 -0400 Received: by mail-pl1-f193.google.com with SMTP id d1so1736153plj.8; Wed, 10 Apr 2019 09:28:33 -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=tR/tgWi0NWu/p8jUty40o4OgX03BGJEy7JzWJugTrTg=; b=l8tHrCHyh+IqMwRszJzBwTaDmzvJKoNJ+URalOMbDC3tvrW/bV25yFooCf1BzdDd8b /F/zQuupt3JljsBgfTuXXGPFwtqrmO4cUAsLBrMyBc4RQF//9JJr0d95N2lmnD4bJOgg 6lAbjwGwohr7gH3DDbpqFu7T4gqN5NEVMHipmSKPy0P366huTIk0+GjLXakVqMh0reu3 ZOW23PU9JfzgsX9/KFwgh+Y+Obil7r7HFYQOHA3p2B/n0z9WU0tZjWi/JvD39FZ1YYh5 xuf/8/XBRQywJ4bFr7cLAcG2UYNjK27jVQvwIEYoX+k0+72SmyDd8isrNLbOuXaMcCPJ yb3w== 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=tR/tgWi0NWu/p8jUty40o4OgX03BGJEy7JzWJugTrTg=; b=hPH01HhAZSS9DQuK+GWuRNX9jNM3VB47PjAbv2rKjGeKaJ1MAuijIX076BuM0nH5s2 EL1I2GQPYNP97kumq8bUYSjUOW+mgU5L/dMsg1W79oZZqs/6F3InA/C/DW2CTltJr5si g8L1lPJP8woeQQ9oJH4881dVcKhzsJnmCAsuI6QRh2Fb6xZeUCrfbmyvU1cvC5nhq2I9 PzqymSnV38aNYH7hx/2cHUnSfndoCsfmPxE0a9ImKGQLJywOuB+twvFqtpx0TJwHU+EQ mq5Cz7NUOSED1ZFDZKBEA1V2Ybb2DTm+pYGhLtW0wWK/UrNfMkG7Xx7e0ELrm+hgorX+ 3sCA== X-Gm-Message-State: APjAAAVi9XrQBRS0BwmDq0AmBM2EeMwZJODf2VV1MjCiqHxmloWpYz4+ OlUBfCql0xBhbtOww5urtMc= X-Google-Smtp-Source: APXvYqwJlYL+IfVOaai2ytLp+SH6HMDh9ZjHEEpEf7GoE87eBMjFLOfgam1WiYIfk0AXWgxR4hrqKQ== X-Received: by 2002:a17:902:7d81:: with SMTP id a1mr44620383plm.202.1554913712767; Wed, 10 Apr 2019 09:28:32 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id z8sm44583797pgz.3.2019.04.10.09.28.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:32 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Matthias Brugger Subject: [PATCH 18/22] watchdog: mt7621_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Wed, 10 Apr 2019 09:27:59 -0700 Message-Id: <1554913683-25454-19-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Matthias Brugger Signed-off-by: Guenter Roeck --- drivers/watchdog/mt7621_wdt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/mt7621_wdt.c b/drivers/watchdog/mt7621_wdt.c index 9c943f1d57ec..cbb3c0dde136 100644 --- a/drivers/watchdog/mt7621_wdt.c +++ b/drivers/watchdog/mt7621_wdt.c @@ -133,18 +133,19 @@ static struct watchdog_device mt7621_wdt_dev = { static int mt7621_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; mt7621_wdt_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(mt7621_wdt_base)) return PTR_ERR(mt7621_wdt_base); - mt7621_wdt_reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); + mt7621_wdt_reset = devm_reset_control_get_exclusive(dev, NULL); if (!IS_ERR(mt7621_wdt_reset)) reset_control_deassert(mt7621_wdt_reset); mt7621_wdt_dev.bootstatus = mt7621_wdt_bootcause(); watchdog_init_timeout(&mt7621_wdt_dev, mt7621_wdt_dev.max_timeout, - &pdev->dev); + dev); watchdog_set_nowayout(&mt7621_wdt_dev, nowayout); if (mt7621_wdt_is_running(&mt7621_wdt_dev)) { /* @@ -161,7 +162,7 @@ static int mt7621_wdt_probe(struct platform_device *pdev) set_bit(WDOG_HW_RUNNING, &mt7621_wdt_dev.status); } - return devm_watchdog_register_device(&pdev->dev, &mt7621_wdt_dev); + return devm_watchdog_register_device(dev, &mt7621_wdt_dev); } static void mt7621_wdt_shutdown(struct platform_device *pdev) From patchwork Wed Apr 10 16:28:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894363 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 26FC817E0 for ; Wed, 10 Apr 2019 16:28:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1193328BD9 for ; Wed, 10 Apr 2019 16:28:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05A3128BE1; Wed, 10 Apr 2019 16:28:57 +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 E20FB28BCC for ; Wed, 10 Apr 2019 16:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731864AbfDJQ2z (ORCPT ); Wed, 10 Apr 2019 12:28:55 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33100 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387933AbfDJQ2f (ORCPT ); Wed, 10 Apr 2019 12:28:35 -0400 Received: by mail-pf1-f195.google.com with SMTP id h5so1806858pfo.0; Wed, 10 Apr 2019 09:28:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZIFkfAZMLG3ZtjNbK1/QwyzTqgHbls9I5r5J/yPn+AM=; b=UuzrEs3D/iI4GnkUQsBc1f5DUUAWNrrCSXsMdOWmJOxXYH2MGmZffr+4yqKSZ3d1rS IXm+w43bLGo+1RzvRlYWQeF4k2eOFjV99y9SDZrcar7g9Jp26rLFn5pjC2ImL0qU6/PB S/N+eGn7dTQUOQY3zs6Zuqbn/cZnxfHowWx+fVOOTZS3nMLZvxvGQ/zBdN6YSUnwosee F5BeRvOmCrvsZH6hBKApEYTKeZqHTxZb+95Qa4iUrfnyxuzhJtdCd+YFZCDsFbugbmob m2oe6KXzTSLK+q27IXF8fHbAMNbRHh1EDYtWB2OABoWpN98RfIEWsDDdAoHAkcKkSE6Z RtmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ZIFkfAZMLG3ZtjNbK1/QwyzTqgHbls9I5r5J/yPn+AM=; b=EPDOdsBEYPb7QJCKLOTQ2Q+jiH5fXcwzU3U77BtRf1erWf/FCLp+m9T853V/KE+jBw w/dbdEwzpGAbQyTDaR5tXS06sJk/YYlHkCUJANKeoGqWXszA6whwF8rNZbsVuk7ni+Mb /yTC/hAUJuNzfDNccYUdSP/s3G3fjzTW15c7J4mkUKMNuuB2K+2FrRaNmmWyYfU+bpqS fz49zJX8CcKyB1WrZq9kPBf30+AruBccRmIuSUYiT8dMQQzfFOkEebhl4zU6+papcwwb Ap/2dy8FP07dGVHP3v8CkzOhgApVz1kkmuK5FOypzuVg6Bkdgw+PFAyOi42w4svj3jDu slhg== X-Gm-Message-State: APjAAAXdaO8ByukW9vL1lE+JwYNEUlUj3e7zga8mK483GHPUaCbp7ChX HnpZZSrI7WKNS/lpP9TZay8= X-Google-Smtp-Source: APXvYqzyEHlqxTJGrUfXPg7Z3KBRGvKQpyVsi+uIBSjC+6/o7VKpiX0xSAjPnN2QPUB2y14UM1+Sew== X-Received: by 2002:a63:36ce:: with SMTP id d197mr42761951pga.180.1554913714112; Wed, 10 Apr 2019 09:28:34 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id n5sm42295817pgp.80.2019.04.10.09.28.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:33 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 19/22] watchdog: rt2880_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:28:00 -0700 Message-Id: <1554913683-25454-20-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-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 empty remove function - Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly - Use devm_watchdog_register_driver() to register watchdog device - Replace shutdown function with call to watchdog_stop_on_reboot() Signed-off-by: Guenter Roeck --- drivers/watchdog/rt2880_wdt.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/watchdog/rt2880_wdt.c b/drivers/watchdog/rt2880_wdt.c index 4adf5f39fdd9..905e60f45eec 100644 --- a/drivers/watchdog/rt2880_wdt.c +++ b/drivers/watchdog/rt2880_wdt.c @@ -141,17 +141,18 @@ static struct watchdog_device rt288x_wdt_dev = { static int rt288x_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; rt288x_wdt_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(rt288x_wdt_base)) return PTR_ERR(rt288x_wdt_base); - rt288x_wdt_clk = devm_clk_get(&pdev->dev, NULL); + rt288x_wdt_clk = devm_clk_get(dev, NULL); if (IS_ERR(rt288x_wdt_clk)) return PTR_ERR(rt288x_wdt_clk); - rt288x_wdt_reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); + rt288x_wdt_reset = devm_reset_control_get_exclusive(dev, NULL); if (!IS_ERR(rt288x_wdt_reset)) reset_control_deassert(rt288x_wdt_reset); @@ -159,31 +160,20 @@ static int rt288x_wdt_probe(struct platform_device *pdev) rt288x_wdt_dev.bootstatus = rt288x_wdt_bootcause(); rt288x_wdt_dev.max_timeout = (0xfffful / rt288x_wdt_freq); - rt288x_wdt_dev.parent = &pdev->dev; + rt288x_wdt_dev.parent = dev; watchdog_init_timeout(&rt288x_wdt_dev, rt288x_wdt_dev.max_timeout, - &pdev->dev); + dev); watchdog_set_nowayout(&rt288x_wdt_dev, nowayout); - ret = watchdog_register_device(&rt288x_wdt_dev); + watchdog_stop_on_reboot(&rt288x_wdt_dev); + ret = devm_watchdog_register_device(dev, &rt288x_wdt_dev); if (!ret) - dev_info(&pdev->dev, "Initialized\n"); + dev_info(dev, "Initialized\n"); return 0; } -static int rt288x_wdt_remove(struct platform_device *pdev) -{ - watchdog_unregister_device(&rt288x_wdt_dev); - - return 0; -} - -static void rt288x_wdt_shutdown(struct platform_device *pdev) -{ - rt288x_wdt_stop(&rt288x_wdt_dev); -} - static const struct of_device_id rt288x_wdt_match[] = { { .compatible = "ralink,rt2880-wdt" }, {}, @@ -192,8 +182,6 @@ MODULE_DEVICE_TABLE(of, rt288x_wdt_match); static struct platform_driver rt288x_wdt_driver = { .probe = rt288x_wdt_probe, - .remove = rt288x_wdt_remove, - .shutdown = rt288x_wdt_shutdown, .driver = { .name = KBUILD_MODNAME, .of_match_table = rt288x_wdt_match, From patchwork Wed Apr 10 16:28:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894357 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 8084A17E0 for ; Wed, 10 Apr 2019 16:28:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CCFE28A1B for ; Wed, 10 Apr 2019 16:28:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61B7B28BDB; Wed, 10 Apr 2019 16:28: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 0A02A28BB4 for ; Wed, 10 Apr 2019 16:28:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387884AbfDJQ2g (ORCPT ); Wed, 10 Apr 2019 12:28:36 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34940 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387942AbfDJQ2g (ORCPT ); Wed, 10 Apr 2019 12:28:36 -0400 Received: by mail-pg1-f193.google.com with SMTP id g8so1875292pgf.2; Wed, 10 Apr 2019 09:28:35 -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=CH6L2uzJtaCz65XjzhhlNI5Vmu2UxURtpsq3Xl1aHTE=; b=FC44KMiWHeYquqM77/vv8osNSx8MExE7lnkqrdXnDG92l2bd8wZhKbNygLt0bmwn2v SxCkFOFn8jCxi4Ar+CqGnEjIQDy/fz1xQLxfj8UsLoC2tuEswYUMTAXcETG8mXYmWAZ9 sYecaVVAg5e032atVlIbmmtasnNbFXULGqNz3AO+9tW9g7qBMaYGXVmoBXOVp4N3DRQU PQl8UTyFycslNwgtv7QId/2CYpbxpnTsB3QJ0iI9CM3qDkpOFI0CEgfJYmpkE5Cv0C+I SoQRUqsnk8af9kI0EKT0NLVeUD93rt/4knMXmkrQvrvH0BwNjNCrMXw7X2gGFm3q9tCo CFzg== 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=CH6L2uzJtaCz65XjzhhlNI5Vmu2UxURtpsq3Xl1aHTE=; b=iKjmuyg1pBQ2Kwk7x2hI9wF2KKlLaSrI8kXE8e+Zt/FkwrWvGFMg/5VubAXu1idbel 2+CIAz8kl9m4VyESA0VJFZRb6nJqqzj/tp3zqujmsv3vzVN1rOaRAO7KjQ9e8736oBgU OesFJbFu1zuMg7qT+4roDthhZeDd6FZSN8H5vVJRX0gIl6Gcd9oxCq9nxysyegoMghkL YqoB1bvG6aYvf2h9/1dA3X6YaYd5PP3JNr4E3R472GtsAjprT8bz6k5g9UYdfMFI1IGv 2Nh9o3Rjylmtb8MYl7KjS8fUYqXObRyZwCmcSS1owlUwK24iAM9U3PV/xe4kYqMdHx63 6ojw== X-Gm-Message-State: APjAAAUFTT1Bytksgp/UGPf+eb+G3ivZm9i+t2qRy5JGvz6k6F7dccA+ 9+puJuuCXTHIOnnsfI1SrAc= X-Google-Smtp-Source: APXvYqxFNaDdvdR1InKhC+bT5ZC9DT+l2EnAJbuIa9WZ1Yju4F8nqVo0cRbMMt1oOcDr4Jqmn8rE6A== X-Received: by 2002:a62:e501:: with SMTP id n1mr21039555pff.17.1554913715427; Wed, 10 Apr 2019 09:28:35 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id a12sm41051784pgq.21.2019.04.10.09.28.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:34 -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: jz4740_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Wed, 10 Apr 2019 09:28:01 -0700 Message-Id: <1554913683-25454-21-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly. Also, there is no call to dev_get_drvdata() or platform_get_drvdata() in the driver, so drop the unnecessary call to platform_set_drvdata(). 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/jz4740_wdt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/jz4740_wdt.c b/drivers/watchdog/jz4740_wdt.c index aa9d3523addd..d1bc7cbd4f2b 100644 --- a/drivers/watchdog/jz4740_wdt.c +++ b/drivers/watchdog/jz4740_wdt.c @@ -163,11 +163,12 @@ MODULE_DEVICE_TABLE(of, jz4740_wdt_of_matches); static int jz4740_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct jz4740_wdt_drvdata *drvdata; struct watchdog_device *jz4740_wdt; int ret; - drvdata = devm_kzalloc(&pdev->dev, sizeof(struct jz4740_wdt_drvdata), + drvdata = devm_kzalloc(dev, sizeof(struct jz4740_wdt_drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -181,7 +182,7 @@ static int jz4740_wdt_probe(struct platform_device *pdev) jz4740_wdt->timeout = heartbeat; jz4740_wdt->min_timeout = 1; jz4740_wdt->max_timeout = MAX_HEARTBEAT; - jz4740_wdt->parent = &pdev->dev; + jz4740_wdt->parent = dev; watchdog_set_nowayout(jz4740_wdt, nowayout); watchdog_set_drvdata(jz4740_wdt, drvdata); @@ -189,18 +190,16 @@ static int jz4740_wdt_probe(struct platform_device *pdev) if (IS_ERR(drvdata->base)) return PTR_ERR(drvdata->base); - drvdata->rtc_clk = devm_clk_get(&pdev->dev, "rtc"); + drvdata->rtc_clk = devm_clk_get(dev, "rtc"); if (IS_ERR(drvdata->rtc_clk)) { - dev_err(&pdev->dev, "cannot find RTC clock\n"); + dev_err(dev, "cannot find RTC clock\n"); return PTR_ERR(drvdata->rtc_clk); } - ret = devm_watchdog_register_device(&pdev->dev, &drvdata->wdt); + ret = devm_watchdog_register_device(dev, &drvdata->wdt); if (ret < 0) return ret; - platform_set_drvdata(pdev, drvdata); - return 0; } From patchwork Wed Apr 10 16:28:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894361 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 5AA91139A for ; Wed, 10 Apr 2019 16:28:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46F8928BBD for ; Wed, 10 Apr 2019 16:28:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B87F28BBB; Wed, 10 Apr 2019 16:28:51 +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 D051028BD5 for ; Wed, 10 Apr 2019 16:28:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731867AbfDJQ2i (ORCPT ); Wed, 10 Apr 2019 12:28:38 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37306 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387953AbfDJQ2h (ORCPT ); Wed, 10 Apr 2019 12:28:37 -0400 Received: by mail-pl1-f195.google.com with SMTP id w23so1737093ply.4; Wed, 10 Apr 2019 09:28:37 -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=Y3q0kgdoTOk/eYTK2ErICl6tYKEu68Zi7htktucMeOA=; b=SYGZRtP85ydvrBfzCxF3iJZJkmnJCQuMpxv6Ziq4bMU2tmZ+dORYAzFK2kBV24ssFk AXAWhIZh79xPKCfoWdAZlWzvjMUbl6Z836KZdh7xBAyzccE+2YX34BMjzcpONPFdqRxc OEoiMFdrn6RhEBs6LXCOXQ1oDc/+/qhtZx+4qj5Hlz9fkOSfhHdj2/1J7InBg44FJu8o FpsYvJBDBbG/Muu8A5gYk3d7IkYnxNx36v4Qrhe+Y0Y6TlzCRUCzzthUHRiEseQsectq wuab7nhI+msT6rYCJrXhIitVikO0XcCWblLjt4c5NTHKH5rvO8pElMuJhV4W80ab+Ar+ tsLA== 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=Y3q0kgdoTOk/eYTK2ErICl6tYKEu68Zi7htktucMeOA=; b=crva7mcpSaisBMVd1tlKiwReT4qGLV2gp6UbR2yfsVSYgMXfkKA6QI0iwLiNUtMVAs sPqVGaBIVwwv+KR8vVjanJrGTGJHB9Er0WfV4dHm4MjozybA41CP5SK0LCNH4uzpwtUo /Ev44BweppSQXhbuD2OVRJ0Lmpu1IMVQbopd4VIeyiQs7SurQtgBo4UUBCHtNm7vXDZ0 1hU+zdGsOQ7zCULJ+RuAuWirtSPpiwBS3vBEkfWfttPACU7iohOSXlEcPTZzH7pVhX1V zX8/XlF1OTOCPEPVXppK2514EL7gKwn6zkvMMqRIB2+t12v0uTnZWS7F9HawTwPc5T43 Xr5w== X-Gm-Message-State: APjAAAVRT84RPG2KrIQ7ZRcpVV3WXPoAkaFkPPHxZBaHQhq2/4Ggenx7 giCNTF7Ivo51tgEjHkPSVschNbNm X-Google-Smtp-Source: APXvYqwresMKhaadD1wyYs5Vx35MBq8gOEU1GAguLyQ7xLsPtnH2nYJUdtAIeLbre3JnscHerOMYNg== X-Received: by 2002:a17:902:b597:: with SMTP id a23mr43264926pls.284.1554913717080; Wed, 10 Apr 2019 09:28:37 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id t82sm97448554pfa.153.2019.04.10.09.28.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:36 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 21/22] watchdog: mpc8xxx_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:28:02 -0700 Message-Id: <1554913683-25454-22-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop empty remove function This also drops the inaccurate message on remove; the driver won't be removed if the hardware watchdog is running, no matter if the watchdog device is open or not. - Use local variable 'struct device *dev' consistently - Use devm_watchdog_register_driver() to register watchdog device Signed-off-by: Guenter Roeck Reviewed-by: Christophe Leroy --- drivers/watchdog/mpc8xxx_wdt.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c index 3b5b446b690c..9b6d6a5a27ad 100644 --- a/drivers/watchdog/mpc8xxx_wdt.c +++ b/drivers/watchdog/mpc8xxx_wdt.c @@ -204,9 +204,10 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev) if (ddata->wdd.timeout < ddata->wdd.min_timeout) ddata->wdd.timeout = ddata->wdd.min_timeout; - ret = watchdog_register_device(&ddata->wdd); + ret = devm_watchdog_register_device(dev, &ddata->wdd); if (ret) { - dev_err(dev, "cannot register watchdog device (err=%d)\n", ret); + dev_err(dev, "cannot register watchdog device (err=%d)\n", + ret); return ret; } @@ -218,17 +219,6 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev) return 0; } -static int mpc8xxx_wdt_remove(struct platform_device *ofdev) -{ - struct mpc8xxx_wdt_ddata *ddata = platform_get_drvdata(ofdev); - - dev_crit(&ofdev->dev, "Watchdog removed, expect the %s soon!\n", - reset ? "reset" : "machine check exception"); - watchdog_unregister_device(&ddata->wdd); - - return 0; -} - static const struct of_device_id mpc8xxx_wdt_match[] = { { .compatible = "mpc83xx_wdt", @@ -259,7 +249,6 @@ MODULE_DEVICE_TABLE(of, mpc8xxx_wdt_match); static struct platform_driver mpc8xxx_wdt_driver = { .probe = mpc8xxx_wdt_probe, - .remove = mpc8xxx_wdt_remove, .driver = { .name = "mpc8xxx_wdt", .of_match_table = mpc8xxx_wdt_match, From patchwork Wed Apr 10 16:28:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10894359 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 B4B4417E0 for ; Wed, 10 Apr 2019 16:28:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E70728BA6 for ; Wed, 10 Apr 2019 16:28:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CD7C28BBB; Wed, 10 Apr 2019 16:28:50 +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 3160028BA6 for ; Wed, 10 Apr 2019 16:28:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731886AbfDJQ2o (ORCPT ); Wed, 10 Apr 2019 12:28:44 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45133 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731892AbfDJQ2j (ORCPT ); Wed, 10 Apr 2019 12:28:39 -0400 Received: by mail-pf1-f193.google.com with SMTP id e24so1771512pfi.12; Wed, 10 Apr 2019 09:28:38 -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=S+GV2SyW/bymaq3EbCzp8kJz5OheCRJsZsCuHkP6+Lk=; b=ISHxPmh/QzYSLGOp8LuhzL0Q0EsIY4ErgK3l+3cba+3f3CEaJwG4iHjOK0/repCk0b 5Oit5uj3K794/pmOG2WUaD/V1bDX53o+ubC6iTdb9Lx9onWnauMQOcohmApbA0/1qjY1 4xR7ptT04em1XUqskBFxclM/as0blmWjnyITWBghy6AY70GyN2x+TGQ10RlYwWyFr99A cG/C2GPrRdIf3rC8ul0hqfx2s5MVE8A8eMJsAsMVzzHTPBUWhZ/HvpNlM+f25Y43GABt ZyCDtcRsQoJC+lOuE++XNLzdjsd2nUVEaWGMSnE+c03ZB9BhCDnYgqJkQEHL55de9MXc scaQ== 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=S+GV2SyW/bymaq3EbCzp8kJz5OheCRJsZsCuHkP6+Lk=; b=RkwzFlXdkjzU5PelndMyRdnzY3qi0P85nbaOvp1qOZEJDjl/ui7mc9p4RCv9+iOkyL 3aUo55GjiG7CQGfntWM7brC4KmqxHHfGyGX7jSdA5gSnTZxZBS9vTM3lDTUA17jHzrDN 9IUaZkh/v/XR4cZnGTtUKDFl7RwACOBFb0PC01UaZ+oQbKbc3wVKi8o4CEsI+3R5ShdO NrvPjOpMei6I8EBKwviGda4ghaZ0n/EEzFh7Yqs5oqdfk2FHEjy2GCgXJ3GxRZPMgkem OxYN4hFWjvREslJExKSgnE1LKTI3SFVBCi1fRTrqbRqOY/+1se7iVbhqKkO62kocVPkO EYVw== X-Gm-Message-State: APjAAAXIrk1k9cFjpUb5xd74qevECXTU3ycvkpt378UnWLHUSXaVCJLY joxbHcYunthcvmndsepVHeQ= X-Google-Smtp-Source: APXvYqySBxJ14wgGhdZPcHzxBvmFCjH9W7qm+4v/DcXfzLmrOGyaIFieUZx64NrDk2tBWg3s/ipJ/Q== X-Received: by 2002:a63:5b4b:: with SMTP id l11mr12611446pgm.95.1554913718420; Wed, 10 Apr 2019 09:28:38 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id f71sm51877312pfc.109.2019.04.10.09.28.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:37 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Vladimir Zapolskiy , Sylvain Lemieux Subject: [PATCH 22/22] watchdog: pnx4008_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:28:03 -0700 Message-Id: <1554913683-25454-23-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop 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 Cc: Vladimir Zapolskiy Cc: Sylvain Lemieux Signed-off-by: Guenter Roeck --- drivers/watchdog/pnx4008_wdt.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c index 24c266a9e1dc..f94d844e596c 100644 --- a/drivers/watchdog/pnx4008_wdt.c +++ b/drivers/watchdog/pnx4008_wdt.c @@ -183,52 +183,49 @@ static struct watchdog_device pnx4008_wdd = { .max_timeout = MAX_HEARTBEAT, }; +static void pnx4008_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int pnx4008_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret = 0; - watchdog_init_timeout(&pnx4008_wdd, heartbeat, &pdev->dev); + watchdog_init_timeout(&pnx4008_wdd, heartbeat, dev); wdt_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(wdt_base)) return PTR_ERR(wdt_base); - wdt_clk = devm_clk_get(&pdev->dev, NULL); + wdt_clk = devm_clk_get(dev, NULL); if (IS_ERR(wdt_clk)) return PTR_ERR(wdt_clk); ret = clk_prepare_enable(wdt_clk); if (ret) return ret; + ret = devm_add_action_or_reset(dev, pnx4008_clk_disable_unprepare, + wdt_clk); + if (ret) + return ret; pnx4008_wdd.bootstatus = (readl(WDTIM_RES(wdt_base)) & WDOG_RESET) ? WDIOF_CARDRESET : 0; - pnx4008_wdd.parent = &pdev->dev; + pnx4008_wdd.parent = dev; watchdog_set_nowayout(&pnx4008_wdd, nowayout); watchdog_set_restart_priority(&pnx4008_wdd, 128); pnx4008_wdt_stop(&pnx4008_wdd); /* disable for now */ - ret = watchdog_register_device(&pnx4008_wdd); + ret = devm_watchdog_register_device(dev, &pnx4008_wdd); if (ret < 0) { - dev_err(&pdev->dev, "cannot register watchdog device\n"); - goto disable_clk; + dev_err(dev, "cannot register watchdog device\n"); + return ret; } - dev_info(&pdev->dev, "heartbeat %d sec\n", pnx4008_wdd.timeout); - - return 0; - -disable_clk: - clk_disable_unprepare(wdt_clk); - return ret; -} - -static int pnx4008_wdt_remove(struct platform_device *pdev) -{ - watchdog_unregister_device(&pnx4008_wdd); - - clk_disable_unprepare(wdt_clk); + dev_info(dev, "heartbeat %d sec\n", pnx4008_wdd.timeout); return 0; } @@ -247,7 +244,6 @@ static struct platform_driver platform_wdt_driver = { .of_match_table = of_match_ptr(pnx4008_wdt_match), }, .probe = pnx4008_wdt_probe, - .remove = pnx4008_wdt_remove, }; module_platform_driver(platform_wdt_driver);