Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4070346yba; Tue, 9 Apr 2019 10:28:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlVPt3Ys/l5R13ZJbbzD7NpGai4EmDhGgtLYjT6b28ckXsXPy6aiFrQmv250ZqjRckEnUC X-Received: by 2002:a62:388d:: with SMTP id f135mr37917698pfa.103.1554830915414; Tue, 09 Apr 2019 10:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554830915; cv=none; d=google.com; s=arc-20160816; b=oa8NT0dK1EKGkht/G4My2ZykbM91QDefeDHP9ZlyBnqE7OAPQBQkLJwbBeaY47ARMG 9X41ZiSf33OY6I2AQ/fKBfxGA8/R6p7j1osrAbBxmw+6bQklXJGRiBM8hiUrCO/Q4nj0 r6bgEYjA2cFEXjfsMJPW2azfv6w98na17/p8bRzvdYIBUbCzdGSyd9AozQxD6tEx/EQ+ LaJH14rWsu3Cly1X1e0png3CtWNH8eBICGenZXLFiFlfXWHOJOYuNSzFgca+6mLkUXgQ ZZ17DVRGBciQBVc8BWqZps/OU5hlyqx27G161aRNTDzlsabBx1mOJY/UCD5A6Z3xZi7C /o9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=JZEYa3ly8OHfRyblvnsc1Mq4A63GITyn9+eW6LRG6T8=; b=SGM3iF+R0OqjNu2mxq92TZU+utmpjIX6yr3Fh0Eqq0fCr08ozA0OV2rp8qxVeBnuOK D4ZXb1my9QlIvgJE9+rmJRBh3Z+PN+WutuBxV7i4EdRJ8/JdY2KcxJa8nNkBWndeFQiN Ta2HgJaIw4DgfK9B8EH3cGk6CThWPTutchThpT+L2o0kiXN9Z7tj11vVG6UUaMF8H54q q30O8hIGa1wEJsvL47Asr5A2LqdQZjl/iIkBTPGIjGoCdSVNXR4sw6uXWj6DnXyZkMxg nmLG/qQbKFzawbWRoEspHjKxkxfVVNLHzCuu4XnjhusV5MRFn6ASOU2umJhQduKrIWbB CnSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=a2hfqMMq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g62si10505975pgc.44.2019.04.09.10.28.19; Tue, 09 Apr 2019 10:28:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=a2hfqMMq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbfDIRY3 (ORCPT + 99 others); Tue, 9 Apr 2019 13:24:29 -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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. Other improvements as listed below. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Drop 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, -- 2.7.4