Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4962521yba; Wed, 10 Apr 2019 08:28:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiORgMb5GRrupp7jDAW0jkjyaAoyJ8IXErlEZyCG/ynePkF3CnU3B5Y+Njr/PjBn9uXTRO X-Received: by 2002:a65:51c9:: with SMTP id i9mr41763982pgq.187.1554910129193; Wed, 10 Apr 2019 08:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554910129; cv=none; d=google.com; s=arc-20160816; b=ggjKj77FBF9DISBXmZMwbSvt8MkfAh27Y77QKu6kNr42vSTMXr4d//ARgrjuDadu4K 1jE9el8sQfUT02JUyE6iFnoH8rY3oJU+5RrsdMPftmq8INLc4GvTXmAFRBiYlHMgG1QP iIzK2TRuw+Ttzov7wn9EZ/ToLjULojQc57xnRjHTKFw8NXQ2y3f4Ux6PJqU7MFcWKRsx yQ1O9FakWrgIZIY8oAUtl5Wv+cimgbqY/rLBOEspYPwxrnQcUDPpjxF4tKA33bFS/qMX bUCUybTbEEJ8ipFXB2s5cXUryqY8EA+/G63slzIRz9iVPKn2YBD5kmHdz/4Gc4CcM8S5 fNuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from; bh=iSi5PgUwsPliUkgW3/fxq7Pllz8IQMfII9fLbQIXraA=; b=wv06gocQIrOUDKErTaH8EenzMrx7XaiNIgCYlDtIQ0A20h1mtyh6ryPMPx9J3Ocq59 K2I/i0JajciSQgA1NUwDImcULVI9Yyv6Urng7hVbWKjkrMdUEM2uh1KP2HWH1BI4ioHw PgRUh0pbZy2qf8CDPFBF/dH3fc2f+XdsxvGmKpJ4Q+2YKFCQkAr7ELmaQOkFGxG/WXAZ CKdzwWdIW0QiOtzCLfQHpT3GvUCyhsWgbH/wzLZh3QmIxpHsgz+eGyHD85PalDnDQi6t SZ0/fXrJCZIEfg2E9dOxIHx+UFLt3PNpbMMBwvejAsrK5LxHZsz+PNkKvdbki4AsV8sB +cCQ== ARC-Authentication-Results: i=1; mx.google.com; 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 t66si33661122pfb.178.2019.04.10.08.28.33; Wed, 10 Apr 2019 08:28:49 -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; 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 S1730741AbfDJLUk convert rfc822-to-8bit (ORCPT + 99 others); Wed, 10 Apr 2019 07:20:40 -0400 Received: from unicorn.mansr.com ([81.2.72.234]:35072 "EHLO unicorn.mansr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729508AbfDJLUk (ORCPT ); Wed, 10 Apr 2019 07:20:40 -0400 Received: by unicorn.mansr.com (Postfix, from userid 51770) id 8F29417C68; Wed, 10 Apr 2019 12:20:38 +0100 (BST) From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= To: Guenter Roeck Cc: Wim Van Sebroeck , linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Marc Gonzalez Subject: Re: [PATCH 23/23] watchdog: tangox_wdt: Convert to use device managed functions and other improvements References: <1554830641-9247-1-git-send-email-linux@roeck-us.net> <1554830641-9247-24-git-send-email-linux@roeck-us.net> Date: Wed, 10 Apr 2019 12:20:38 +0100 In-Reply-To: <1554830641-9247-24-git-send-email-linux@roeck-us.net> (Guenter Roeck's message of "Tue, 9 Apr 2019 10:24:01 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Guenter Roeck writes: > 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 > --- > drivers/watchdog/tangox_wdt.c | 37 ++++++++++++++----------------------- > 1 file changed, 14 insertions(+), 23 deletions(-) Acked-by: Mans Rullgard > 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, > -- > 2.7.4 > -- M?ns Rullg?rd