Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2273635ybv; Mon, 24 Feb 2020 02:23:48 -0800 (PST) X-Google-Smtp-Source: APXvYqxDMjButii2kgs8MOno0ZR3TpazweK++IQ7Utm9eu/XHSkPulElNjVzZ3ruwDJ2+TTGqDpb X-Received: by 2002:aca:1c09:: with SMTP id c9mr12333996oic.85.1582539828044; Mon, 24 Feb 2020 02:23:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582539828; cv=none; d=google.com; s=arc-20160816; b=f8tNgMQa5bDKsu3pHpAm4WmDNJCUBdKtCLt/N+CstTAqiYRC1EyBvjdStpUTVEPxRi ZqN8USnYWkmbCO1YdVZb9iLIy4lYkMnlGE8nCunXogGN8ah89/PBf7714WVJV4Fb5T7R ylmdXqAdpp0B+r8K/tsiV4Z2sv8TOHD9eqA9axf3VbiFS/drQLmiQSKP5Kihq5foAo8w JSXewtanGxc7No7FjeavtWl1ehjXRMQ8qHiZKpONDpOrpHO489b2IEq0aOyaYqI2DKWD XlKqkbOWKRvx7thzEoma4HqRj+dxQ2X9pnY12/2FNR0o/7vCZ134sELPDtj+CEug1a4K YKcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=H9nJO2skWVmsEdqZSQWKXWqKYG+IaXUx6OizldbFuUQ=; b=su/i5ZWxwMuSgMctc+nUzRMqkdatwIgB1Ug/aER1eqjpDCFQ7Fz9wba6LHAEU2kXkb TFwwGwq5GO58FN2b0xzPVsPKEpWx3xG5OHtzVnMLIX/wxOGHd/bCxVfr2qdRp26ZX5lU Mic+c66kKRKvLPNOMTJHs0AyUT+k3o9/aWSWET92tC8K9/+w5QZlgbKbLU5++yy/2WCi wi1oEYIjOyjS7SAbwctz4UEAmlL7QfImb3df3p07YlpFZF/SSYVNaUMVZZjaFxQ+GY42 /40ex5VEGycXmbB49vqmTSC9GBw7XxfMXbOZ2DkzG2x9QWFbr2rkTiybGLgmd+J1eP6i WsDw== 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 i15si4768906oik.46.2020.02.24.02.23.35; Mon, 24 Feb 2020 02:23:48 -0800 (PST) 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 S1727290AbgBXKWZ (ORCPT + 99 others); Mon, 24 Feb 2020 05:22:25 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:55547 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726509AbgBXKWY (ORCPT ); Mon, 24 Feb 2020 05:22:24 -0500 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j6AsO-0006AU-OD; Mon, 24 Feb 2020 11:22:12 +0100 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1j6AsN-00010t-EU; Mon, 24 Feb 2020 11:22:11 +0100 Date: Mon, 24 Feb 2020 11:22:11 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Anson Huang Cc: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Linux-imx@nxp.com Subject: Re: [PATCH] watchdog: imx2_wdt: Drop .remove callback Message-ID: <20200224102211.clzqw4vtzc4nz5df@pengutronix.de> References: <1582512687-13312-1-git-send-email-Anson.Huang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1582512687-13312-1-git-send-email-Anson.Huang@nxp.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 24, 2020 at 10:51:27AM +0800, Anson Huang wrote: > .remove callback implementation doesn' call clk_disable_unprepare() which > is buggy, actually, we can just use devm_watchdog_register_device() and > devm_add_action_or_reset() to handle all necessary operations for remove > action, then .remove callback can be dropped. > > Signed-off-by: Anson Huang > --- > drivers/watchdog/imx2_wdt.c | 37 ++++++++++--------------------------- > 1 file changed, 10 insertions(+), 27 deletions(-) > > diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c > index f8d58bf..1fe472f 100644 > --- a/drivers/watchdog/imx2_wdt.c > +++ b/drivers/watchdog/imx2_wdt.c > @@ -244,6 +244,11 @@ static const struct regmap_config imx2_wdt_regmap_config = { > .max_register = 0x8, > }; > > +static void imx2_wdt_action(void *data) > +{ > + clk_disable_unprepare(data); Does this have the effect of stopping the watchdog? Maybe we can have a more expressive function name here (imx2_wdt_stop_clk or similar)? Is there some watchdog core policy that tells if the watchdog should be stopped on unload? > +} > + > static int __init imx2_wdt_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) > if (ret) > return ret; > > + ret = devm_add_action_or_reset(dev, imx2_wdt_action, wdev->clk); > + if (ret) > + return ret; > + > regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val); > wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0; > > @@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) > */ > regmap_write(wdev->regmap, IMX2_WDT_WMCR, 0); > > - ret = watchdog_register_device(wdog); > - if (ret) > - goto disable_clk; > - > - dev_info(dev, "timeout %d sec (nowayout=%d)\n", > - wdog->timeout, nowayout); Does the core put this info in the kernel log? If not dropping it isn't obviously right enough to be done en passant. > - return 0; > - > -disable_clk: > - clk_disable_unprepare(wdev->clk); > - return ret; > -} > - > -static int __exit imx2_wdt_remove(struct platform_device *pdev) > -{ > - struct watchdog_device *wdog = platform_get_drvdata(pdev); > - struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); > - > - watchdog_unregister_device(wdog); > - > - if (imx2_wdt_is_running(wdev)) { > - imx2_wdt_ping(wdog); > - dev_crit(&pdev->dev, "Device removed: Expect reboot!\n"); > - } I also wonder about this one. This changes the timing behaviour and so IMHO shouldn't be done as a side effect of a cleanup patch. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | https://www.pengutronix.de/ |