From patchwork Tue Apr 9 17:23:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10891887 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 269761515 for ; Tue, 9 Apr 2019 17:26:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14C5F26E4F for ; Tue, 9 Apr 2019 17:26:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08BD42893C; Tue, 9 Apr 2019 17:26:36 +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 9972D26E4F for ; Tue, 9 Apr 2019 17:26:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726606AbfDIRYO (ORCPT ); Tue, 9 Apr 2019 13:24:14 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42638 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726431AbfDIRYN (ORCPT ); Tue, 9 Apr 2019 13:24:13 -0400 Received: by mail-pl1-f193.google.com with SMTP id cv12so9792782plb.9; Tue, 09 Apr 2019 10:24: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=WDkdjCuCoMl4klGjBikpqpnhMyWOhlVzWHe2RSdyLn0=; b=TX3lekicuwdd7C++LfiUuLaqPbrTD3Spl0GMuuAv9LUWdOWbBQhnsXzW9GFO8p3I+W 6j5Ykqe3nhTs4MKMkWufVVbH7f0BDWYDdsgJl2y4IMRNETk4k+5gpen4jfR1JrerUwEv hDcpcd/eSq0foA2J9OYBalqPNR8i+d9ZzRCYoSrMLOActt5BOadq9C3u+rPH3rBiXBnG gCSdKu8HyPL0jETy6QpkoOJ2WKaGUnpxp4ht0SH8LgLT1QuyH9x0MsZY7W5j84c3Oze9 DRmXaX+tZViYWn2v6aFHX3NNcuz0NQq5/bb1Rr9zePhxo7cPa2bhZXlwyMXw4lT99xAG k88g== 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=WDkdjCuCoMl4klGjBikpqpnhMyWOhlVzWHe2RSdyLn0=; b=DqJW3NmDkeMzREcHwi4M5a1FI39xHWQVyPJ9ovCrIM5SWRYZStvpRSqzsR7CN2+EGP uvXtZSfLk1ryhS83Twkg074p83KZmkipVWGWuKBPSCoDjvhedDTJpT5xPrm1Autq9I38 pjy2v6iVdYuo+8bt1SoHpEgU4beK9qqMMRIcIABFXo8slZYm2AEUXmAlEbOco4B+i8D3 dYedXT9AvULcq2Du6CEVFlbXSbModaICRNWfdJIHoy+Yl3CkBKBAaTx7htwbZNIK+ryQ l0skkD0YqIXct2pfqFQ4+/nyl6Ti/jdTXDvA++yf5HC9oYjNqpX8Z2UB0ktPyPQVv/zk UmBA== X-Gm-Message-State: APjAAAVLnoT3KV+qYZB5Rr45mia0LtGXrARyCeIQOWmYmpfNu/+J8Rm2 3p0YYjyfhhiKFPbjdBA11Akcuq34 X-Google-Smtp-Source: APXvYqwVcFu9w2KErfPWvjoL2Iq7SKADR+E81dsVQ7tlI2u7cBlGnLxyX6ixz52AWUCZyqnbdehC/A== X-Received: by 2002:a17:902:d83:: with SMTP id 3mr14265678plv.125.1554830653174; Tue, 09 Apr 2019 10:24:13 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id m16sm83832033pfi.29.2019.04.09.10.24.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24: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 01/23] watchdog: max77620_wdt: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:23:39 -0700 Message-Id: <1554830641-9247-2-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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 - Replace stop on remove with call to watchdog_stop_on_unregister() - Use devm_watchdog_register_driver() to register watchdog device Signed-off-by: Guenter Roeck --- drivers/watchdog/max77620_wdt.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/watchdog/max77620_wdt.c b/drivers/watchdog/max77620_wdt.c index 70c9cd3ba938..3ca6b9337932 100644 --- a/drivers/watchdog/max77620_wdt.c +++ b/drivers/watchdog/max77620_wdt.c @@ -112,17 +112,18 @@ static const struct watchdog_ops max77620_wdt_ops = { static int max77620_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct max77620_wdt *wdt; struct watchdog_device *wdt_dev; unsigned int regval; int ret; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; - wdt->dev = &pdev->dev; - wdt->rmap = dev_get_regmap(pdev->dev.parent, NULL); + wdt->dev = dev; + wdt->rmap = dev_get_regmap(dev->parent, NULL); if (!wdt->rmap) { dev_err(wdt->dev, "Failed to get parent regmap\n"); return -ENODEV; @@ -183,25 +184,16 @@ static int max77620_wdt_probe(struct platform_device *pdev) watchdog_set_nowayout(wdt_dev, nowayout); watchdog_set_drvdata(wdt_dev, wdt); - ret = watchdog_register_device(wdt_dev); + watchdog_stop_on_unregister(wdt_dev); + ret = devm_watchdog_register_device(dev, wdt_dev); if (ret < 0) { - dev_err(&pdev->dev, "watchdog registration failed: %d\n", ret); + dev_err(dev, "watchdog registration failed: %d\n", ret); return ret; } return 0; } -static int max77620_wdt_remove(struct platform_device *pdev) -{ - struct max77620_wdt *wdt = platform_get_drvdata(pdev); - - max77620_wdt_stop(&wdt->wdt_dev); - watchdog_unregister_device(&wdt->wdt_dev); - - return 0; -} - static const struct platform_device_id max77620_wdt_devtype[] = { { .name = "max77620-watchdog", }, { }, @@ -213,7 +205,6 @@ static struct platform_driver max77620_wdt_driver = { .name = "max77620-watchdog", }, .probe = max77620_wdt_probe, - .remove = max77620_wdt_remove, .id_table = max77620_wdt_devtype, }; From patchwork Tue Apr 9 17:23:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10891885 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 431AF186D for ; Tue, 9 Apr 2019 17:26:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3016A2839C for ; Tue, 9 Apr 2019 17:26:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 240D026E4F; Tue, 9 Apr 2019 17:26:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B31072894C for ; Tue, 9 Apr 2019 17:26:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726638AbfDIRYQ (ORCPT ); Tue, 9 Apr 2019 13:24:16 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:32937 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726431AbfDIRYP (ORCPT ); Tue, 9 Apr 2019 13:24:15 -0400 Received: by mail-pg1-f194.google.com with SMTP id k19so9701235pgh.0; Tue, 09 Apr 2019 10:24:14 -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=jKbn0+uhPr/AYdBY5ar3yTCFhEOd5nLB6VfRC6MJRs4=; b=shalK5htuv5iTeHjjay2f9Y3ThgIXWaEiHASUHAjJLeFul0xMsWmwAijFo3QQNG3+n kyIfcFdqYlMnJmXIB4IZNWdEFxDk7QYNU9/IO8YS7tR4vJGsoNZ+fYLjchvx6si5y5Jt vrr7qKsSnRwWAYihNwLiLVHhNzsRSQ2G9+M34VbPixh/nlABu9pYlupp4Yc9MDHAcgfE epMhlHuYLpZikldCbXUFwvysFL0gp2OB52qk2n3QaUPPmn5dqOYMnM2DNk/DQ4FomCdw vVVPvifyM/Dg+YS9UIJZFiFt6W9UhMeIoSYOF+gSMZnLN/T7d6pnZkzN8o0Uerw6eX8h CLXg== 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=jKbn0+uhPr/AYdBY5ar3yTCFhEOd5nLB6VfRC6MJRs4=; b=bzDV3Ul09EifMpYrZHA2bKU4VVSs3RqgqWaN4lKOyrBO56zEut/+cS3FDeZO2GmTdg PIM+QhVynYxXhC+/yjz6D+IC04jMsqaqKc2ZNgYP737X0srP0gZdTzG4pRkX9D85j8AC u47nTI5RLH0FAZ0707kHk1rIDflFtvDWylMw4iNRriZIfGyMJYOA0xCnLvIzSo6ALfaq FERfDPM/ynZDtKUK9UoW+gEnQTcy/lUvY2CujKTCNhEdSRM1R4e157oEx5VCe1AxVHmN JRggAgQFeYW+HJO9qQEoUWop1uq3zjfZh9ohKNxtXeTdoMzRuQOhYLuXfcNIixx+LmFN Kw4g== X-Gm-Message-State: APjAAAX7X5nJeSFgkKupBsn0urOmlpHXEAK7Snv/uSod6EFjcBK586RV EegLI9eeGT5Hywku/u3Bi7R8sdpf X-Google-Smtp-Source: APXvYqyWqvGmg7h8q0DRYGXRO1e1TkVmxX/7G5h+mhILcL6AodF6B/LsfwYkj/OEg2rduen9pky5RQ== X-Received: by 2002:a63:450f:: with SMTP id s15mr35323176pga.157.1554830654534; Tue, 09 Apr 2019 10:24:14 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id a6sm46239723pfn.181.2019.04.09.10.24.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:14 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Johannes Thumshirn Subject: [PATCH 02/23] watchdog: mena21_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Tue, 9 Apr 2019 10:23:40 -0700 Message-Id: <1554830641-9247-3-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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: Johannes Thumshirn Signed-off-by: Guenter Roeck Reviewed-by: Johannes Thumshirn --- drivers/watchdog/mena21_wdt.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c index 6db69883ece6..e9ca4e0e25dc 100644 --- a/drivers/watchdog/mena21_wdt.c +++ b/drivers/watchdog/mena21_wdt.c @@ -127,19 +127,20 @@ static struct watchdog_device a21_wdt = { static int a21_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct a21_wdt_drv *drv; unsigned int reset = 0; int num_gpios; int ret; int i; - drv = devm_kzalloc(&pdev->dev, sizeof(struct a21_wdt_drv), GFP_KERNEL); + drv = devm_kzalloc(dev, sizeof(struct a21_wdt_drv), GFP_KERNEL); if (!drv) return -ENOMEM; - num_gpios = gpiod_count(&pdev->dev, NULL); + num_gpios = gpiod_count(dev, NULL); if (num_gpios != NUM_GPIOS) { - dev_err(&pdev->dev, "gpios DT property wrong, got %d want %d", + dev_err(dev, "gpios DT property wrong, got %d want %d", num_gpios, NUM_GPIOS); return -ENODEV; } @@ -152,12 +153,9 @@ static int a21_wdt_probe(struct platform_device *pdev) gflags = GPIOD_ASIS; else gflags = GPIOD_IN; - drv->gpios[i] = devm_gpiod_get_index(&pdev->dev, NULL, i, - gflags); - if (IS_ERR(drv->gpios[i])) { - ret = PTR_ERR(drv->gpios[i]); - return ret; - } + drv->gpios[i] = devm_gpiod_get_index(dev, NULL, i, gflags); + if (IS_ERR(drv->gpios[i])) + return PTR_ERR(drv->gpios[i]); gpiod_set_consumer_name(drv->gpios[i], "MEN A21 Watchdog"); @@ -173,10 +171,10 @@ static int a21_wdt_probe(struct platform_device *pdev) } } - watchdog_init_timeout(&a21_wdt, 30, &pdev->dev); + watchdog_init_timeout(&a21_wdt, 30, dev); watchdog_set_nowayout(&a21_wdt, nowayout); watchdog_set_drvdata(&a21_wdt, drv); - a21_wdt.parent = &pdev->dev; + a21_wdt.parent = dev; reset = a21_wdt_get_bootstatus(drv); if (reset == 2) @@ -189,15 +187,15 @@ static int a21_wdt_probe(struct platform_device *pdev) a21_wdt.bootstatus |= WDIOF_EXTERN2; drv->wdt = a21_wdt; - dev_set_drvdata(&pdev->dev, drv); + dev_set_drvdata(dev, drv); - ret = devm_watchdog_register_device(&pdev->dev, &a21_wdt); + ret = devm_watchdog_register_device(dev, &a21_wdt); if (ret) { - dev_err(&pdev->dev, "Cannot register watchdog device\n"); + dev_err(dev, "Cannot register watchdog device\n"); return ret; } - dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n"); + dev_info(dev, "MEN A21 watchdog timer driver enabled\n"); return 0; } From patchwork Tue Apr 9 17:23:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10891881 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 B22E61708 for ; Tue, 9 Apr 2019 17:26:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E91626E4F for ; Tue, 9 Apr 2019 17:26:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 906E528947; Tue, 9 Apr 2019 17:26:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF34126E4F for ; Tue, 9 Apr 2019 17:26:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbfDIRYR (ORCPT ); Tue, 9 Apr 2019 13:24:17 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46072 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726636AbfDIRYQ (ORCPT ); Tue, 9 Apr 2019 13:24:16 -0400 Received: by mail-pg1-f194.google.com with SMTP id y3so9669552pgk.12; Tue, 09 Apr 2019 10:24: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=x4NI7aKQEmDUDGqQdkRAf06VY55NwroheFeIzCPepUQ=; b=UnOq0YDX3I9UMOlMOLvNS2ULRhEgKW7pcqv2y95ITByii3wQ8pU3wf8+/uNvAmfDaO VOM2SvxJT+k185Xp1W9ZOkDoUYeHjoDUkNXtqpCiPyrejV6F0n7b1vw7peDohh/UFPoe 81vRshgsQGL6wFJTqMtn6ComOairMooEUopVEBCCwaSqt6iql3NAnviNOYpOSuSlNzm4 07IQR+iXUY18ldsCr4ZY19DzqurMJuv9vTJv0b6K4bSGiCguncLGsBpxRdUPKWRbMD4I Jc9yWEakMrCCW1lJ9yQG5bVG03iwV3ZF0VMYZ1Vgzrg6lYEPXHJa7fp0soAx1pNkY+Tf cQJA== 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=x4NI7aKQEmDUDGqQdkRAf06VY55NwroheFeIzCPepUQ=; b=ZheYS9dEpfi1OXYh/h7TASBIyU/y46yZmk+hlASDJgnRdClS6nZFm0k+pgevaOpUcn rJ2PSb6Xs/4+8QMeb1nw4eE+QCZCnoSGC1bg81/3cCOJ7akof9agoHPoItdAdEqnI4Rg Uga8ZY2V1lIgk69ldZyaClO5dAZ1BmNdmv8tLqTmKt4QXU4NnhjG9dnbe/OfHnr6TVn7 LKtZunYBIXrubJ+LpiKNw7ZI0d3eIIej9ZcM4SIIkuJWSSFReEuGDSLZsvxukuGxGl4W kd5I3XhHjWCSX2sZRzjAcExUNy/lisP1XIX7Rggd0CEpyDdq3QC0rWOhFfhzwGE/q29u HZxA== X-Gm-Message-State: APjAAAW9YxIoOAgb5P9Cdg2hk0i5LnHlDBUy4jZ4rVjzUPTLfhf/XGzr pIn4xH0I0JsI4CHLdJbEcwI9Xv+V X-Google-Smtp-Source: APXvYqwab62fyJkIdplK9SJ1FoLww3q88qk8OIJO6jRcWdGmsgH2x7dR9I4+Lp37LQLWdJ+pLFSi4Q== X-Received: by 2002:a63:b811:: with SMTP id p17mr35932710pge.219.1554830655878; Tue, 09 Apr 2019 10:24:15 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id z22sm17527816pgv.23.2019.04.09.10.24.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:15 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Andreas Werner Subject: [PATCH 03/23] watchdog: menf21bmc_wdt: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:23:41 -0700 Message-Id: <1554830641-9247-4-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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 Cc: Andreas Werner Signed-off-by: Guenter Roeck --- drivers/watchdog/menf21bmc_wdt.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/drivers/watchdog/menf21bmc_wdt.c b/drivers/watchdog/menf21bmc_wdt.c index 3aefddebb386..b1dbff553cdc 100644 --- a/drivers/watchdog/menf21bmc_wdt.c +++ b/drivers/watchdog/menf21bmc_wdt.c @@ -117,12 +117,12 @@ static const struct watchdog_ops menf21bmc_wdt_ops = { static int menf21bmc_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret, bmc_timeout; struct menf21bmc_wdt *drv_data; - struct i2c_client *i2c_client = to_i2c_client(pdev->dev.parent); + struct i2c_client *i2c_client = to_i2c_client(dev->parent); - drv_data = devm_kzalloc(&pdev->dev, - sizeof(struct menf21bmc_wdt), GFP_KERNEL); + drv_data = devm_kzalloc(dev, sizeof(struct menf21bmc_wdt), GFP_KERNEL); if (!drv_data) return -ENOMEM; @@ -130,7 +130,7 @@ static int menf21bmc_wdt_probe(struct platform_device *pdev) drv_data->wdt.info = &menf21bmc_wdt_info; drv_data->wdt.min_timeout = BMC_WD_TIMEOUT_MIN; drv_data->wdt.max_timeout = BMC_WD_TIMEOUT_MAX; - drv_data->wdt.parent = &pdev->dev; + drv_data->wdt.parent = dev; drv_data->i2c_client = i2c_client; /* @@ -140,40 +140,28 @@ static int menf21bmc_wdt_probe(struct platform_device *pdev) bmc_timeout = i2c_smbus_read_word_data(drv_data->i2c_client, BMC_CMD_WD_TIME); if (bmc_timeout < 0) { - dev_err(&pdev->dev, "failed to get current WDT timeout\n"); + dev_err(dev, "failed to get current WDT timeout\n"); return bmc_timeout; } - watchdog_init_timeout(&drv_data->wdt, bmc_timeout / 10, &pdev->dev); + watchdog_init_timeout(&drv_data->wdt, bmc_timeout / 10, dev); watchdog_set_nowayout(&drv_data->wdt, nowayout); watchdog_set_drvdata(&drv_data->wdt, drv_data); platform_set_drvdata(pdev, drv_data); ret = menf21bmc_wdt_set_bootstatus(drv_data); if (ret < 0) { - dev_err(&pdev->dev, "failed to set Watchdog bootstatus\n"); + dev_err(dev, "failed to set Watchdog bootstatus\n"); return ret; } - ret = watchdog_register_device(&drv_data->wdt); + ret = devm_watchdog_register_device(dev, &drv_data->wdt); if (ret) { - dev_err(&pdev->dev, "failed to register Watchdog device\n"); + dev_err(dev, "failed to register Watchdog device\n"); return ret; } - dev_info(&pdev->dev, "MEN 14F021P00 BMC Watchdog device enabled\n"); - - return 0; -} - -static int menf21bmc_wdt_remove(struct platform_device *pdev) -{ - struct menf21bmc_wdt *drv_data = platform_get_drvdata(pdev); - - dev_warn(&pdev->dev, - "Unregister MEN 14F021P00 BMC Watchdog device, board may reset\n"); - - watchdog_unregister_device(&drv_data->wdt); + dev_info(dev, "MEN 14F021P00 BMC Watchdog device enabled\n"); return 0; } @@ -191,7 +179,6 @@ static struct platform_driver menf21bmc_wdt = { .name = DEVNAME, }, .probe = menf21bmc_wdt_probe, - .remove = menf21bmc_wdt_remove, .shutdown = menf21bmc_wdt_shutdown, }; From patchwork Tue Apr 9 17:23: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: 10891879 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 5B1341800 for ; Tue, 9 Apr 2019 17:26:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48CA926E4F for ; Tue, 9 Apr 2019 17:26:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D31F2893C; Tue, 9 Apr 2019 17:26:32 +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 B666226E4F for ; Tue, 9 Apr 2019 17:26:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbfDIR00 (ORCPT ); Tue, 9 Apr 2019 13:26:26 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37902 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726680AbfDIRYR (ORCPT ); Tue, 9 Apr 2019 13:24:17 -0400 Received: by mail-pl1-f196.google.com with SMTP id f36so5321127plb.5; Tue, 09 Apr 2019 10:24: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=N7pXl0rEiajoRYlmlyCcHrLu1k72W3SQ3h4ZaNh/x7o=; b=tnteAQz1tdJzzwbiVs2GoawFebbqelB4dQlH3F4MJnezM74hZoa9Xu2ooG4FA3ICta UBp1WKLAE+w5mfRVhRUWc/eQ7DFpeHnwk3KDrfHA3wrNvaN1j7HsjVTDrG0nxjTEEebJ GYDL1FFJ52KNEKvHXTHsWQQLeQMIFRdT56BENTSHgL34A2yW0V6Os/GkkfOKuEt23yEW fBDK8woJ1SJn65MOz6R8Nsl0lQ11PUJKkbRnbQ9dJyHSiBBa0+NKtGnVAYFb1X+P/xTS EiRhXIbluHBQhFX5zzGLCM7+Z2m8AaK8WagQjtQYmHctvh72UKI6vkAh8YrDwSBtkaIW DuXg== 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=N7pXl0rEiajoRYlmlyCcHrLu1k72W3SQ3h4ZaNh/x7o=; b=m/L64qry3Z/PfD8mTZOZU+abkNms1d5G1F7vxGu/XYAt4sv1OcRES0U9I2izr7zNb0 EYIh+aLB38k9JVZtBLQCK+Dr7At6V5Mef+lmnc4A5qOssln1338/f0qGcpPIIDkmBhH+ TvNyUzCZr/2uvqhm9+7ozbvwFngQHt2YslUDKSsIwURTggE2wwL7GR/NN1S828XNndl/ uyWHUH7SXD/8xW/7vktkT5XOC9QeEU3IIEwj9s3tF2P2WSxFfbJwxpqp1nukUmn3HytU hzZ3DnoOGb32xYdbfwh5JtAi4gUxhjhfZsAloeWyv7C6p0iM+f3EL4fX31vk+5B/JK1u 9RjQ== X-Gm-Message-State: APjAAAWpLSmiDhTbJRtu9dyGxOfpNhJifLbUQcGTUiK4oYIsot2Z7APU RLq6voH90hIs8Y6Wszu0SN8= X-Google-Smtp-Source: APXvYqzlxQr64knfrR1xhd2KeQOIXl/VzuGHLqSS4vGWT91fbY6ysozucteFE2bwgHBbr27xlCjkJQ== X-Received: by 2002:a17:902:e709:: with SMTP id co9mr38932668plb.86.1554830657206; Tue, 09 Apr 2019 10:24:17 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id n5sm39338725pgp.80.2019.04.09.10.24.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:16 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Kevin Hilman Subject: [PATCH 04/23] watchdog: meson_gxbb_wdt: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:23:42 -0700 Message-Id: <1554830641-9247-5-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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 - Replace shutdown function with call to watchdog_stop_on_reboot() Cc: Kevin Hilman Signed-off-by: Guenter Roeck --- drivers/watchdog/meson_gxbb_wdt.c | 45 +++++++++++++-------------------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c index a8ed75cc9a6e..d17c1a6ed723 100644 --- a/drivers/watchdog/meson_gxbb_wdt.c +++ b/drivers/watchdog/meson_gxbb_wdt.c @@ -136,12 +136,18 @@ static const struct of_device_id meson_gxbb_wdt_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, meson_gxbb_wdt_dt_ids); +static void meson_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int meson_gxbb_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct meson_gxbb_wdt *data; int ret; - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -149,17 +155,21 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev) if (IS_ERR(data->reg_base)) return PTR_ERR(data->reg_base); - data->clk = devm_clk_get(&pdev->dev, NULL); + data->clk = devm_clk_get(dev, NULL); if (IS_ERR(data->clk)) return PTR_ERR(data->clk); ret = clk_prepare_enable(data->clk); if (ret) return ret; + ret = devm_add_action_or_reset(dev, meson_clk_disable_unprepare, + data->clk); + if (ret) + return ret; platform_set_drvdata(pdev, data); - data->wdt_dev.parent = &pdev->dev; + data->wdt_dev.parent = dev; data->wdt_dev.info = &meson_gxbb_wdt_info; data->wdt_dev.ops = &meson_gxbb_wdt_ops; data->wdt_dev.max_hw_heartbeat_ms = GXBB_WDT_TCNT_SETUP_MASK; @@ -176,37 +186,12 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev) meson_gxbb_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout); - ret = watchdog_register_device(&data->wdt_dev); - if (ret) { - clk_disable_unprepare(data->clk); - return ret; - } - - return 0; -} - -static int meson_gxbb_wdt_remove(struct platform_device *pdev) -{ - struct meson_gxbb_wdt *data = platform_get_drvdata(pdev); - - watchdog_unregister_device(&data->wdt_dev); - - clk_disable_unprepare(data->clk); - - return 0; -} - -static void meson_gxbb_wdt_shutdown(struct platform_device *pdev) -{ - struct meson_gxbb_wdt *data = platform_get_drvdata(pdev); - - meson_gxbb_wdt_stop(&data->wdt_dev); + watchdog_stop_on_reboot(&data->wdt_dev); + return devm_watchdog_register_device(dev, &data->wdt_dev); } static struct platform_driver meson_gxbb_wdt_driver = { .probe = meson_gxbb_wdt_probe, - .remove = meson_gxbb_wdt_remove, - .shutdown = meson_gxbb_wdt_shutdown, .driver = { .name = "meson-gxbb-wdt", .pm = &meson_gxbb_wdt_pm_ops, From patchwork Tue Apr 9 17:23: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: 10891833 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 83B741800 for ; Tue, 9 Apr 2019 17:24:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71D2328942 for ; Tue, 9 Apr 2019 17:24:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65B5228948; Tue, 9 Apr 2019 17:24:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDBD828944 for ; Tue, 9 Apr 2019 17:24:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726702AbfDIRYW (ORCPT ); Tue, 9 Apr 2019 13:24:22 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44345 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726691AbfDIRYT (ORCPT ); Tue, 9 Apr 2019 13:24:19 -0400 Received: by mail-pf1-f193.google.com with SMTP id y13so10094842pfm.11; Tue, 09 Apr 2019 10:24: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=YlBMQHRRMhSGuQhnSlFbWv+llB56GpesX1o6ChIhKxU=; b=SuyKz2LIVhEGOGyvfhvaUadmHhrM7ZmrNkdyPGDHc3n0iNnXeXR98eWmg51PgWiTM/ /pTTMUCYsFulAXgGdRNFaAERml9yTaH5ud8UywW4DWXGLVifidthNk8DBwnxfT6wzXBB YD742r7C/N8skol38qrBrRhPTdfTFbHf6S0/L/+yTtqx2LFPcwfa++YbTZTcbNghCtOY 4emS23u1wOtU1i8uh/+gfI0GNrvMLJQj0KFtfmkaCP3ITpETkakbWVNLNTo5C56NhEQG mUVmWb78rnJgW74rtgYgGevftCW6hicPmMdbjjOuUbp53yIUWifGOOnvW/KQOY4utksS Y2Sw== 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=YlBMQHRRMhSGuQhnSlFbWv+llB56GpesX1o6ChIhKxU=; b=F0XlbSazSntQL4tgLfnD290p7EULseR4KcrQO5cjM05IPaM4C6PRKC7onJaOjiGDwM R95Zed9U1/89X9+7I1FilWg5OGe9LuN0KIYv2z0cSl2NyWToS0VHIXndwLlXqvkvXtJT 5gJHzAbMeH/vLNkxZvf8Ozwrqlg0hFch3pG3l3NmOv97wdt5Zdi9anFwcTPNZA+5pW08 Cyb0pW8Q6U/YK6eTyZZ4GQ+tUuooc9gPBCWEMSCzlqWy67g8PW2ss2pHGyAeh0Uz18Bi IVUYa4Rc1t8vwdVE4YNQiMFfXfnTB4d7M4PBGpPwJpujJlrSXvnDNTptNvVnn2bzhy5p WgGQ== X-Gm-Message-State: APjAAAV5bzRy1QXB5GhqJdAzoKvDPP/446Z8A1vKhBMZpeun6SeOcC72 Rbm88KO19lJ978FStIta9j0= X-Google-Smtp-Source: APXvYqx9Jsyrx5f90R2F39FekzKGJeQYtN2TqtqbIC9lm5866gmWcyDOFs5lfj4i0Zqp4D1QCreKbA== X-Received: by 2002:a63:2747:: with SMTP id n68mr36008288pgn.317.1554830658622; Tue, 09 Apr 2019 10:24:18 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id g10sm15915554pgq.54.2019.04.09.10.24.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:18 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Kevin Hilman Subject: [PATCH 05/23] watchdog: meson_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Tue, 9 Apr 2019 10:23:43 -0700 Message-Id: <1554830641-9247-6-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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: Kevin Hilman Signed-off-by: Guenter Roeck --- drivers/watchdog/meson_wdt.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/meson_wdt.c b/drivers/watchdog/meson_wdt.c index 7fc6acb33c7f..01889cef81e1 100644 --- a/drivers/watchdog/meson_wdt.c +++ b/drivers/watchdog/meson_wdt.c @@ -164,11 +164,12 @@ MODULE_DEVICE_TABLE(of, meson_wdt_dt_ids); static int meson_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct meson_wdt_dev *meson_wdt; const struct of_device_id *of_id; int err; - meson_wdt = devm_kzalloc(&pdev->dev, sizeof(*meson_wdt), GFP_KERNEL); + meson_wdt = devm_kzalloc(dev, sizeof(*meson_wdt), GFP_KERNEL); if (!meson_wdt) return -ENOMEM; @@ -176,14 +177,14 @@ static int meson_wdt_probe(struct platform_device *pdev) if (IS_ERR(meson_wdt->wdt_base)) return PTR_ERR(meson_wdt->wdt_base); - of_id = of_match_device(meson_wdt_dt_ids, &pdev->dev); + of_id = of_match_device(meson_wdt_dt_ids, dev); if (!of_id) { - dev_err(&pdev->dev, "Unable to initialize WDT data\n"); + dev_err(dev, "Unable to initialize WDT data\n"); return -ENODEV; } meson_wdt->data = of_id->data; - meson_wdt->wdt_dev.parent = &pdev->dev; + meson_wdt->wdt_dev.parent = dev; meson_wdt->wdt_dev.info = &meson_wdt_info; meson_wdt->wdt_dev.ops = &meson_wdt_ops; meson_wdt->wdt_dev.max_timeout = @@ -195,18 +196,18 @@ static int meson_wdt_probe(struct platform_device *pdev) watchdog_set_drvdata(&meson_wdt->wdt_dev, meson_wdt); - watchdog_init_timeout(&meson_wdt->wdt_dev, timeout, &pdev->dev); + watchdog_init_timeout(&meson_wdt->wdt_dev, timeout, dev); watchdog_set_nowayout(&meson_wdt->wdt_dev, nowayout); watchdog_set_restart_priority(&meson_wdt->wdt_dev, 128); meson_wdt_stop(&meson_wdt->wdt_dev); watchdog_stop_on_reboot(&meson_wdt->wdt_dev); - err = devm_watchdog_register_device(&pdev->dev, &meson_wdt->wdt_dev); + err = devm_watchdog_register_device(dev, &meson_wdt->wdt_dev); if (err) return err; - dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)", + dev_info(dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)", meson_wdt->wdt_dev.timeout, nowayout); return 0; From patchwork Tue Apr 9 17:23: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: 10891831 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 555FB1708 for ; Tue, 9 Apr 2019 17:24:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44AC028942 for ; Tue, 9 Apr 2019 17:24:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3964A2894C; Tue, 9 Apr 2019 17:24:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9DB728942 for ; Tue, 9 Apr 2019 17:24:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726636AbfDIRYV (ORCPT ); Tue, 9 Apr 2019 13:24:21 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35594 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726556AbfDIRYU (ORCPT ); Tue, 9 Apr 2019 13:24:20 -0400 Received: by mail-pf1-f196.google.com with SMTP id t21so7796636pfh.2; Tue, 09 Apr 2019 10:24: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=BTbLDR4gnZ7lFPmSCCa0QIInTL3LtlTlBWa9cvu84sM=; b=NgO5WhP0ViQOQ67MmOnc7P+BOFX3ODs7bfwlSYsjIjsI5fLs7fClX2BQb9B74V9V2r B2+0DNQz7+Sd2ACrzYmYPZh9jkuOZrdQ4ViO4Vxbk8c6z6MsXk3hKxD2dT0b5DBFKKdt h1j43GRpUvri0iiGPK0zp3Q66FvPqEpIPrxTHWg4p9JLdMwBe2p66s1w2QYi+0iYTpFY vMw9ltLbGBH03rQ4f/Y8N+vl3m2LHycYqUzyn6qDVbQCDAj3LyizmZD2sXc5YG5pbCcL HsORUjjWHifwHn1sFQxQc/ZS+gZi3fSzJlsOVefy+sl94Is0Pui2LxnthGmws+9HDekX IQtQ== 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=BTbLDR4gnZ7lFPmSCCa0QIInTL3LtlTlBWa9cvu84sM=; b=f8n97yX9F5l1UkKvzJ06Dcf7ImjaqJuv12yQuxnWluGgZxzg9ENY81wuntcA6tuK3S a8T1EjHAJeNx64g9PNEGriIpqa5nFJxILU4lIffA2yusYXuzcBYz3S6kA5gVKB0Q1L1L bj6lo5mW3+6lwy4WEf2Dbmkt9mu18/c9sTFSGZg46+Hwe0y/Y96uC1obQBw3h4HUDBDd 5xuK2IjkwNVMmQ5y6GiVS4G4rZWnJw4dhfCPgETCHS3C+up7dbO3dZHZeTEzi3huLRn5 IqEGrIGtjwz37TjHrNn1gzMJX/8sCaHh7g09qaxJ+je5s5apzguKx/u9CAU2O8c2Nzw5 ptLg== X-Gm-Message-State: APjAAAU3WnpFqGncExh5cCPulc5wMqzzo3zDUQRlZVZCr75REeousi6B OSGHpyh6+8Bxt+k3oC3TF+M= X-Google-Smtp-Source: APXvYqyZbGEfHz99IbERUPIpeCYQUuPgVmJryMgmJIIz/W2Vu7ABU/1nqFf6vzsqsu0Q0MAQGbGecA== X-Received: by 2002:a63:2f44:: with SMTP id v65mr35494829pgv.141.1554830660198; Tue, 09 Apr 2019 10:24:20 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 4sm45069219pfn.159.2019.04.09.10.24.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24: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 06/23] watchdog: mlx_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Tue, 9 Apr 2019 10:23:44 -0700 Message-Id: <1554830641-9247-7-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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/mlx_wdt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/mlx_wdt.c b/drivers/watchdog/mlx_wdt.c index 70c2cbf9c993..03b9ac4b99af 100644 --- a/drivers/watchdog/mlx_wdt.c +++ b/drivers/watchdog/mlx_wdt.c @@ -233,20 +233,21 @@ static int mlxreg_wdt_init_timeout(struct mlxreg_wdt *wdt, static int mlxreg_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct mlxreg_core_platform_data *pdata; struct mlxreg_wdt *wdt; int rc; - pdata = dev_get_platdata(&pdev->dev); + pdata = dev_get_platdata(dev); if (!pdata) { - dev_err(&pdev->dev, "Failed to get platform data.\n"); + dev_err(dev, "Failed to get platform data.\n"); return -EINVAL; } - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; - wdt->wdd.parent = &pdev->dev; + wdt->wdd.parent = dev; wdt->regmap = pdata->regmap; mlxreg_wdt_config(wdt, pdata); @@ -266,12 +267,11 @@ static int mlxreg_wdt_probe(struct platform_device *pdev) set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); } mlxreg_wdt_check_card_reset(wdt); - rc = devm_watchdog_register_device(&pdev->dev, &wdt->wdd); + rc = devm_watchdog_register_device(dev, &wdt->wdd); register_error: if (rc) - dev_err(&pdev->dev, - "Cannot register watchdog device (err=%d)\n", rc); + dev_err(dev, "Cannot register watchdog device (err=%d)\n", rc); return rc; } From patchwork Tue Apr 9 17:23: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: 10891865 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 9BBFE1800 for ; Tue, 9 Apr 2019 17:26:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A74A26E4F for ; Tue, 9 Apr 2019 17:26:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7ED0F28553; Tue, 9 Apr 2019 17:26:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D7942839C for ; Tue, 9 Apr 2019 17:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726713AbfDIRYY (ORCPT ); Tue, 9 Apr 2019 13:24:24 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45014 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726701AbfDIRYW (ORCPT ); Tue, 9 Apr 2019 13:24:22 -0400 Received: by mail-pg1-f194.google.com with SMTP id i2so9669728pgj.11; Tue, 09 Apr 2019 10:24: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=JZEYa3ly8OHfRyblvnsc1Mq4A63GITyn9+eW6LRG6T8=; b=a2hfqMMqsMQkahqYCKaeGT1+SqfxIyR5b7acDrrjM+SxM+Y+2hjgqElVnXF+AdSLF4 dBhCA0hjY7/vFb7cjjr2SCIK6q4Mzu9y7Fu2aU4Hh/UlHWMR0a/LugrJ9TIO115DVGHn kSX8yr1ph+nRWwmAwHqD5pgHaniE9S+evn/vpJliw7hEhQGQQ+7pKWHTScWo6m4fMTOS 5SyYAA5+0ycXfAOdjO3+bRpin3pM82FJMmN+mmHs9olPS9pBSI5jp2bGacwpetitgXw5 5UoYI0dtsH78MxYRVSdSALv/U/BQO0kdZpd1qOx2rDA9tXmCR3jgYTWfHxtmZdKkLSRv VvbQ== 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=JZEYa3ly8OHfRyblvnsc1Mq4A63GITyn9+eW6LRG6T8=; b=jzgLI6C7E7H2wPz/2i/ETCeV+JRRRnS1iuiRs7bYuLH7WAgx09B7dywWogj1s/p+ql ibUrBwXkM+8AjcpTRefwXYVAisB4UxBnv1D9INZ06dmfED0IZlHWSfLyb9ORlyEK0obD 8kCLPuvfEGRX6366iuCSXqvM416ez5/OZa5iKVXF7uComOP3VclcFGgJL87y06qW3PfJ q1684LC+x6Q0la9ClCE1qany1D6FKUimRG0WeT7byUt+Z6it1wXJihg+KuOGcgWQ+Ybz UnSS/dwtQXaxyExZGy7pnrPjY9swxsUY6czclU8hIjOQFVRXYw5ZRuxp3CEI/BR2A/25 M7kA== X-Gm-Message-State: APjAAAWW5/r05mg6N6jImc0Gb4ei3RXxL7eK7N+cvfTnQ0foF5TSZk9N sQ6dLGlU2F47JQjJzgdTyYY= X-Google-Smtp-Source: APXvYqw7WFvTSSxwx0Vw8QBSB/a/O41O6ttJyXFXT+MMs+zyX3WsUQ782Hwa80CNoI68FOdQtx3xvA== X-Received: by 2002:a63:1548:: with SMTP id 8mr33492294pgv.277.1554830661645; Tue, 09 Apr 2019 10:24:21 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id n22sm38977234pfa.51.2019.04.09.10.24.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:21 -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/23] watchdog: moxart_wdt: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:23:45 -0700 Message-Id: <1554830641-9247-8-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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 - Replace 'of_clk_get(np, 0)' with 'devm_clk_get(dev, NULL)' - Use local variable 'struct device *dev' consistently - Replace stop on remove with call to watchdog_stop_on_unregister() - Use devm_watchdog_register_driver() to register watchdog device Signed-off-by: Guenter Roeck --- drivers/watchdog/moxart_wdt.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/watchdog/moxart_wdt.c b/drivers/watchdog/moxart_wdt.c index 740215a247fc..6340a1f5f471 100644 --- a/drivers/watchdog/moxart_wdt.c +++ b/drivers/watchdog/moxart_wdt.c @@ -91,7 +91,6 @@ static int moxart_wdt_probe(struct platform_device *pdev) { struct moxart_wdt_dev *moxart_wdt; struct device *dev = &pdev->dev; - struct device_node *node = dev->of_node; struct clk *clk; int err; unsigned int max_timeout; @@ -107,7 +106,7 @@ static int moxart_wdt_probe(struct platform_device *pdev) if (IS_ERR(moxart_wdt->base)) return PTR_ERR(moxart_wdt->base); - clk = of_clk_get(node, 0); + clk = devm_clk_get(dev, NULL); if (IS_ERR(clk)) { pr_err("%s: of_clk_get failed\n", __func__); return PTR_ERR(clk); @@ -134,7 +133,8 @@ static int moxart_wdt_probe(struct platform_device *pdev) watchdog_set_drvdata(&moxart_wdt->dev, moxart_wdt); - err = watchdog_register_device(&moxart_wdt->dev); + watchdog_stop_on_unregister(&moxart_wdt->dev); + err = devm_watchdog_register_device(dev, &moxart_wdt->dev); if (err) return err; @@ -144,15 +144,6 @@ static int moxart_wdt_probe(struct platform_device *pdev) return 0; } -static int moxart_wdt_remove(struct platform_device *pdev) -{ - struct moxart_wdt_dev *moxart_wdt = platform_get_drvdata(pdev); - - moxart_wdt_stop(&moxart_wdt->dev); - - return 0; -} - static const struct of_device_id moxart_watchdog_match[] = { { .compatible = "moxa,moxart-watchdog" }, { }, @@ -161,7 +152,6 @@ MODULE_DEVICE_TABLE(of, moxart_watchdog_match); static struct platform_driver moxart_wdt_driver = { .probe = moxart_wdt_probe, - .remove = moxart_wdt_remove, .driver = { .name = "moxart-watchdog", .of_match_table = moxart_watchdog_match, From patchwork Tue Apr 9 17:23: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: 10891863 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 6A1411515 for ; Tue, 9 Apr 2019 17:26:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5678E26E4F for ; Tue, 9 Apr 2019 17:26:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AC6D28947; Tue, 9 Apr 2019 17:26:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D718E26E4F for ; Tue, 9 Apr 2019 17:26:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726720AbfDIRYZ (ORCPT ); Tue, 9 Apr 2019 13:24:25 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37295 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726709AbfDIRYX (ORCPT ); Tue, 9 Apr 2019 13:24:23 -0400 Received: by mail-pg1-f196.google.com with SMTP id e6so9686844pgc.4; Tue, 09 Apr 2019 10:24: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=wCXHrOsWqXSwK8IC/YC+rDt+Fx5DNdMSraig28kMeIs=; b=mpwxrvubsnHrRUQtwmvZrNHCNi7Q/q1+vHEdRG/TriC9+JvoBUwhaM6IEHDoKRrEuV S+71QQoSHQwUH+TJRh3Cq5BJf3fUfMlmnzWzFjxMdhvSemuA3g81R5FOq6ceNTozTJol hV0JsMj0MxAhV+NyY7di3Y9cSTXeqHnpCEWInRs23MJ6Zjq1CtrQi+98x79Zt9T27934 maj70O6yRjKfjnkDhCAosJpYIDmSdllc7gpsbWbbiBpgcOzxs1gkOiG280EdmyxHSqgm kaO+n9+RZL0QpfiDlk3PewK8unON20eM5V8MbvShTGJ2UfbtQya6/Z6GlXh+H744Qq3g 8KcQ== 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=wCXHrOsWqXSwK8IC/YC+rDt+Fx5DNdMSraig28kMeIs=; b=aZC3Gv+kFCoyU/uhKuV6XV5dl0U3s7xiLowbzKROUkh8PkA4soKPTFVztfghjfMMP/ Cb/GdpS9tjspNOZZWWdKq5fefFsdbzF5wTt76ipImu0P5udih/JKU/qvkLFpZiRlJjQF GM0TiDl4QmkQkdy7P0wuOxoO0MDUfjN9M62+bZOq2ad2p6CiOUGSljvddhPLD4k0MUmn wy6JX0ZQkcQ1P8FkaC0i02UGDo1vSBTWuQPb1pJembPAoSQG7H8kmxxv9K6GL40aXe1G NMIBnEaRCQD297zrpFdjvawgxAeVQ26eCJsGdcKC6ezcwYhhN9r70FT7zMgV/hFzPhOP qMvA== X-Gm-Message-State: APjAAAU/0PgThSZZDCGqCFMqyciuMT/8EEdkkwTcLRHYGAAvflQI35Ki BChJPoa/HLbArOsamif92M4= X-Google-Smtp-Source: APXvYqx7DrLyrMimYHWjerCF4nTRqpMoTuqxLhS2qiGsz+sSBX7rHt5y0STqMuiVIIFME2lx9p31VQ== X-Received: by 2002:a65:6259:: with SMTP id q25mr35969443pgv.103.1554830662973; Tue, 09 Apr 2019 10:24:22 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id q75sm7345068pfi.102.2019.04.09.10.24.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:22 -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 08/23] watchdog: mtk_wdt: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:23:46 -0700 Message-Id: <1554830641-9247-9-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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 - Replace shutdown function with call to watchdog_stop_on_reboot() Cc: Matthias Brugger Signed-off-by: Guenter Roeck --- drivers/watchdog/mtk_wdt.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c index 113a48d54058..9c3d0033260d 100644 --- a/drivers/watchdog/mtk_wdt.c +++ b/drivers/watchdog/mtk_wdt.c @@ -153,10 +153,11 @@ static const struct watchdog_ops mtk_wdt_ops = { static int mtk_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct mtk_wdt_dev *mtk_wdt; int err; - mtk_wdt = devm_kzalloc(&pdev->dev, sizeof(*mtk_wdt), GFP_KERNEL); + mtk_wdt = devm_kzalloc(dev, sizeof(*mtk_wdt), GFP_KERNEL); if (!mtk_wdt) return -ENOMEM; @@ -171,9 +172,9 @@ static int mtk_wdt_probe(struct platform_device *pdev) mtk_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT; mtk_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT; mtk_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT; - mtk_wdt->wdt_dev.parent = &pdev->dev; + mtk_wdt->wdt_dev.parent = dev; - watchdog_init_timeout(&mtk_wdt->wdt_dev, timeout, &pdev->dev); + watchdog_init_timeout(&mtk_wdt->wdt_dev, timeout, dev); watchdog_set_nowayout(&mtk_wdt->wdt_dev, nowayout); watchdog_set_restart_priority(&mtk_wdt->wdt_dev, 128); @@ -181,29 +182,13 @@ static int mtk_wdt_probe(struct platform_device *pdev) mtk_wdt_stop(&mtk_wdt->wdt_dev); - err = watchdog_register_device(&mtk_wdt->wdt_dev); + watchdog_stop_on_reboot(&mtk_wdt->wdt_dev); + err = devm_watchdog_register_device(dev, &mtk_wdt->wdt_dev); if (unlikely(err)) return err; - dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)\n", - mtk_wdt->wdt_dev.timeout, nowayout); - - return 0; -} - -static void mtk_wdt_shutdown(struct platform_device *pdev) -{ - struct mtk_wdt_dev *mtk_wdt = platform_get_drvdata(pdev); - - if (watchdog_active(&mtk_wdt->wdt_dev)) - mtk_wdt_stop(&mtk_wdt->wdt_dev); -} - -static int mtk_wdt_remove(struct platform_device *pdev) -{ - struct mtk_wdt_dev *mtk_wdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(&mtk_wdt->wdt_dev); + dev_info(dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)\n", + mtk_wdt->wdt_dev.timeout, nowayout); return 0; } @@ -245,8 +230,6 @@ static const struct dev_pm_ops mtk_wdt_pm_ops = { static struct platform_driver mtk_wdt_driver = { .probe = mtk_wdt_probe, - .remove = mtk_wdt_remove, - .shutdown = mtk_wdt_shutdown, .driver = { .name = DRV_NAME, .pm = &mtk_wdt_pm_ops, From patchwork Tue Apr 9 17:23: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: 10891875 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 9651A1515 for ; Tue, 9 Apr 2019 17:26:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84D2A26E4F for ; Tue, 9 Apr 2019 17:26:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78E1E2893C; Tue, 9 Apr 2019 17:26:25 +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 233A026E4F for ; Tue, 9 Apr 2019 17:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726712AbfDIR0C (ORCPT ); Tue, 9 Apr 2019 13:26:02 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35539 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726716AbfDIRYZ (ORCPT ); Tue, 9 Apr 2019 13:24:25 -0400 Received: by mail-pg1-f195.google.com with SMTP id g8so9691795pgf.2; Tue, 09 Apr 2019 10:24:24 -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=dA8ux7CA/LyMnGAXtd3Ndhtk0tgOsCy2XAsz0prAjfA=; b=rwigojSrciJTV/G4AhGIyZE/zGC0vTvm0oHtK80B+/AWfTxZq0vnfQLu40ZwuosqNw lSf0em1eNLLpR9HIBB0nJg4EbbhOd5m6TKudxM7SLZ+fc0+lfJ1MgGwACLv2PWHfI2/2 NfPyRgH0QdOdc62aAaymI1cWJ2nTyaKktEcdw9posh3HXO8M18Tnf0+ZmE5pbVAXgBel YfNFIXbPZBXbXX25glxLFuOeexdRUheAZG6bHGdLa/scUxripKNNg1pL5bei2+pPzD5p 5Dwdtga9JtKwN50zEvAwaRQ1VZ9TLH3Bwmb51Q2gZ+syTVD40qXpliUWXXGWFWhGMuiD fQ6w== 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=dA8ux7CA/LyMnGAXtd3Ndhtk0tgOsCy2XAsz0prAjfA=; b=GidFsI8juWMgxYMLTb/nNRNRC34xXg6QpaJFcXeTDBQ2n4MJpBGek2+kOKnpSbCKtS G9P6LTG9W87MtFlhqUhpqVkXOA+Q/CkI3hC0GY1n8KRLQuOdKPGSwaF5BDdzAlhuFwZ+ 0SI1gk5ykk0pE3G1pzvaaAryeG/hQoKS9wbA8f06P7MwQ/37Ky5FdXRxvS9n8GM1ue3K ZLESUIVBEGk8w4LlTp+1nsrrd5FjbgP1E0efO4zPm6Qt+4n3JeSnwHHzjZJG52UylKqU 53HC6jFEKygkHPVK4i/SFlZTNsc4v6SgJcKWhnjQL6/XDMyY3eeb9HU3Ch6GRG8hYzyf 90bQ== X-Gm-Message-State: APjAAAW1eOHv/f6VdrM491pA/GI4ch0coUSY+anRFzT9+JY3BvloGftf sNwjP+MX/FYWHGpFx6sbdRU= X-Google-Smtp-Source: APXvYqyN/O2WIhyqI5qpK22XZuq8UyH5OjZJjQBdiUjHCdk0fUHfY7CEjsMxQkDMsZ7lArIBxu/QZQ== X-Received: by 2002:a62:1795:: with SMTP id 143mr38608394pfx.104.1554830664327; Tue, 09 Apr 2019 10:24:24 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h16sm10564900pgj.85.2019.04.09.10.24.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:23 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Avi Fishman , Tomer Maimon , Patrick Venture , Nancy Yuen , Brendan Higgins Subject: [PATCH 09/23] watchdog: npcm_wdt: Use local variable 'dev' consistently Date: Tue, 9 Apr 2019 10:23:47 -0700 Message-Id: <1554830641-9247-10-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use local variable 'struct device *dev' consistently. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches Cc: Avi Fishman Cc: Tomer Maimon Cc: Patrick Venture Cc: Nancy Yuen Cc: Brendan Higgins Signed-off-by: Guenter Roeck --- drivers/watchdog/npcm_wdt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c index 4fce10c145c2..9d6c1689b12c 100644 --- a/drivers/watchdog/npcm_wdt.c +++ b/drivers/watchdog/npcm_wdt.c @@ -184,7 +184,7 @@ static int npcm_wdt_probe(struct platform_device *pdev) int irq; int ret; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -214,8 +214,8 @@ static int npcm_wdt_probe(struct platform_device *pdev) set_bit(WDOG_HW_RUNNING, &wdt->wdd.status); } - ret = devm_request_irq(dev, irq, npcm_wdt_interrupt, 0, - "watchdog", wdt); + ret = devm_request_irq(dev, irq, npcm_wdt_interrupt, 0, "watchdog", + wdt); if (ret) return ret; From patchwork Tue Apr 9 17:23: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: 10891861 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 53A471515 for ; Tue, 9 Apr 2019 17:26:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41B1726E4F for ; Tue, 9 Apr 2019 17:26:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35FFB28553; Tue, 9 Apr 2019 17:26:00 +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 9D9DA26E4F for ; Tue, 9 Apr 2019 17:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726742AbfDIRY1 (ORCPT ); Tue, 9 Apr 2019 13:24:27 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:37767 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726733AbfDIRY0 (ORCPT ); Tue, 9 Apr 2019 13:24:26 -0400 Received: by mail-pl1-f194.google.com with SMTP id w23so9810672ply.4; Tue, 09 Apr 2019 10:24: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=H6MIpn01nQGgr4gWV6XiOub4WhlBGRZ9EDKqwwULRjo=; b=GIuUgu3cjFcOhhqpXuc7V9A1832EcFD0n0OCIFv+TP1czEW8TsW5Q2hgWsJH4QN+Xp jiVUwFs822SoFfEIL/pLConMdFxPfBlVs36jDGZEx/V3GYjNJ8zVxjqzYSNSox+gz1bY CGzOQkgR2UZS43ktNnV/iYmOIz4tlwLUZ0mCMmU+4yRgs/fYJpAyvzQ2+2URQsrW1TJT UySI/LFD4D+Nia79Rh/QnpELU+U5v/a5u4Wn8VQqzeMuCVBVmCfigm3QfTd9sc5Onpeh G0D2DbnseWJtKVRXh9EQdJBaHfwLqehqJgtj5+++KHTQX5uGZgrDWPIWgOdTy028kxaV NFog== 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=H6MIpn01nQGgr4gWV6XiOub4WhlBGRZ9EDKqwwULRjo=; b=N49mgYiXcenRhTOLbSXbRGdURxzWnIkrVwVJCG68Hg1gSGowoMpLBisLGafMSTn8CT D0kIeZyYRyeIwuF1sehsn8nXN2OHPsI8HG2GuaD3ul2lHxCXzQv0W2ZAeAQbc7uce9MT SZNtIh0qVFfmeXE1PDs6lk8FX2Ev4xqwvljwHbvcXFtIeJnkYal85qeg87qLKj+//Ygf mycdREiazKSIyiQf3cimvx3qcKXZJPgA8cCG+Knzt6Aixg/ZT+URh+W2fOzYquGFSxMT fk6C59EMl/Hcq96cHQ2oRDbCPiPPw6UVMicafEnJM+cLNj5JQvz23ikASibknLxg/DOj D88g== X-Gm-Message-State: APjAAAXXNJDND1zZzdLHoweqFPv+xrw1E99nKs6KkP6AEDN3r8AIQLlr /6CiG6XyAJoJz3xIfW9pYDk= X-Google-Smtp-Source: APXvYqyNhRqiUe2Su255D2H++loLO0HocAMUANlsuwl1T0LaE7KWsE6DnNLODwF0hRzc+kTmQ6ZRyA== X-Received: by 2002:a17:902:e90b:: with SMTP id cs11mr31531975plb.243.1554830665725; Tue, 09 Apr 2019 10:24:25 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id o81sm29860950pfa.156.2019.04.09.10.24.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:25 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Michal Simek Subject: [PATCH 10/23] watchdog: of_xilinx_wdt: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:23:48 -0700 Message-Id: <1554830641-9247-11-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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: Michal Simek Signed-off-by: Guenter Roeck Acked-by: Michal Simek --- drivers/watchdog/of_xilinx_wdt.c | 58 ++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c index 5c977164b3e5..03786992b701 100644 --- a/drivers/watchdog/of_xilinx_wdt.c +++ b/drivers/watchdog/of_xilinx_wdt.c @@ -151,41 +151,46 @@ static u32 xwdt_selftest(struct xwdt_device *xdev) return XWT_TIMER_FAILED; } +static void xwdt_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int xwdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int rc; u32 pfreq = 0, enable_once = 0; struct xwdt_device *xdev; struct watchdog_device *xilinx_wdt_wdd; - xdev = devm_kzalloc(&pdev->dev, sizeof(*xdev), GFP_KERNEL); + xdev = devm_kzalloc(dev, sizeof(*xdev), GFP_KERNEL); if (!xdev) return -ENOMEM; xilinx_wdt_wdd = &xdev->xilinx_wdt_wdd; xilinx_wdt_wdd->info = &xilinx_wdt_ident; xilinx_wdt_wdd->ops = &xilinx_wdt_ops; - xilinx_wdt_wdd->parent = &pdev->dev; + xilinx_wdt_wdd->parent = dev; xdev->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(xdev->base)) return PTR_ERR(xdev->base); - rc = of_property_read_u32(pdev->dev.of_node, "xlnx,wdt-interval", + rc = of_property_read_u32(dev->of_node, "xlnx,wdt-interval", &xdev->wdt_interval); if (rc) - dev_warn(&pdev->dev, - "Parameter \"xlnx,wdt-interval\" not found\n"); + dev_warn(dev, "Parameter \"xlnx,wdt-interval\" not found\n"); - rc = of_property_read_u32(pdev->dev.of_node, "xlnx,wdt-enable-once", + rc = of_property_read_u32(dev->of_node, "xlnx,wdt-enable-once", &enable_once); if (rc) - dev_warn(&pdev->dev, + dev_warn(dev, "Parameter \"xlnx,wdt-enable-once\" not found\n"); watchdog_set_nowayout(xilinx_wdt_wdd, enable_once); - xdev->clk = devm_clk_get(&pdev->dev, NULL); + xdev->clk = devm_clk_get(dev, NULL); if (IS_ERR(xdev->clk)) { if (PTR_ERR(xdev->clk) != -ENOENT) return PTR_ERR(xdev->clk); @@ -196,10 +201,10 @@ static int xwdt_probe(struct platform_device *pdev) */ xdev->clk = NULL; - rc = of_property_read_u32(pdev->dev.of_node, "clock-frequency", + rc = of_property_read_u32(dev->of_node, "clock-frequency", &pfreq); if (rc) - dev_warn(&pdev->dev, + dev_warn(dev, "The watchdog clock freq cannot be obtained\n"); } else { pfreq = clk_get_rate(xdev->clk); @@ -218,44 +223,34 @@ static int xwdt_probe(struct platform_device *pdev) rc = clk_prepare_enable(xdev->clk); if (rc) { - dev_err(&pdev->dev, "unable to enable clock\n"); + dev_err(dev, "unable to enable clock\n"); return rc; } + rc = devm_add_action_or_reset(dev, xwdt_clk_disable_unprepare, + xdev->clk); + if (rc) + return rc; rc = xwdt_selftest(xdev); if (rc == XWT_TIMER_FAILED) { - dev_err(&pdev->dev, "SelfTest routine error\n"); - goto err_clk_disable; + dev_err(dev, "SelfTest routine error\n"); + return rc; } - rc = watchdog_register_device(xilinx_wdt_wdd); + rc = devm_watchdog_register_device(dev, xilinx_wdt_wdd); if (rc) { - dev_err(&pdev->dev, "Cannot register watchdog (err=%d)\n", rc); - goto err_clk_disable; + dev_err(dev, "Cannot register watchdog (err=%d)\n", rc); + return rc; } clk_disable(xdev->clk); - dev_info(&pdev->dev, "Xilinx Watchdog Timer at %p with timeout %ds\n", + dev_info(dev, "Xilinx Watchdog Timer at %p with timeout %ds\n", xdev->base, xilinx_wdt_wdd->timeout); platform_set_drvdata(pdev, xdev); return 0; -err_clk_disable: - clk_disable_unprepare(xdev->clk); - - return rc; -} - -static int xwdt_remove(struct platform_device *pdev) -{ - struct xwdt_device *xdev = platform_get_drvdata(pdev); - - watchdog_unregister_device(&xdev->xilinx_wdt_wdd); - clk_disable_unprepare(xdev->clk); - - return 0; } /** @@ -303,7 +298,6 @@ MODULE_DEVICE_TABLE(of, xwdt_of_match); static struct platform_driver xwdt_driver = { .probe = xwdt_probe, - .remove = xwdt_remove, .driver = { .name = WATCHDOG_NAME, .of_match_table = xwdt_of_match, From patchwork Tue Apr 9 17:23: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: 10891835 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 0BCA91515 for ; Tue, 9 Apr 2019 17:24:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECEB328942 for ; Tue, 9 Apr 2019 17:24:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E035428948; Tue, 9 Apr 2019 17:24: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 5C9D328942 for ; Tue, 9 Apr 2019 17:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726755AbfDIRY2 (ORCPT ); Tue, 9 Apr 2019 13:24:28 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43006 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbfDIRY1 (ORCPT ); Tue, 9 Apr 2019 13:24:27 -0400 Received: by mail-pg1-f195.google.com with SMTP id p6so9680466pgh.9; Tue, 09 Apr 2019 10:24: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=pcq2ZYRBSeSNy0rJ3Utjw0J/rJxnyDG4Pd+n7XplGZg=; b=sQq586EkCdJ/9p7WXbf1+H4bh2TINrQgyFOaGEWzq73ea78a8TTtygrWBYsBm5D66l kGKJjl0zk4jxAbg57WROS2uL2sCDVjnbgVP4h/LFoHEEgH9fnVsuHf4sdrEi4CU40myD VCUPPjiiB/JPdVRLY+T/9w7vMX/tYSOjBlWBiWoKBe2dnOC/0p5e5goZKivDONbUiJJq yVx5mae2UZZpR8y+MBdIHJtgesJMYbLjOS22JpcSjE83/1sDPu8Q2EsXf9fTQmf4UWu6 VCDEZX/mVtpocR4JnXjfq3gVx2D0qEf1uomR/QJXb/iv/IvUVxkneuk4BVGepltVlrpC ZeMA== 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=pcq2ZYRBSeSNy0rJ3Utjw0J/rJxnyDG4Pd+n7XplGZg=; b=f/D32akfRAU6XX144uPllIk4sm0HlJCRDP2mmpqlnaPYshDn2+tAY0jR4xRobMrK8p 5wARjEQo+V99la8wnSWZfkRA1dTbhVRpFOIZ+JY+gKvVd3UoULeLufLZNYEeFUbHLNKd p8XpnODJafZTLqFePS0ChHSNuCmiif0XS4IwdqXIn+pof5Od9j8b0iLmekZNfwrdsLBE PslIQj6xx4r0JaeC9OCmYMfaOQc+Qs+cpudBWn9A345/zgzsCuhYoviK6pji3aPoIdAX J6oTJiCqpydAWPDDRXeqxcFciubk3X7MdXFAMB0waxKnfrWJ8IesTm2XSPBsAURLworJ NWlA== X-Gm-Message-State: APjAAAVRRccL9xcUN/XOUVeLYe7A4wFvY/ENapmgvPsgPB5TbmeFyZFG OBWnf58GfCz4tLcxvPuWAWE= X-Google-Smtp-Source: APXvYqz3ypuWQ/GC2tJ1glxa89gkZLD8vcBTfWvm5rHPTVsRsVMbcml5Afau1P2z4QXVsUP0hY+64Q== X-Received: by 2002:a63:cf0f:: with SMTP id j15mr35672330pgg.329.1554830667025; Tue, 09 Apr 2019 10:24:27 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id l88sm56756038pfb.104.2019.04.09.10.24.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24: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 11/23] watchdog: pm8916_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Tue, 9 Apr 2019 10:23:49 -0700 Message-Id: <1554830641-9247-12-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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/pm8916_wdt.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_wdt.c index 7f10041fcf5b..2d3652004e39 100644 --- a/drivers/watchdog/pm8916_wdt.c +++ b/drivers/watchdog/pm8916_wdt.c @@ -132,15 +132,16 @@ static const struct watchdog_ops pm8916_wdt_ops = { static int pm8916_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct pm8916_wdt *wdt; struct device *parent; int err, irq; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; - parent = pdev->dev.parent; + parent = dev->parent; /* * The pm8916-pon-wdt is a child of the pon device, which is a child @@ -150,20 +151,20 @@ static int pm8916_wdt_probe(struct platform_device *pdev) */ wdt->regmap = dev_get_regmap(parent->parent, NULL); if (!wdt->regmap) { - dev_err(&pdev->dev, "failed to locate regmap\n"); + dev_err(dev, "failed to locate regmap\n"); return -ENODEV; } err = device_property_read_u32(parent, "reg", &wdt->baseaddr); if (err) { - dev_err(&pdev->dev, "failed to get pm8916-pon address\n"); + dev_err(dev, "failed to get pm8916-pon address\n"); return err; } irq = platform_get_irq(pdev, 0); if (irq > 0) { - if (devm_request_irq(&pdev->dev, irq, pm8916_wdt_isr, 0, - "pm8916_wdt", wdt)) + if (devm_request_irq(dev, irq, pm8916_wdt_isr, 0, "pm8916_wdt", + wdt)) irq = 0; } @@ -172,23 +173,23 @@ static int pm8916_wdt_probe(struct platform_device *pdev) wdt->baseaddr + PON_PMIC_WD_RESET_S2_CTL, RESET_TYPE_HARD); if (err) { - dev_err(&pdev->dev, "failed configure watchdog\n"); + dev_err(dev, "failed configure watchdog\n"); return err; } wdt->wdev.info = (irq > 0) ? &pm8916_wdt_pt_ident : &pm8916_wdt_ident, wdt->wdev.ops = &pm8916_wdt_ops, - wdt->wdev.parent = &pdev->dev; + wdt->wdev.parent = dev; wdt->wdev.min_timeout = PM8916_WDT_MIN_TIMEOUT; wdt->wdev.max_timeout = PM8916_WDT_MAX_TIMEOUT; wdt->wdev.timeout = PM8916_WDT_DEFAULT_TIMEOUT; wdt->wdev.pretimeout = 0; watchdog_set_drvdata(&wdt->wdev, wdt); - watchdog_init_timeout(&wdt->wdev, 0, &pdev->dev); + watchdog_init_timeout(&wdt->wdev, 0, dev); pm8916_wdt_configure_timers(&wdt->wdev); - return devm_watchdog_register_device(&pdev->dev, &wdt->wdev); + return devm_watchdog_register_device(dev, &wdt->wdev); } static const struct of_device_id pm8916_wdt_id_table[] = { From patchwork Tue Apr 9 17:23: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: 10891859 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 24DA21800 for ; Tue, 9 Apr 2019 17:25:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 115A026E4F for ; Tue, 9 Apr 2019 17:25:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0543C28553; Tue, 9 Apr 2019 17:25:56 +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 7DFE22839C for ; Tue, 9 Apr 2019 17:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726771AbfDIRY3 (ORCPT ); Tue, 9 Apr 2019 13:24:29 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39370 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbfDIRY3 (ORCPT ); Tue, 9 Apr 2019 13:24:29 -0400 Received: by mail-pg1-f193.google.com with SMTP id k3so9688530pga.6; Tue, 09 Apr 2019 10:24:28 -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=0rD/0tJd1ah52P5emLg7Kwg4Ngw1RXkxMOo+hYFX6MI=; b=TNkEqJEkBx11Z87Um62dQeUYMLD78aDSQJTsH0bGvKsXigMUQ7AXWQLcP/2rFVwLTS 67D0fsmr83d4OwsAgeONdsylz5zA77sVyWcbV+jud0MDafxr604gClwrQkFgYuTBDkL4 tW7ji66vBFBSy5UHb0ophx+vza1qDEn3CSp5gWIjrsqZD6Wja7XUNyGJcm+LrG9dhBGL AOujuXTFgWmU7sKcmIleNx7GLKBPbHO27BcCFOcHZeWdXbu51hgREfqLIvJOnvkRcIx9 jMzBeZAOFF/egGvBgfjeQ3+5Par2vobiad5tjyXWlFYOTpNy7v9XOezDBZoQF49AoX6l ue0w== 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=0rD/0tJd1ah52P5emLg7Kwg4Ngw1RXkxMOo+hYFX6MI=; b=Jk32xKECIaDdgG5G2ETMnevxhcM04lyu3p1JlPFzd415heWto1bjV3n9XMlmmFNL3H m74Zg/FWOzrc0sVqjh5ItqvZeeOK5e3oReMSvYSh6IHgYfn9APkLS05A/7k1EmrcYsud ED3Jz7nhgO4cdZuSQCvZUC8NvlgDwnToyDO/qDfKHBm7tgiEB/Il2RIMP7/qFDEYs4fm nmTYnVjxk4JZWT9gny9VSDr199DlBsUoIt5vWmzqlAJB2agELUQDSxJfmx3XWBmbARyk mriwXFi6feD4XodmBEiqy1TpSHmYbdm6kdqsFlRVEMDI5NbnXD+yj8vT/GH4u6Ogade1 Uehg== X-Gm-Message-State: APjAAAV2zFp/Dc3XF4edezshnwmPzJ64mgnBrAfqNMKQqEheox6KgYu5 grf5/YJRXkjKa/7uw0vuiCs= X-Google-Smtp-Source: APXvYqwDijYB0a3pB9nyXb+JBQ1AIuie29eF2lTvGapEcsA8jWNYq9kNES7hwAkm0x1OXP/1xWKLag== X-Received: by 2002:a62:7549:: with SMTP id q70mr27889935pfc.112.1554830668375; Tue, 09 Apr 2019 10:24:28 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id f1sm40310238pgl.35.2019.04.09.10.24.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:27 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Andy Gross , David Brown Subject: [PATCH 12/23] watchdog: qcom-wdt: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:23:50 -0700 Message-Id: <1554830641-9247-13-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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: Andy Gross Cc: David Brown Signed-off-by: Guenter Roeck --- drivers/watchdog/qcom-wdt.c | 55 +++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c index 5dfd604477a4..6d29c33b1316 100644 --- a/drivers/watchdog/qcom-wdt.c +++ b/drivers/watchdog/qcom-wdt.c @@ -142,22 +142,28 @@ static const struct watchdog_info qcom_wdt_info = { .identity = KBUILD_MODNAME, }; +static void qcom_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int qcom_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct qcom_wdt *wdt; struct resource *res; - struct device_node *np = pdev->dev.of_node; + struct device_node *np = dev->of_node; const u32 *regs; u32 percpu_offset; int ret; - regs = of_device_get_match_data(&pdev->dev); + regs = of_device_get_match_data(dev); if (!regs) { - dev_err(&pdev->dev, "Unsupported QCOM WDT module\n"); + dev_err(dev, "Unsupported QCOM WDT module\n"); return -ENODEV; } - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -172,21 +178,25 @@ static int qcom_wdt_probe(struct platform_device *pdev) res->start += percpu_offset; res->end += percpu_offset; - wdt->base = devm_ioremap_resource(&pdev->dev, res); + wdt->base = devm_ioremap_resource(dev, res); 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)) { - dev_err(&pdev->dev, "failed to get input clock\n"); + dev_err(dev, "failed to get input clock\n"); return PTR_ERR(wdt->clk); } ret = clk_prepare_enable(wdt->clk); if (ret) { - dev_err(&pdev->dev, "failed to setup clock\n"); + dev_err(dev, "failed to setup clock\n"); return ret; } + ret = devm_add_action_or_reset(dev, qcom_clk_disable_unprepare, + wdt->clk); + if (ret) + return ret; /* * We use the clock rate to calculate the max timeout, so ensure it's @@ -199,16 +209,15 @@ static int qcom_wdt_probe(struct platform_device *pdev) wdt->rate = clk_get_rate(wdt->clk); if (wdt->rate == 0 || wdt->rate > 0x10000000U) { - dev_err(&pdev->dev, "invalid clock rate\n"); - ret = -EINVAL; - goto err_clk_unprepare; + dev_err(dev, "invalid clock rate\n"); + return -EINVAL; } wdt->wdd.info = &qcom_wdt_info; wdt->wdd.ops = &qcom_wdt_ops; wdt->wdd.min_timeout = 1; wdt->wdd.max_timeout = 0x10000000U / wdt->rate; - wdt->wdd.parent = &pdev->dev; + wdt->wdd.parent = dev; wdt->layout = regs; if (readl(wdt_addr(wdt, WDT_STS)) & 1) @@ -220,29 +229,16 @@ static int qcom_wdt_probe(struct platform_device *pdev) * the max instead. */ wdt->wdd.timeout = min(wdt->wdd.max_timeout, 30U); - watchdog_init_timeout(&wdt->wdd, 0, &pdev->dev); + watchdog_init_timeout(&wdt->wdd, 0, dev); - ret = watchdog_register_device(&wdt->wdd); + ret = devm_watchdog_register_device(dev, &wdt->wdd); if (ret) { - dev_err(&pdev->dev, "failed to register watchdog\n"); - goto err_clk_unprepare; + dev_err(dev, "failed to register watchdog\n"); + return ret; } platform_set_drvdata(pdev, wdt); return 0; - -err_clk_unprepare: - clk_disable_unprepare(wdt->clk); - return ret; -} - -static int qcom_wdt_remove(struct platform_device *pdev) -{ - struct qcom_wdt *wdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(&wdt->wdd); - clk_disable_unprepare(wdt->clk); - return 0; } static int __maybe_unused qcom_wdt_suspend(struct device *dev) @@ -277,7 +273,6 @@ MODULE_DEVICE_TABLE(of, qcom_wdt_of_table); static struct platform_driver qcom_watchdog_driver = { .probe = qcom_wdt_probe, - .remove = qcom_wdt_remove, .driver = { .name = KBUILD_MODNAME, .of_match_table = qcom_wdt_of_table, From patchwork Tue Apr 9 17:23: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: 10891855 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 877F11515 for ; Tue, 9 Apr 2019 17:25:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 741672839C for ; Tue, 9 Apr 2019 17:25:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 682592894D; Tue, 9 Apr 2019 17:25: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 09BF52839C for ; Tue, 9 Apr 2019 17:25:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726785AbfDIRYb (ORCPT ); Tue, 9 Apr 2019 13:24:31 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45427 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726775AbfDIRYa (ORCPT ); Tue, 9 Apr 2019 13:24:30 -0400 Received: by mail-pf1-f194.google.com with SMTP id e24so10090002pfi.12; Tue, 09 Apr 2019 10:24: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=YEVlYxcVMQ+udZOYQMBpKUyQvjiSc8bbYElkffO0rRU=; b=JfQarJYVrpruasuUhAMsdXQlKQS6hMFlFJFresi8WkLysRiXPH+VRUqRiAvJVDmSue ORvTIqoH3OuIhMCcWiYWbQQVUUL6qm3bnxscl1fyCAkuv3q8cpqmHG+bGhrpw6Q8oEG1 QxD8htrDqMfYPgLn7Z+TF+NKpi3euyebZqLTN+Sy1ypykeXUUN/dWpcEa/DANcoWIjKN z3wxnomLta1RCMrsFJD+MyvSm5Jz7My+Zq+FmEPquD70flV6YLiiPuPgFjgzbBfMvKX0 LPpLLvRi/pOySZ2KJiDQTTMathOID4y0DlRGZlovUDSa3cKr3xV5qG4DPpdzoddm8h75 kfjg== 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=YEVlYxcVMQ+udZOYQMBpKUyQvjiSc8bbYElkffO0rRU=; b=ZOaC6YTH86Z+18u9tDAsYk8IVQ/wGuAjeqDQ4zflpayYR+qfW8IbR+nttzN+QDFOjX 0qyMG81/wsZerN+x46grZip7AQBPAOJOS4T0A6Xo4UdywR83YmLaZ297lN3htppbTtGO VdG87OcuGgSZMqRfAk5zDO6XGfQyx25vcwHJRwGz8/pHGjJnWMi4LpDI88l+ewmvuJHN adfuBMbuUGBHnbjrmh7WNy2eZPyc4wazhtGlfO9ZozTVYMZ9YZxZVepZTUJBGTFdDOTn Ag/Ro+JK52As9g/Q/2MyoOBgAo3RJKkK+9GGDjpSoUIkVP/I435KlOpsbueogmABCfBY 6LrA== X-Gm-Message-State: APjAAAWdkscSDGZ5lSR+hREQB8KhRzIMyy78JdI926G91hL6Dpm7KoNF idx+fxCsoB4MeOj3SJ/YGqg= X-Google-Smtp-Source: APXvYqyDqUkCR5hqaZQ5hYE7oUTpuCoF5l4pIT4LeR9fyh0o0RPI6nXd25B46cXbot4bZhyCpERiiw== X-Received: by 2002:aa7:8208:: with SMTP id k8mr38574721pfi.69.1554830669689; Tue, 09 Apr 2019 10:24:29 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id r76sm34023097pfa.39.2019.04.09.10.24.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24: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 13/23] watchdog: rn5t618_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Tue, 9 Apr 2019 10:23:51 -0700 Message-Id: <1554830641-9247-14-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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/rn5t618_wdt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/rn5t618_wdt.c b/drivers/watchdog/rn5t618_wdt.c index e60f55702ab7..21fcb36f9074 100644 --- a/drivers/watchdog/rn5t618_wdt.c +++ b/drivers/watchdog/rn5t618_wdt.c @@ -146,11 +146,12 @@ static const struct watchdog_ops rn5t618_wdt_ops = { static int rn5t618_wdt_probe(struct platform_device *pdev) { - struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); + struct device *dev = &pdev->dev; + struct rn5t618 *rn5t618 = dev_get_drvdata(dev->parent); struct rn5t618_wdt *wdt; int min_timeout, max_timeout; - wdt = devm_kzalloc(&pdev->dev, sizeof(struct rn5t618_wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(struct rn5t618_wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -163,10 +164,10 @@ static int rn5t618_wdt_probe(struct platform_device *pdev) wdt->wdt_dev.min_timeout = min_timeout; wdt->wdt_dev.max_timeout = max_timeout; wdt->wdt_dev.timeout = max_timeout; - wdt->wdt_dev.parent = &pdev->dev; + wdt->wdt_dev.parent = dev; watchdog_set_drvdata(&wdt->wdt_dev, wdt); - watchdog_init_timeout(&wdt->wdt_dev, timeout, &pdev->dev); + watchdog_init_timeout(&wdt->wdt_dev, timeout, dev); watchdog_set_nowayout(&wdt->wdt_dev, nowayout); platform_set_drvdata(pdev, wdt); From patchwork Tue Apr 9 17:23: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: 10891857 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 EA49C1515 for ; Tue, 9 Apr 2019 17:25:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D55B926E4F for ; Tue, 9 Apr 2019 17:25:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C985028947; Tue, 9 Apr 2019 17:25:55 +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 531C326E4F for ; Tue, 9 Apr 2019 17:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726708AbfDIRZt (ORCPT ); Tue, 9 Apr 2019 13:25:49 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43108 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726786AbfDIRYb (ORCPT ); Tue, 9 Apr 2019 13:24:31 -0400 Received: by mail-pf1-f196.google.com with SMTP id c8so10105090pfd.10; Tue, 09 Apr 2019 10:24: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=bnlZ/hHz2P+XdfA2OTKL/VfiS9qckCeYUcGcUaZUPJQ=; b=opVxhz0fsOXp/x3EQw6IhRKSlx7G/xDAheArKDTVorvHhykijNsRv/ryay0ZNyAVY+ Tb495xgJz5wWiBsTA1xAFNmxaXvDDGKmlHYE5mF/6wPzY+TQ43y4f/N42/33/sSNx8Or 4cBMiBKIKXRSZ2CQv+ASA58+x24C6HFbZVEQpopFSQCu+GzMEiNNV+AiIvSJRQkbU5ww 2LDsUZmTNBITJZyYBKyvwkbA+sSrH0j9ndEKdHq5DPmUIE9ROpxk+t3dL7Je8MTDqs92 TLSuLViN/NV9WsMqZCeTiSk/XnEb48Y89OQBT+50pmXbKeqPlrxcVBShG/tbnIYSwmgP dARw== 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=bnlZ/hHz2P+XdfA2OTKL/VfiS9qckCeYUcGcUaZUPJQ=; b=NdR2y59k2kUs43pRw/UA2j0iNJoZg6OUB4XMyZsAg6WtBF1055h7ZZeFfVgNbj5hLZ xW0MwNxJrgrVSf/BhxxkzFXpuet2ZLpLoXPKTVyDLei3RmaxXB0G0CwWwKUl1FEsrb4H HNnjYiDKnowzqbEUnFSA7xXHGwGdrjA4xyM6spDOxDE0KmpmmU3sJYi+7IlgqIeH5IzQ YMSgFdNFm2a6yxGrHmkgGc+rNLEHRZOA9WPcdCYxUXGk1BfwSEkIcu9EfQ4GfSG3LXTs WH7WUk+nW3gIz2qU0M98X8y7K4EqkmOIOV7Ow85Jo2W/r/yWOrSAiFFHRLG6HqncTyae 8Kjw== X-Gm-Message-State: APjAAAUW7n/uzHPRkgFRgFEF+ULcHukFchVSASBbBkPNIlftCP8I86K6 nRaLHBKtxxjNbjGSXFRrLs8= X-Google-Smtp-Source: APXvYqw7vcq7zSxOxF96FEvco77OOLatQNEF4Wz8ihNNVOHN/q3fdJ+dmf82Ec4j8vdDUHeAUlxoIg== X-Received: by 2002:a63:7117:: with SMTP id m23mr34950135pgc.271.1554830671117; Tue, 09 Apr 2019 10:24:31 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b26sm65662685pgn.4.2019.04.09.10.24.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:30 -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/23] watchdog: rtd119x_wdt: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:23:52 -0700 Message-Id: <1554830641-9247-15-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop unnecessary braces around conditional return statements - Drop empty remove function - Use devm_add_action_or_reset() for calls to clk_disable_unprepare - Replace 'of_clk_get(np, 0)' with 'devm_clk_get(dev, NULL)' - Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly - Use devm_watchdog_register_driver() to register watchdog device Signed-off-by: Guenter Roeck --- drivers/watchdog/rtd119x_wdt.c | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/drivers/watchdog/rtd119x_wdt.c b/drivers/watchdog/rtd119x_wdt.c index cb17c49f3534..c4cb23d65218 100644 --- a/drivers/watchdog/rtd119x_wdt.c +++ b/drivers/watchdog/rtd119x_wdt.c @@ -95,12 +95,18 @@ static const struct of_device_id rtd119x_wdt_dt_ids[] = { { } }; +static void rtd119x_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int rtd119x_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct rtd119x_watchdog_device *data; int ret; - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -108,22 +114,24 @@ static int rtd119x_wdt_probe(struct platform_device *pdev) if (IS_ERR(data->base)) return PTR_ERR(data->base); - data->clk = of_clk_get(pdev->dev.of_node, 0); + data->clk = devm_clk_get(dev, NULL); if (IS_ERR(data->clk)) return PTR_ERR(data->clk); ret = clk_prepare_enable(data->clk); - if (ret) { - clk_put(data->clk); + if (ret) + return ret; + ret = devm_add_action_or_reset(dev, rtd119x_clk_disable_unprepare, + data->clk); + if (ret) return ret; - } data->wdt_dev.info = &rtd119x_wdt_info; data->wdt_dev.ops = &rtd119x_wdt_ops; data->wdt_dev.timeout = 120; data->wdt_dev.max_timeout = 0xffffffff / clk_get_rate(data->clk); data->wdt_dev.min_timeout = 1; - data->wdt_dev.parent = &pdev->dev; + data->wdt_dev.parent = dev; watchdog_stop_on_reboot(&data->wdt_dev); watchdog_set_drvdata(&data->wdt_dev, data); @@ -133,31 +141,11 @@ static int rtd119x_wdt_probe(struct platform_device *pdev) rtd119x_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout); rtd119x_wdt_stop(&data->wdt_dev); - ret = watchdog_register_device(&data->wdt_dev); - if (ret) { - clk_disable_unprepare(data->clk); - clk_put(data->clk); - return ret; - } - - return 0; -} - -static int rtd119x_wdt_remove(struct platform_device *pdev) -{ - struct rtd119x_watchdog_device *data = platform_get_drvdata(pdev); - - watchdog_unregister_device(&data->wdt_dev); - - clk_disable_unprepare(data->clk); - clk_put(data->clk); - - return 0; + return devm_watchdog_register_device(dev, &data->wdt_dev); } static struct platform_driver rtd119x_wdt_driver = { .probe = rtd119x_wdt_probe, - .remove = rtd119x_wdt_remove, .driver = { .name = "rtd1295-watchdog", .of_match_table = rtd119x_wdt_dt_ids, From patchwork Tue Apr 9 17:23: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: 10891853 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 78BE41708 for ; Tue, 9 Apr 2019 17:25:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 640CC26E4F for ; Tue, 9 Apr 2019 17:25:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5725A2894C; Tue, 9 Apr 2019 17:25: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 DD9E926E4F for ; Tue, 9 Apr 2019 17:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726644AbfDIRZo (ORCPT ); Tue, 9 Apr 2019 13:25:44 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41408 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbfDIRYd (ORCPT ); Tue, 9 Apr 2019 13:24:33 -0400 Received: by mail-pl1-f196.google.com with SMTP id d1so9802356plj.8; Tue, 09 Apr 2019 10:24:32 -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=INJ416e+pd21Ry2WyJYMICDziX05uHazE/a32a5u+ko=; b=nUsDpz0eQ7fheYMhQdWPNcTGzLYvKFdNYN6yDPkLcm682erL9LH8/51bmUaBoGCd/k LY9b4REzc4ZosAKIWN2cEPalss4SRG2CbcQZwMh9B/FQioT92taBZSLl0Y9VcepcpoKl EzGa/ZMv8B6IUtqZKQp88GPnWPis9a5szJUT6BXvcjF2+btDhN9ilA1Bg1u3R3xm55hH EWf6GjUd82xE1X8u68dKwQOP+1liETA++s9CTA3eIncS3aMebBA1I+9XtZVixC+TfC3g 2Q31bzf3v/at+IzuEk3Lm4x8dzRTu05QZM8BBY6CbVDtfR/JApr1rA0H4now7rDxDB2E zdoA== 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=INJ416e+pd21Ry2WyJYMICDziX05uHazE/a32a5u+ko=; b=jOXB0RoLUTppZQe6PdQU6EJ8uU7e2YHNa7crfBXjblfa18y8BpTUnfPzTnTFc41ToD Xcq0IF4T4hUow4AhNQnJg7Eu0F7lBpQYGZB3Mzi7cokuL7Du7E0uYRgdlFoJGQ+HqT7C bZcohmc0WJ1IwDuxSfRJUR5qmWGBQ0UFnqyuFeq+E3w45zmumBBtXH/vozP1k36PyoXu pc+P/iLsxQapDAGVuWXMOfTcGIydJw+LN+w6W6n58TcA42ULJ6e4NFZrvkOGMucPgctb dLHnX0AK8JlDftev2ffr6WmDEoEHUHs5etQJqn7EqVgoYLMcu8XSAjB85rEiHrlQlhFL 8JcQ== X-Gm-Message-State: APjAAAUrR0PZqFzZxcnJRS2SX1WCv6UKKGW2Ld1pppdrzL20npRFlYru jPEiiFi9mZtO6G4/SToqB7M= X-Google-Smtp-Source: APXvYqz2Uwp0LqP3ZB8rfsBu+VkCRxfavd7rZtFsUMq+EKMJ7TMBF7901youLmoyVm2ZAxBLfHVUtA== X-Received: by 2002:a17:902:7d8f:: with SMTP id a15mr4589813plm.3.1554830672499; Tue, 09 Apr 2019 10:24:32 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id i3sm49062881pfa.90.2019.04.09.10.24.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:31 -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/23] watchdog: rza_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Tue, 9 Apr 2019 10:23:53 -0700 Message-Id: <1554830641-9247-16-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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/rza_wdt.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/watchdog/rza_wdt.c b/drivers/watchdog/rza_wdt.c index b854f0aeb3ef..7b6c365f7cd3 100644 --- a/drivers/watchdog/rza_wdt.c +++ b/drivers/watchdog/rza_wdt.c @@ -166,11 +166,12 @@ static const struct watchdog_ops rza_wdt_ops = { static int rza_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct rza_wdt *priv; unsigned long rate; int ret; - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -178,21 +179,21 @@ static int rza_wdt_probe(struct platform_device *pdev) if (IS_ERR(priv->base)) return PTR_ERR(priv->base); - priv->clk = devm_clk_get(&pdev->dev, NULL); + priv->clk = devm_clk_get(dev, NULL); if (IS_ERR(priv->clk)) return PTR_ERR(priv->clk); rate = clk_get_rate(priv->clk); if (rate < 16384) { - dev_err(&pdev->dev, "invalid clock rate (%ld)\n", rate); + dev_err(dev, "invalid clock rate (%ld)\n", rate); return -ENOENT; } priv->wdev.info = &rza_wdt_ident, priv->wdev.ops = &rza_wdt_ops, - priv->wdev.parent = &pdev->dev; + priv->wdev.parent = dev; - priv->cks = (u8)(uintptr_t)of_device_get_match_data(&pdev->dev); + priv->cks = (u8)(uintptr_t) of_device_get_match_data(dev); if (priv->cks == CKS_4BIT) { /* Assume slowest clock rate possible (CKS=0xF) */ priv->wdev.max_timeout = (DIVIDER_4BIT * U8_MAX) / rate; @@ -207,19 +208,19 @@ static int rza_wdt_probe(struct platform_device *pdev) * max_hw_heartbeat_ms. */ priv->wdev.max_hw_heartbeat_ms = (1000 * U8_MAX) / rate; - dev_dbg(&pdev->dev, "max hw timeout of %dms\n", - priv->wdev.max_hw_heartbeat_ms); + dev_dbg(dev, "max hw timeout of %dms\n", + priv->wdev.max_hw_heartbeat_ms); } priv->wdev.min_timeout = 1; priv->wdev.timeout = DEFAULT_TIMEOUT; - watchdog_init_timeout(&priv->wdev, 0, &pdev->dev); + watchdog_init_timeout(&priv->wdev, 0, dev); watchdog_set_drvdata(&priv->wdev, priv); - ret = devm_watchdog_register_device(&pdev->dev, &priv->wdev); + ret = devm_watchdog_register_device(dev, &priv->wdev); if (ret) - dev_err(&pdev->dev, "Cannot register watchdog device\n"); + dev_err(dev, "Cannot register watchdog device\n"); return ret; } From patchwork Tue Apr 9 17:23: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: 10891851 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 B56EC1708 for ; Tue, 9 Apr 2019 17:25:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A358D26E4F for ; Tue, 9 Apr 2019 17:25:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9768B28553; Tue, 9 Apr 2019 17:25:43 +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 0F3F126E4F for ; Tue, 9 Apr 2019 17:25:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726628AbfDIRZc (ORCPT ); Tue, 9 Apr 2019 13:25:32 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37781 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726709AbfDIRYf (ORCPT ); Tue, 9 Apr 2019 13:24:35 -0400 Received: by mail-pl1-f196.google.com with SMTP id w23so9810934ply.4; Tue, 09 Apr 2019 10:24: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=HlrSdebMSpMB59zkY9xN76aLFZr/Ctm0yTCe9ZBi980=; b=HLLKyga69ly1A+xOgUCvVvP97m8rZDtjUrGpSm5S7PhTcxgLf/j6rKSxEl3pnBqG+u 49YcO+2vDBZBcrEzUZJdpJJ/zZHVJbv069rz3h+XbO/dMFGQW0O8jjkU3JSik18dIVKH qlaXuutwWDB22uoe03gfe3vkixisvDR6uo26U3C5vrd6iWjPOpSpC0DOFlqvwocmhQQ4 SRrBZlpwjRtDj14riwj5QmyhAT4I19hJHiSk+CTehFSeBkJMR6D5GRjX6ee6MTNRe58o CLk59fzW41eu9BbZLLI2ER8tTnJiP7C5axwXcRy9ZNoDJGxXWF0Gg2ESy+nlepu/p10P Qi0w== 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=HlrSdebMSpMB59zkY9xN76aLFZr/Ctm0yTCe9ZBi980=; b=eC2R6TVeVBiG01xumCZHcnC7UQAFtqFG5Q+/hN2fswFaBF8xfOv9xXBfzb85YlVEbX qx1a8FcAEb2A+mAlTQ/1vtWd6R96bKO2gPOlVoGzmFdTIB+F9aGdvIJ92faMZv8iUOPf XG7Hm3c26WKEl4oDdYtb31vX3NdVj9GLVO75bK1QmbeTxg9w8+6onscgKqDh7Pp7GHzN sD2MrWs/gPwNFx6y+fF9yGm3y+3d6lyr9DQIEhVav5DwbFxPoxBNmSY3sSh+dGjNw47s xXXnbaiQ8wghdM6tjIcEL4KY1688IUGurr1kMvpuslHHachMuBfngL4jtV7U4tU6jJOY eIrg== X-Gm-Message-State: APjAAAUFohICE5UTbbfjilw7xz4IdUKtj1EteZ84yQeJB9vr2iYOiOEx YObxP2nq4cgncOtePQQagtA= X-Google-Smtp-Source: APXvYqxVvzSxIHnrbUQ/MfrN6XcZFUz8agbNWg0zJwbhRlF4CoN6VFKCQsSaIWtjqhYtA3rqZv49cw== X-Received: by 2002:a17:902:168:: with SMTP id 95mr37424847plb.212.1554830674203; Tue, 09 Apr 2019 10:24:34 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id j9sm30813023pfc.43.2019.04.09.10.24.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:33 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches Subject: [PATCH 16/23] watchdog: sama5d4_wdt: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:23:54 -0700 Message-Id: <1554830641-9247-17-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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 - Replace stop on remove with call to watchdog_stop_on_unregister() - Use devm_watchdog_register_driver() to register watchdog device Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Ludovic Desroches Signed-off-by: Guenter Roeck --- drivers/watchdog/sama5d4_wdt.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c index ea72fa0aa3ec..111695223aae 100644 --- a/drivers/watchdog/sama5d4_wdt.c +++ b/drivers/watchdog/sama5d4_wdt.c @@ -199,6 +199,7 @@ static int sama5d4_wdt_init(struct sama5d4_wdt *wdt) static int sama5d4_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct watchdog_device *wdd; struct sama5d4_wdt *wdt; void __iomem *regs; @@ -206,7 +207,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev) u32 timeout; int ret; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -226,26 +227,25 @@ static int sama5d4_wdt_probe(struct platform_device *pdev) wdt->reg_base = regs; - irq = irq_of_parse_and_map(pdev->dev.of_node, 0); + irq = irq_of_parse_and_map(dev->of_node, 0); if (!irq) - dev_warn(&pdev->dev, "failed to get IRQ from DT\n"); + dev_warn(dev, "failed to get IRQ from DT\n"); - ret = of_sama5d4_wdt_init(pdev->dev.of_node, wdt); + ret = of_sama5d4_wdt_init(dev->of_node, wdt); if (ret) return ret; if ((wdt->mr & AT91_WDT_WDFIEN) && irq) { - ret = devm_request_irq(&pdev->dev, irq, sama5d4_wdt_irq_handler, + ret = devm_request_irq(dev, irq, sama5d4_wdt_irq_handler, IRQF_SHARED | IRQF_IRQPOLL | IRQF_NO_SUSPEND, pdev->name, pdev); if (ret) { - dev_err(&pdev->dev, - "cannot register interrupt handler\n"); + dev_err(dev, "cannot register interrupt handler\n"); return ret; } } - watchdog_init_timeout(wdd, wdt_timeout, &pdev->dev); + watchdog_init_timeout(wdd, wdt_timeout, dev); timeout = WDT_SEC2TICKS(wdd->timeout); @@ -258,31 +258,21 @@ static int sama5d4_wdt_probe(struct platform_device *pdev) watchdog_set_nowayout(wdd, nowayout); - ret = watchdog_register_device(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 (timeout = %d sec, nowayout = %d)\n", + dev_info(dev, "initialized (timeout = %d sec, nowayout = %d)\n", wdd->timeout, nowayout); return 0; } -static int sama5d4_wdt_remove(struct platform_device *pdev) -{ - struct sama5d4_wdt *wdt = platform_get_drvdata(pdev); - - sama5d4_wdt_stop(&wdt->wdd); - - watchdog_unregister_device(&wdt->wdd); - - return 0; -} - static const struct of_device_id sama5d4_wdt_of_match[] = { { .compatible = "atmel,sama5d4-wdt", }, { } @@ -310,7 +300,6 @@ static SIMPLE_DEV_PM_OPS(sama5d4_wdt_pm_ops, NULL, static struct platform_driver sama5d4_wdt_driver = { .probe = sama5d4_wdt_probe, - .remove = sama5d4_wdt_remove, .driver = { .name = "sama5d4_wdt", .pm = &sama5d4_wdt_pm_ops, From patchwork Tue Apr 9 17:23: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: 10891849 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 212161708 for ; Tue, 9 Apr 2019 17:25:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F2B226E4F for ; Tue, 9 Apr 2019 17:25:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 037A228553; Tue, 9 Apr 2019 17:25:31 +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 9519126E4F for ; Tue, 9 Apr 2019 17:25:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726733AbfDIRYg (ORCPT ); Tue, 9 Apr 2019 13:24:36 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41317 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbfDIRYg (ORCPT ); Tue, 9 Apr 2019 13:24:36 -0400 Received: by mail-pf1-f195.google.com with SMTP id 188so10101963pfd.8; Tue, 09 Apr 2019 10:24: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=wD2DSazscH8pXYOvV/UE8CSsvEV5LX5/5sBBOGKP7p8=; b=eV2EbIcXbFp6kSeKeMNvf5UqnqRATv1xl1WZ+nYPml+zy6bcX/dFqOoeXypThBKXpI Lf1dEWoGHeHrQanv3ZMbUbvQiaDOx9yRszWjxb/3qyadSGi+0kysQFgNSIBl5ZIHPoJk m85t125W/rODREVLJW8JeKQNjJ2P2EmyibFTOWEpiUmZp6FgQvqlQ/ltXJybYKalw5kb iFnfw2dEQezAwcjwCYyxKtTmHSx2hPRWixPTu3xGLEVWPuf4cEcnK24sLp1rUaX+0R+j HDE7DEYoO9MjGADWk0M7EIV8tpPj3UECDpJlJL/24LJGCo0nGHrs8pEgBdHSZRuOZ/Jt IpAw== 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=wD2DSazscH8pXYOvV/UE8CSsvEV5LX5/5sBBOGKP7p8=; b=FyrNeUyEbxeh+EN/GzMgOdhPNp33PKfL4vBv980gsObHKWdx6yxm0dKakFv4dX3k4G QSogSJzsd+GAnjE2RTbIUdq/rCAbn14JHwXRBp02iZQ4Uh36KvEjYLjj9RtbZKVNxmV8 aLJD/PtVtnUfLTXArLYHzil95U+6Pwxtd+Erp4hSMl9qp5glSyexEQ6zXbu4k6zGhGSK sL86BjBVfTnSNJ+UFFIGh8cyraMoK6cyXbn3haw4+wXakfRQe2xakS32XIqcxYfJsdQW Bkq8n7KtHYDMwqb2wLTJ2VQgGkW3udk13SPEgBS87qBLSObGdTptIs9nQych1wcufsYR mwvw== X-Gm-Message-State: APjAAAXxYoqQ+zlgpNsQQRV9PMFJ3akzk1fPXC4ulO86X8uIKh4DbUx/ nYta2VkjcDcwo4iLFacUuy+e/S0K X-Google-Smtp-Source: APXvYqxX7yq7oeJCIHOJZAA6eu5MS+m+Z8J0sAWhG5A7iGuMBYVg8Q46PO4tCBnuFW2fSL6aOmJKGQ== X-Received: by 2002:a65:5286:: with SMTP id y6mr35447051pgp.79.1554830675591; Tue, 09 Apr 2019 10:24:35 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id v43sm25926590pgn.57.2019.04.09.10.24.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:35 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Barry Song Subject: [PATCH 17/23] watchdog: sirfsoc_wdt: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:23:55 -0700 Message-Id: <1554830641-9247-18-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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 - Replace shutdown function with call to watchdog_stop_on_reboot() - Replace stop on remove with call to watchdog_stop_on_unregister() - Use devm_watchdog_register_driver() to register watchdog device Cc: Barry Song Signed-off-by: Guenter Roeck --- drivers/watchdog/sirfsoc_wdt.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/watchdog/sirfsoc_wdt.c b/drivers/watchdog/sirfsoc_wdt.c index 2559062d35da..e79a4097d50b 100644 --- a/drivers/watchdog/sirfsoc_wdt.c +++ b/drivers/watchdog/sirfsoc_wdt.c @@ -146,6 +146,7 @@ static struct watchdog_device sirfsoc_wdd = { static int sirfsoc_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; void __iomem *base; @@ -155,11 +156,13 @@ static int sirfsoc_wdt_probe(struct platform_device *pdev) watchdog_set_drvdata(&sirfsoc_wdd, (__force void *)base); - watchdog_init_timeout(&sirfsoc_wdd, timeout, &pdev->dev); + watchdog_init_timeout(&sirfsoc_wdd, timeout, dev); watchdog_set_nowayout(&sirfsoc_wdd, nowayout); - sirfsoc_wdd.parent = &pdev->dev; + sirfsoc_wdd.parent = dev; - ret = watchdog_register_device(&sirfsoc_wdd); + watchdog_stop_on_reboot(&sirfsoc_wdd); + watchdog_stop_on_unregister(&sirfsoc_wdd); + ret = devm_watchdog_register_device(dev, &sirfsoc_wdd); if (ret) return ret; @@ -168,19 +171,6 @@ static int sirfsoc_wdt_probe(struct platform_device *pdev) return 0; } -static void sirfsoc_wdt_shutdown(struct platform_device *pdev) -{ - struct watchdog_device *wdd = platform_get_drvdata(pdev); - - sirfsoc_wdt_disable(wdd); -} - -static int sirfsoc_wdt_remove(struct platform_device *pdev) -{ - sirfsoc_wdt_shutdown(pdev); - return 0; -} - #ifdef CONFIG_PM_SLEEP static int sirfsoc_wdt_suspend(struct device *dev) { @@ -218,8 +208,6 @@ static struct platform_driver sirfsoc_wdt_driver = { .of_match_table = sirfsoc_wdt_of_match, }, .probe = sirfsoc_wdt_probe, - .remove = sirfsoc_wdt_remove, - .shutdown = sirfsoc_wdt_shutdown, }; module_platform_driver(sirfsoc_wdt_driver); From patchwork Tue Apr 9 17:23: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: 10891847 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 460F31708 for ; Tue, 9 Apr 2019 17:25:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3290726E4F for ; Tue, 9 Apr 2019 17:25:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26F6F28553; Tue, 9 Apr 2019 17:25: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 8B2CE26E4F for ; Tue, 9 Apr 2019 17:25:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726894AbfDIRZV (ORCPT ); Tue, 9 Apr 2019 13:25:21 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44377 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbfDIRYi (ORCPT ); Tue, 9 Apr 2019 13:24:38 -0400 Received: by mail-pf1-f196.google.com with SMTP id y13so10095408pfm.11; Tue, 09 Apr 2019 10:24: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=2MUlrOc0HiJHRTPNOKs/f+k1Z+oIQtcna7qAe/Y1Um4=; b=Tf7voPLO3YZyyvjoPhKA55fjMXGPckPHhuKqPs/zJuKMFQqdDboJMxxw+wNjDH+NN4 su6u8KalO1AWWle/fwU7PDanEvUdmyvai92GnZWucZEBr/TDcPq3LuWw8U0BEuWMKZpr wd2Lu3lTp2LIVj0tMqP4EY1fRarbkGaxyiXtjeMT3bkmTDM9K9eRuWIcBrVs0TlaMmeP pPprvCYeOH6wFH7dBiitLU8whe3UhamgOVFItdLqooviFVebaRsgUDH+sVVIMyO05br3 zKG4xLNAGzXTya6+dGYjhPNbrNEpk99IaIq065gpxGd0QNbjaHo98mQn2n1eVv6mtUZW b/yQ== 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=2MUlrOc0HiJHRTPNOKs/f+k1Z+oIQtcna7qAe/Y1Um4=; b=cdbRXRGt4c2h8sYkvQKwlAkySWDO1+UsJdzQROVVULs0NvMaStM7PZycafsxsR5NiH juu0gwdWmFCtwqKf7jlgexwBmbc8u+RHyIXXu4/j62m+DsRTLuzZITVL21uYicjRavrG f2QoGqFDHKBy47p8C//H3osqOYvsHhorm7xmM2eEdNxL37/nMcLshUfXbRmA7nbw3gnH k9cM4vXwwjHSHi+DK+IhZesZ9M+ZCY8hvNvTvEifXv6c8KfFapHiWNilHqmsB9mgiVrK vbpws+SXdzRZXuC8Zq9jjktOvZ5xB+xjVf+orMPa5WvGLI7W1G2yBsVW16+sH0ghizkv hw/A== X-Gm-Message-State: APjAAAVSxhKqI8Ja/MUPdEP1h9K6Mq2z0MKjhcDnr0Vt4C4Po4xNLdfk 56DhTcCZ64xL7j72dFpLamo= X-Google-Smtp-Source: APXvYqxvHgvqSPGuGh+v9BXgG5WEaAHjCxJ+PK2aTuh/igv2sfuPFjVnFVMPMCX4gzOeDwEd6t+G0A== X-Received: by 2002:a63:1d45:: with SMTP id d5mr14543285pgm.184.1554830676980; Tue, 09 Apr 2019 10:24:36 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id v189sm83838525pgd.77.2019.04.09.10.24.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24: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 18/23] watchdog: 1: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:23:56 -0700 Message-Id: <1554830641-9247-19-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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 - Replace devm_add_action() followed by failure action with devm_add_action_or_reset() - Replace 'val = e; return val;' with 'return e;' - Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly - Use devm_watchdog_register_driver() to register watchdog device Signed-off-by: Guenter Roeck --- drivers/watchdog/sprd_wdt.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/drivers/watchdog/sprd_wdt.c b/drivers/watchdog/sprd_wdt.c index a63163a93777..14874e9b207b 100644 --- a/drivers/watchdog/sprd_wdt.c +++ b/drivers/watchdog/sprd_wdt.c @@ -245,9 +245,7 @@ static u32 sprd_wdt_get_timeleft(struct watchdog_device *wdd) u32 val; val = sprd_wdt_get_cnt_value(wdt); - val = val / SPRD_WDT_CNT_STEP; - - return val; + return val / SPRD_WDT_CNT_STEP; } static const struct watchdog_ops sprd_wdt_ops = { @@ -269,10 +267,11 @@ static const struct watchdog_info sprd_wdt_info = { static int sprd_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct sprd_wdt *wdt; int ret; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -280,57 +279,56 @@ static int sprd_wdt_probe(struct platform_device *pdev) if (IS_ERR(wdt->base)) return PTR_ERR(wdt->base); - wdt->enable = devm_clk_get(&pdev->dev, "enable"); + wdt->enable = devm_clk_get(dev, "enable"); if (IS_ERR(wdt->enable)) { - dev_err(&pdev->dev, "can't get the enable clock\n"); + dev_err(dev, "can't get the enable clock\n"); return PTR_ERR(wdt->enable); } - wdt->rtc_enable = devm_clk_get(&pdev->dev, "rtc_enable"); + wdt->rtc_enable = devm_clk_get(dev, "rtc_enable"); if (IS_ERR(wdt->rtc_enable)) { - dev_err(&pdev->dev, "can't get the rtc enable clock\n"); + dev_err(dev, "can't get the rtc enable clock\n"); return PTR_ERR(wdt->rtc_enable); } wdt->irq = platform_get_irq(pdev, 0); if (wdt->irq < 0) { - dev_err(&pdev->dev, "failed to get IRQ resource\n"); + dev_err(dev, "failed to get IRQ resource\n"); return wdt->irq; } - ret = devm_request_irq(&pdev->dev, wdt->irq, sprd_wdt_isr, - IRQF_NO_SUSPEND, "sprd-wdt", (void *)wdt); + ret = devm_request_irq(dev, wdt->irq, sprd_wdt_isr, IRQF_NO_SUSPEND, + "sprd-wdt", (void *)wdt); if (ret) { - dev_err(&pdev->dev, "failed to register irq\n"); + dev_err(dev, "failed to register irq\n"); return ret; } wdt->wdd.info = &sprd_wdt_info; wdt->wdd.ops = &sprd_wdt_ops; - wdt->wdd.parent = &pdev->dev; + wdt->wdd.parent = dev; wdt->wdd.min_timeout = SPRD_WDT_MIN_TIMEOUT; wdt->wdd.max_timeout = SPRD_WDT_MAX_TIMEOUT; wdt->wdd.timeout = SPRD_WDT_MAX_TIMEOUT; ret = sprd_wdt_enable(wdt); if (ret) { - dev_err(&pdev->dev, "failed to enable wdt\n"); + dev_err(dev, "failed to enable wdt\n"); return ret; } - ret = devm_add_action(&pdev->dev, sprd_wdt_disable, wdt); + ret = devm_add_action_or_reset(dev, sprd_wdt_disable, wdt); if (ret) { - sprd_wdt_disable(wdt); - dev_err(&pdev->dev, "Failed to add wdt disable action\n"); + dev_err(dev, "Failed to add wdt disable action\n"); return ret; } watchdog_set_nowayout(&wdt->wdd, WATCHDOG_NOWAYOUT); - watchdog_init_timeout(&wdt->wdd, 0, &pdev->dev); + watchdog_init_timeout(&wdt->wdd, 0, dev); - ret = devm_watchdog_register_device(&pdev->dev, &wdt->wdd); + ret = devm_watchdog_register_device(dev, &wdt->wdd); if (ret) { sprd_wdt_disable(wdt); - dev_err(&pdev->dev, "failed to register watchdog\n"); + dev_err(dev, "failed to register watchdog\n"); return ret; } platform_set_drvdata(pdev, wdt); From patchwork Tue Apr 9 17:23: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: 10891845 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 6EEF21515 for ; Tue, 9 Apr 2019 17:25:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57F152839C for ; Tue, 9 Apr 2019 17:25:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47CAC26E4F; Tue, 9 Apr 2019 17:25:14 +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 B3F5E26E4F for ; Tue, 9 Apr 2019 17:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726902AbfDIRYk (ORCPT ); Tue, 9 Apr 2019 13:24:40 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:42667 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726872AbfDIRYj (ORCPT ); Tue, 9 Apr 2019 13:24:39 -0400 Received: by mail-pl1-f194.google.com with SMTP id cv12so9793447plb.9; Tue, 09 Apr 2019 10:24: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=9wckhJHxSrM0tEjClZFzEqYk0LhohFKE4bYwFU5BfO8=; b=tWHcVwdh7iZ1KJO7SKn8rvrgz6u0RJtfuQplQLjcfaIn6q38WY9+yEiHJHK2+/1P0N LrNedCP0MrD93//XBBi+hxztvtQoftF/O1ys2ZfnhUpDlrG/7zEr210WmYlAc0BYfSit +pWOhIv4QwonUDkBPQcEqgeksbhfS+oLC9XoUhDEYI1AOvfGtXPARqN/HU9YFyS6SY+i Io1e8EfPZSorXyyAGR5jZGvVCb67rUIvrT2BtxM2pFImg+wZim20TDD9rLTZDr/3BYQD L/bPnTQAjMe4abtaFfakNdUEOr+V69CICGutJcPQUkWEyZpVKf5IHmDwcOd53mibYPdk U9kg== 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=9wckhJHxSrM0tEjClZFzEqYk0LhohFKE4bYwFU5BfO8=; b=bqIig1AYJD5dRM/pLQgB1jS4XsN7NKKEHXydpUpWDmVH/LPIUO/cRwFG8pJrR7bosn RSy+a6dTIpT22ojD5fOPo6oDCTIfIUy/zO3f/2c+297zrXsOsK9JQycVm8a6HGEpCqR4 iQvEzznnoZN6XzZlRbIxaCyhvDiAGyuh7nrVqxRTR9pzxdgsE1ykyY5PU1EizDuDhCuf Oxq/8Oh9dAhYLGK1uUXCjTL+LCwMxi/Q9k8L2YZEqsO1fUjxFoCZm9PSpE4tHjODOeRa IpaOz3RpyJMDQALDxnFIXlxja/Mxr25CGAKk9eAGTNHeQrcJEnvDC4mxx0L4TYYLUsoh VuNw== X-Gm-Message-State: APjAAAUVLuS30PhvcpXHIjcDVIBaITm+9CJWmrotdIPDypaUpPINOZiW UkTA4iv9PU8w4A8dWTdrHdU= X-Google-Smtp-Source: APXvYqxyYJu5C86rFwHmRR0EQfBRSnBr8/PtrIui34ZVy03cV+Hq7lcCW3gHMHQ85Ji82FsfNJiQvg== X-Received: by 2002:a17:902:2ec1:: with SMTP id r59mr38731835plb.171.1554830678364; Tue, 09 Apr 2019 10:24:38 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id p26sm75177403pfa.49.2019.04.09.10.24.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:37 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Patrice Chotard Subject: [PATCH 19/23] watchdog: st_lpc_wdt: Convert to use device managed functions Date: Tue, 9 Apr 2019 10:23:57 -0700 Message-Id: <1554830641-9247-20-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Use devm_add_action_or_reset() for calls to clk_disable_unprepare - Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly - Use devm_watchdog_register_driver() to register watchdog device Cc: Patrice Chotard Signed-off-by: Guenter Roeck Acked-by: Patrice Chotard --- drivers/watchdog/st_lpc_wdt.c | 47 ++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/watchdog/st_lpc_wdt.c b/drivers/watchdog/st_lpc_wdt.c index 196fb4b72c5d..9a5ed95c3403 100644 --- a/drivers/watchdog/st_lpc_wdt.c +++ b/drivers/watchdog/st_lpc_wdt.c @@ -142,10 +142,16 @@ static struct watchdog_device st_wdog_dev = { .ops = &st_wdog_ops, }; +static void st_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int st_wdog_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; const struct of_device_id *match; - struct device_node *np = pdev->dev.of_node; + struct device_node *np = dev->of_node; struct st_wdog *st_wdog; struct regmap *regmap; struct clk *clk; @@ -155,7 +161,7 @@ static int st_wdog_probe(struct platform_device *pdev) ret = of_property_read_u32(np, "st,lpc-mode", &mode); if (ret) { - dev_err(&pdev->dev, "An LPC mode must be provided\n"); + dev_err(dev, "An LPC mode must be provided\n"); return -EINVAL; } @@ -163,13 +169,13 @@ static int st_wdog_probe(struct platform_device *pdev) if (mode != ST_LPC_MODE_WDT) return -ENODEV; - st_wdog = devm_kzalloc(&pdev->dev, sizeof(*st_wdog), GFP_KERNEL); + st_wdog = devm_kzalloc(dev, sizeof(*st_wdog), GFP_KERNEL); if (!st_wdog) return -ENOMEM; - match = of_match_device(st_wdog_match, &pdev->dev); + match = of_match_device(st_wdog_match, dev); if (!match) { - dev_err(&pdev->dev, "Couldn't match device\n"); + dev_err(dev, "Couldn't match device\n"); return -ENODEV; } st_wdog->syscfg = (struct st_wdog_syscfg *)match->data; @@ -180,17 +186,17 @@ static int st_wdog_probe(struct platform_device *pdev) regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); if (IS_ERR(regmap)) { - dev_err(&pdev->dev, "No syscfg phandle specified\n"); + dev_err(dev, "No syscfg phandle specified\n"); return PTR_ERR(regmap); } - clk = devm_clk_get(&pdev->dev, NULL); + clk = devm_clk_get(dev, NULL); if (IS_ERR(clk)) { - dev_err(&pdev->dev, "Unable to request clock\n"); + dev_err(dev, "Unable to request clock\n"); return PTR_ERR(clk); } - st_wdog->dev = &pdev->dev; + st_wdog->dev = dev; st_wdog->base = base; st_wdog->clk = clk; st_wdog->regmap = regmap; @@ -198,39 +204,40 @@ static int st_wdog_probe(struct platform_device *pdev) st_wdog->clkrate = clk_get_rate(st_wdog->clk); if (!st_wdog->clkrate) { - dev_err(&pdev->dev, "Unable to fetch clock rate\n"); + dev_err(dev, "Unable to fetch clock rate\n"); return -EINVAL; } st_wdog_dev.max_timeout = 0xFFFFFFFF / st_wdog->clkrate; - st_wdog_dev.parent = &pdev->dev; + st_wdog_dev.parent = dev; ret = clk_prepare_enable(clk); if (ret) { - dev_err(&pdev->dev, "Unable to enable clock\n"); + dev_err(dev, "Unable to enable clock\n"); return ret; } + ret = devm_add_action_or_reset(dev, st_clk_disable_unprepare, clk); + if (ret) + return ret; watchdog_set_drvdata(&st_wdog_dev, st_wdog); watchdog_set_nowayout(&st_wdog_dev, WATCHDOG_NOWAYOUT); /* Init Watchdog timeout with value in DT */ - ret = watchdog_init_timeout(&st_wdog_dev, 0, &pdev->dev); + ret = watchdog_init_timeout(&st_wdog_dev, 0, dev); if (ret) { - dev_err(&pdev->dev, "Unable to initialise watchdog timeout\n"); - clk_disable_unprepare(clk); + dev_err(dev, "Unable to initialise watchdog timeout\n"); return ret; } - ret = watchdog_register_device(&st_wdog_dev); + ret = devm_watchdog_register_device(dev, &st_wdog_dev); if (ret) { - dev_err(&pdev->dev, "Unable to register watchdog\n"); - clk_disable_unprepare(clk); + dev_err(dev, "Unable to register watchdog\n"); return ret; } st_wdog_setup(st_wdog, true); - dev_info(&pdev->dev, "LPC Watchdog driver registered, reset type is %s", + dev_info(dev, "LPC Watchdog driver registered, reset type is %s", st_wdog->warm_reset ? "warm" : "cold"); return ret; @@ -241,8 +248,6 @@ static int st_wdog_remove(struct platform_device *pdev) struct st_wdog *st_wdog = watchdog_get_drvdata(&st_wdog_dev); st_wdog_setup(st_wdog, false); - watchdog_unregister_device(&st_wdog_dev); - clk_disable_unprepare(st_wdog->clk); return 0; } From patchwork Tue Apr 9 17:23: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: 10891843 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 5CF981515 for ; Tue, 9 Apr 2019 17:25:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B6EE28553 for ; Tue, 9 Apr 2019 17:25:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FBB628947; Tue, 9 Apr 2019 17:25: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 A61E42894C for ; Tue, 9 Apr 2019 17:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727020AbfDIRZI (ORCPT ); Tue, 9 Apr 2019 13:25:08 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46531 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726894AbfDIRYk (ORCPT ); Tue, 9 Apr 2019 13:24:40 -0400 Received: by mail-pl1-f195.google.com with SMTP id y6so9786214pll.13; Tue, 09 Apr 2019 10:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=RQNFeFQAIS9IcQnzgiGsF4bv+r8/UL2D7gAeGH/2zP8=; b=u/uDCxMfyJYUC9wKKiiREszTvY2wHTAHAVAQagHKdh/JWWn7ZEZu3fHo0vAbbRIkF9 GrrJa3PGVbIynVHH8fqTAFF9/INzvtFcpSlYq/qaSLzVknty0zTPdMUsEFL5nLV0EOxJ XuV/yHBg8kWIq4ThmK8yKu3iP1efUgcfnaAjg84gA/bigRNOQ1xpAH6Q/sMxfzkEug20 w6Q8v1HlYuMcriOokxWzLYcgDL+Aaj5aiP58dImiCQVtRkiSnGqmK3c1sHg3wjSMdMQP 9Y1QFGWhpSeSXB/WO6W/gv8m+ml6mHHSmJxoHtfqAd94lfz+lkkTrfP4jATVyiBY3k/7 /ufA== 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=RQNFeFQAIS9IcQnzgiGsF4bv+r8/UL2D7gAeGH/2zP8=; b=e/q9U6/0YZ/VtKCeErVk75OUBqnT1zEHDWp8Z15vNn4o/PRCmfpRn7VLFPXdLmVaxX k0Xim15PEYwgwE5nKHtzxNZOrfmq+aonv5XhI/kI+EBA6DzqvjTK6cQT73cm4e8SaV4R Kq7t3L6mMC5xr7uBgCQdKsXzZ1a+Yi+9+ho0Dlx+dkqj9A38jI+uD51YkXGiaFMbxSx8 86ZSRPDpZE3YLdOp8SibqgMpXPEkoy07OtNTO1MhmoLFeV/oDG06el6SbeLuDBYByvW+ QAA4uPkEmC9Wrucb7UXPpC+AX4wEuKF7yOIM0g5C0RY6IkRpQ2R0WOZiYgF3E8zHvLOt a9oA== X-Gm-Message-State: APjAAAW4QqudpfWRxiMh+shCeQXg14n8IeKWZhKDOIVDTQdYVTni5wGW M0gszp25cS2SamKI4nGDiwVZaXGG X-Google-Smtp-Source: APXvYqyN2Ln9xTqWl936KqgLjDq7Ij1yK1ABMygWKepDDZC5gmO7TT045JQewXBNA/kedsv1MB5UiA== X-Received: by 2002:a17:902:8a4:: with SMTP id 33mr38847467pll.7.1554830679831; Tue, 09 Apr 2019 10:24:39 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id q11sm47414470pgs.94.2019.04.09.10.24.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:39 -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 20/23] watchdog: stmp3xxx_rtc_wdt: Convert to use device managed functions Date: Tue, 9 Apr 2019 10:23:58 -0700 Message-Id: <1554830641-9247-21-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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. 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 - 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/stmp3xxx_rtc_wdt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/watchdog/stmp3xxx_rtc_wdt.c b/drivers/watchdog/stmp3xxx_rtc_wdt.c index 994c54cc68e9..671f4ba7b4ed 100644 --- a/drivers/watchdog/stmp3xxx_rtc_wdt.c +++ b/drivers/watchdog/stmp3xxx_rtc_wdt.c @@ -89,31 +89,31 @@ static struct notifier_block wdt_notifier = { static int stmp3xxx_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; - watchdog_set_drvdata(&stmp3xxx_wdd, &pdev->dev); + watchdog_set_drvdata(&stmp3xxx_wdd, dev); stmp3xxx_wdd.timeout = clamp_t(unsigned, heartbeat, 1, STMP3XXX_MAX_TIMEOUT); - stmp3xxx_wdd.parent = &pdev->dev; + stmp3xxx_wdd.parent = dev; - ret = watchdog_register_device(&stmp3xxx_wdd); + ret = devm_watchdog_register_device(dev, &stmp3xxx_wdd); if (ret < 0) { - dev_err(&pdev->dev, "cannot register watchdog device\n"); + dev_err(dev, "cannot register watchdog device\n"); return ret; } if (register_reboot_notifier(&wdt_notifier)) - dev_warn(&pdev->dev, "cannot register reboot notifier\n"); + dev_warn(dev, "cannot register reboot notifier\n"); - dev_info(&pdev->dev, "initialized watchdog with heartbeat %ds\n", - stmp3xxx_wdd.timeout); + dev_info(dev, "initialized watchdog with heartbeat %ds\n", + stmp3xxx_wdd.timeout); return 0; } static int stmp3xxx_wdt_remove(struct platform_device *pdev) { unregister_reboot_notifier(&wdt_notifier); - watchdog_unregister_device(&stmp3xxx_wdd); return 0; } From patchwork Tue Apr 9 17:23: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: 10891841 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 B1E7A1515 for ; Tue, 9 Apr 2019 17:25:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E3982839C for ; Tue, 9 Apr 2019 17:25:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9187528947; Tue, 9 Apr 2019 17:25:08 +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 35E152839C for ; Tue, 9 Apr 2019 17:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726513AbfDIRZC (ORCPT ); Tue, 9 Apr 2019 13:25:02 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42001 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726917AbfDIRYl (ORCPT ); Tue, 9 Apr 2019 13:24:41 -0400 Received: by mail-pg1-f193.google.com with SMTP id p6so9680840pgh.9; Tue, 09 Apr 2019 10:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=LjXyeY61Q8IuuG1hh9T51lQPEaZHlcAN/+KWHwI+dVE=; b=dXIHLeaKyxHPjUY4JJgxryi/6ufUxkP/CHFSdqR+fmn0stHaLNbGM5agKZyAKvgMTD EOF5aSlOlf59xUDvJy6CfvpYsn0M9fUhOgyO3LoyWnoiUCQPDQ3r1bDRgtGa1jpXJWs9 yD0ZZ1ZFC331fibCFf7eWP0QEEWFG4811ypbEUw1eDbieVcneiqnWyWFWRj8qJLKT0LQ L210dAJJ1HbGzBTlIwjh5zBW8MlF4VeMKX9MuZaIILM9VkwKFc6ZM52IJwdKQWz9sDju CwFns9vk6yZFC5AVJfqiZq2lDMQ+Ml1hZApt07Nsyfp+zr0XF3I+uAkWKAE1ruBJwZE1 ZnZw== 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=LjXyeY61Q8IuuG1hh9T51lQPEaZHlcAN/+KWHwI+dVE=; b=Wvp5xhUBZJ6bqmrMueURxIITvC9i/QhNq24RSLTzk5lHrBPQBz3WivSdAjy6G6NYBH +s7wj1hP1qA0JKqCidGz4ns4UFNa8ez+GQSPne6VqUnPKlhBSVpwFzsLhoZu17fVAXIL 6XKygLZRIGJ1qDy6Hrvjfu5giJBuCw29BG4DVYsix37R3KFrWDos4GCOo2NJQ6bMzHrq /8IKShL3ymHZPhEQhJncV3nQ1kaexde+gWfTR3nnU9h4hFd8bXDZnbESjG9ftVxNc0rp NL92rXeNzLPsy4f6G6FmV5eOVY4m7VdbpJaKmwVBLdYUp/InIig1Iz/MAiEAtCOA/iAG pmog== X-Gm-Message-State: APjAAAWCO9Fsddtm8cDOPbtahKDNtBpTD/RhX2Qyy8gSgH7lMAgRDG0p 0ea957eUAEXUO0Yo4hsGMvKqWbkO X-Google-Smtp-Source: APXvYqwwX4X15/vOJSIOcGoNs31H6HZ1IkyLKtNz6ucoR3CGTvSkSnFaYZjXFCbBiPa0GCd/lU9leA== X-Received: by 2002:a63:c104:: with SMTP id w4mr36190874pgf.409.1554830681136; Tue, 09 Apr 2019 10:24:41 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id s9sm17492543pfe.183.2019.04.09.10.24.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:40 -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/23] watchdog: stpmic1_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Tue, 9 Apr 2019 10:23:59 -0700 Message-Id: <1554830641-9247-22-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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/stpmic1_wdt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/watchdog/stpmic1_wdt.c b/drivers/watchdog/stpmic1_wdt.c index ad431d8ad95f..45d0c543466f 100644 --- a/drivers/watchdog/stpmic1_wdt.c +++ b/drivers/watchdog/stpmic1_wdt.c @@ -81,18 +81,19 @@ static const struct watchdog_ops pmic_watchdog_ops = { static int pmic_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; struct stpmic1 *pmic; struct stpmic1_wdt *wdt; - if (!pdev->dev.parent) + if (!dev->parent) return -EINVAL; - pmic = dev_get_drvdata(pdev->dev.parent); + pmic = dev_get_drvdata(dev->parent); if (!pmic) return -EINVAL; - wdt = devm_kzalloc(&pdev->dev, sizeof(struct stpmic1_wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(struct stpmic1_wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -102,15 +103,15 @@ static int pmic_wdt_probe(struct platform_device *pdev) wdt->wdtdev.ops = &pmic_watchdog_ops; wdt->wdtdev.min_timeout = PMIC_WDT_MIN_TIMEOUT; wdt->wdtdev.max_timeout = PMIC_WDT_MAX_TIMEOUT; - wdt->wdtdev.parent = &pdev->dev; + wdt->wdtdev.parent = dev; wdt->wdtdev.timeout = PMIC_WDT_DEFAULT_TIMEOUT; - watchdog_init_timeout(&wdt->wdtdev, 0, &pdev->dev); + watchdog_init_timeout(&wdt->wdtdev, 0, dev); watchdog_set_nowayout(&wdt->wdtdev, nowayout); watchdog_set_drvdata(&wdt->wdtdev, wdt); - ret = devm_watchdog_register_device(&pdev->dev, &wdt->wdtdev); + ret = devm_watchdog_register_device(dev, &wdt->wdtdev); if (ret) return ret; From patchwork Tue Apr 9 17:24: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: 10891839 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 F0B361708 for ; Tue, 9 Apr 2019 17:25:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80BB328329 for ; Tue, 9 Apr 2019 17:24:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74D752839C; Tue, 9 Apr 2019 17:24:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 095F528329 for ; Tue, 9 Apr 2019 17:24:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726946AbfDIRYn (ORCPT ); Tue, 9 Apr 2019 13:24:43 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:41327 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726938AbfDIRYn (ORCPT ); Tue, 9 Apr 2019 13:24:43 -0400 Received: by mail-pf1-f193.google.com with SMTP id 188so10102180pfd.8; Tue, 09 Apr 2019 10:24:42 -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=lKK60SRn4Yg+ug3ZuVwplfkDLIPIcVbLLqOT7dazmwU=; b=eTu6A/z3loUpBg9jMjGriS2YEdRi2lhXjNsk299FLuyTIlMs9mn5pXh9IK8usUqBCM bGVzRS62USkpvoAT993gZcysI7EFxALhiVeKM8Q2Qm3h4DnG6d+0FLOsB/VyBFahg201 XDxgsivig3v/J47SsN8JR5wnP3YK8vuTzzWag1v9rj17Tm8yk7d1TIO20uk6b9BTlCzi rjC3f3qzq5HHsYpRMyp5f4rx0UYx7TzBEf4iHHeA2it7S7bUxwxRgjirNJVuU8xbXZyP /UpHp+OX721fxmLsjGO7XZ6OoiHjRlE6ZtGKn6CAbylUhJmgu/swa1dbRhWaylzD5DA0 iQMA== 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=lKK60SRn4Yg+ug3ZuVwplfkDLIPIcVbLLqOT7dazmwU=; b=s2WXv5XCq4ygBgm9QNIF3aet53qq1lyhy9lPNVqqfbWV/YkwEo2umrl1VfRkgtrmKZ X+fMWvgM4J7UMoMGjviFrX5QcvJJnyMUaexlJWlFLen1i0iJRZTK/qrdg/3OKDdlsM5T RJR7q7BRdyWtOVO39ZanTUT0IafVIG8b2LCeBfGlw+oq8qEp+nxQLfV78375yWp7+NDS 6EUdY5WaXmJM4ZOkchfvQxq5UKAiBxNj/KxTks6YKroWol3QrW+lLDX8f/3gAPyJgL8m cKBb6374n3PUHMzuqRJH8Hlus04rEFs7gst9mqcGAWC0inB1i3Wz5usEmKRZgJq0w6H4 m5BQ== X-Gm-Message-State: APjAAAXivQLcmJX6QcABwRuLcrj21oIwnBXiAQYhRdwD74/cA5QJk3V9 sDOrzeUGsTI+Apk8Hks4eqU= X-Google-Smtp-Source: APXvYqwfI7ksbaYhkYikx2wZpQ4iyZ4y4kMAlflNq1y6hNW6n6dSs/KzPW88VTxWq22/2MJ2KTOkvw== X-Received: by 2002:a65:414a:: with SMTP id x10mr36248725pgp.237.1554830682425; Tue, 09 Apr 2019 10:24:42 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id x128sm34556912pfx.103.2019.04.09.10.24.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:41 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH 22/23] watchdog: sunxi_wdt: Use 'dev' instead of dereferencing it repeatedly Date: Tue, 9 Apr 2019 10:24:00 -0700 Message-Id: <1554830641-9247-23-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-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: Maxime Ripard Cc: Chen-Yu Tsai Signed-off-by: Guenter Roeck Acked-by: Maxime Ripard --- drivers/watchdog/sunxi_wdt.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/sunxi_wdt.c b/drivers/watchdog/sunxi_wdt.c index f0e7ef40b1e4..9c22f7753c6b 100644 --- a/drivers/watchdog/sunxi_wdt.c +++ b/drivers/watchdog/sunxi_wdt.c @@ -233,14 +233,15 @@ MODULE_DEVICE_TABLE(of, sunxi_wdt_dt_ids); static int sunxi_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct sunxi_wdt_dev *sunxi_wdt; int err; - sunxi_wdt = devm_kzalloc(&pdev->dev, sizeof(*sunxi_wdt), GFP_KERNEL); + sunxi_wdt = devm_kzalloc(dev, sizeof(*sunxi_wdt), GFP_KERNEL); if (!sunxi_wdt) return -EINVAL; - sunxi_wdt->wdt_regs = of_device_get_match_data(&pdev->dev); + sunxi_wdt->wdt_regs = of_device_get_match_data(dev); if (!sunxi_wdt->wdt_regs) return -ENODEV; @@ -253,9 +254,9 @@ static int sunxi_wdt_probe(struct platform_device *pdev) sunxi_wdt->wdt_dev.timeout = WDT_MAX_TIMEOUT; sunxi_wdt->wdt_dev.max_timeout = WDT_MAX_TIMEOUT; sunxi_wdt->wdt_dev.min_timeout = WDT_MIN_TIMEOUT; - sunxi_wdt->wdt_dev.parent = &pdev->dev; + sunxi_wdt->wdt_dev.parent = dev; - watchdog_init_timeout(&sunxi_wdt->wdt_dev, timeout, &pdev->dev); + watchdog_init_timeout(&sunxi_wdt->wdt_dev, timeout, dev); watchdog_set_nowayout(&sunxi_wdt->wdt_dev, nowayout); watchdog_set_restart_priority(&sunxi_wdt->wdt_dev, 128); @@ -264,12 +265,12 @@ static int sunxi_wdt_probe(struct platform_device *pdev) sunxi_wdt_stop(&sunxi_wdt->wdt_dev); watchdog_stop_on_reboot(&sunxi_wdt->wdt_dev); - err = devm_watchdog_register_device(&pdev->dev, &sunxi_wdt->wdt_dev); + err = devm_watchdog_register_device(dev, &sunxi_wdt->wdt_dev); if (unlikely(err)) return err; - dev_info(&pdev->dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)", - sunxi_wdt->wdt_dev.timeout, nowayout); + dev_info(dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)", + sunxi_wdt->wdt_dev.timeout, nowayout); return 0; } From patchwork Tue Apr 9 17:24: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: 10891837 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 931A01515 for ; Tue, 9 Apr 2019 17:24:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E4FB26E4F for ; Tue, 9 Apr 2019 17:24:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 703552837E; Tue, 9 Apr 2019 17:24:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5E8726E4F for ; Tue, 9 Apr 2019 17:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726938AbfDIRYr (ORCPT ); Tue, 9 Apr 2019 13:24:47 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33254 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726967AbfDIRYo (ORCPT ); Tue, 9 Apr 2019 13:24:44 -0400 Received: by mail-pl1-f196.google.com with SMTP id t16so9814266plo.0; Tue, 09 Apr 2019 10:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=LNDnzLXz1M9MSkyEZMz6quwTIkABp6XTHUa7hYI37yA=; b=oyvPZcHqnlHdgiRZDB5jsULoTOtPtknd2/Waso5/p6kHDzsFx3p3+dByrK489s7Rxk Hs/Ujzr28q7paOljX8GUYjOsZASMZK855GzwQaYluEDHhQK7H8g/O2g7EUkYcwaAtgLl f7oXQfcnJFPDXiH4uysFT4u++OyzOrS1y4kmM04OhOFbEWboBGtEKZzumgsvWo7BeU93 f04bnjt3uCmWgrdwafc0NaiqxnZYBPzfYCE4BoB3etDKWmFrOUjTO6jjw8p97zVHnOca OVwanvXv/vQraKWXWiVWRV54uyMM5D2MHjLt7IKxCWyB2ZBy+QckleKIdM3ZBaNJSA3+ nF6Q== 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=LNDnzLXz1M9MSkyEZMz6quwTIkABp6XTHUa7hYI37yA=; b=jjcruHs+Qpk5BA45ZvAmhoymlaNvUhZpoPUgVqqyZTSrBDZ6tzTmY+IZ6BTYsGa6Hh AGGCb0zRJO1fjt4J1ZmbRPFpeu54vsshT2TD/H/UCwEJbrTCz/hK3wYwLQlW7PD5Fbj0 OHgGRBQx+clCGyf2BNDqqngUn16O/24Kx9Yl1Zkt5lD3Hkpf0K4Ouo9eBTDjNjjou440 6S8Y7+IHKszEInyPc5FFNkTE2up7y+M0zuEw6nEnzhddl4rCvKaaUJ4bwWtfqd0vUYCE VCdFJAVA8wUQBbYLmGbl+SeW6X3vEb445Ppu7rLVBG4kH/Sb8t6gKwmXEGWaCj7heUQM PAWg== X-Gm-Message-State: APjAAAWQlisTvGnD1PFaviToJEFmoyX1bu5sDYIA6aWBQ3qt3P7F4yTx P4VKwyHi7hDMLpX2mx0yoqE= X-Google-Smtp-Source: APXvYqxZZ8RIukBlIh13zt56Di78o4PSlG2zS7O/1U4YoGaqEkhgh+1BPYEYB+YjLNecHVeaaEsrtQ== X-Received: by 2002:a17:902:d68d:: with SMTP id v13mr38736001ply.55.1554830683763; Tue, 09 Apr 2019 10:24:43 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k79sm15526383pfj.28.2019.04.09.10.24.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:43 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Marc Gonzalez , Mans Rullgard Subject: [PATCH 23/23] watchdog: tangox_wdt: Convert to use device managed functions and other improvements Date: Tue, 9 Apr 2019 10:24:01 -0700 Message-Id: <1554830641-9247-24-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-1-git-send-email-linux@roeck-us.net> Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop assignments to otherwise unused variables - Drop unnecessary braces around conditional return statements - Drop empty remove function - Use devm_add_action_or_reset() for calls to clk_disable_unprepare - Replace stop on remove with call to watchdog_stop_on_unregister() - Use devm_watchdog_register_driver() to register watchdog device Cc: Marc Gonzalez Cc: Mans Rullgard Signed-off-by: Guenter Roeck Acked-by: Mans Rullgard --- drivers/watchdog/tangox_wdt.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/drivers/watchdog/tangox_wdt.c b/drivers/watchdog/tangox_wdt.c index 16611fe0d9d1..1afb0e9d808c 100644 --- a/drivers/watchdog/tangox_wdt.c +++ b/drivers/watchdog/tangox_wdt.c @@ -108,6 +108,11 @@ static const struct watchdog_ops tangox_wdt_ops = { .restart = tangox_wdt_restart, }; +static void tangox_clk_disable_unprepare(void *data) +{ + clk_disable_unprepare(data); +} + static int tangox_wdt_probe(struct platform_device *pdev) { struct tangox_wdt_device *dev; @@ -129,12 +134,14 @@ static int tangox_wdt_probe(struct platform_device *pdev) err = clk_prepare_enable(dev->clk); if (err) return err; + err = devm_add_action_or_reset(&pdev->dev, + tangox_clk_disable_unprepare, dev->clk); + if (err) + return err; dev->clk_rate = clk_get_rate(dev->clk); - if (!dev->clk_rate) { - err = -EINVAL; - goto err; - } + if (!dev->clk_rate) + return -EINVAL; dev->wdt.parent = &pdev->dev; dev->wdt.info = &tangox_wdt_info; @@ -168,31 +175,16 @@ static int tangox_wdt_probe(struct platform_device *pdev) watchdog_set_restart_priority(&dev->wdt, 128); - err = watchdog_register_device(&dev->wdt); + watchdog_stop_on_unregister(&dev->wdt); + err = devm_watchdog_register_device(&pdev->dev, &dev->wdt); if (err) - goto err; + return err; platform_set_drvdata(pdev, dev); dev_info(&pdev->dev, "SMP86xx/SMP87xx watchdog registered\n"); return 0; - - err: - clk_disable_unprepare(dev->clk); - return err; -} - -static int tangox_wdt_remove(struct platform_device *pdev) -{ - struct tangox_wdt_device *dev = platform_get_drvdata(pdev); - - tangox_wdt_stop(&dev->wdt); - clk_disable_unprepare(dev->clk); - - watchdog_unregister_device(&dev->wdt); - - return 0; } static const struct of_device_id tangox_wdt_dt_ids[] = { @@ -204,7 +196,6 @@ MODULE_DEVICE_TABLE(of, tangox_wdt_dt_ids); static struct platform_driver tangox_wdt_driver = { .probe = tangox_wdt_probe, - .remove = tangox_wdt_remove, .driver = { .name = "tangox-wdt", .of_match_table = tangox_wdt_dt_ids,