Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1940602ybv; Sun, 23 Feb 2020 18:58:54 -0800 (PST) X-Google-Smtp-Source: APXvYqw/+xqJAxHjvcRKZA5xPFJjvVnVJ2/kTUBwb0i+U5r/d3FlTUvbFaHGl6vdQiq/d77/nFnZ X-Received: by 2002:aca:5588:: with SMTP id j130mr3772773oib.122.1582513134744; Sun, 23 Feb 2020 18:58:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582513134; cv=none; d=google.com; s=arc-20160816; b=CSeVMwY+nM6a4okAZmGMz1KGRNayqC0rn5fKU+6YdjdoifiUtVDnrQEqczc2DTsJY6 hVbEcOHxOyuUYi1QqQypR+/vVpq6LQoNeoavGUU2r5F6qK0vS/LJXKR/LhLTikYiSyhy ve9YVl5iSqyEt8NZEGxhoC2x2FUQqn7+3ViskpNyA1jsdhOZIyYATCE2UYHQLmRCt92j m5UDn/bQ5Nrs+84qChFi3J9Da42ZHetH52cfFVeuCX+kLb6CNqNhsnRyL4qxF/30okDZ sP8nXhnrASlORv7hyx6cw6Zxk376XlKKR54i4RH/bcIix8u9VrC/AVdkyISszY0kQUwy 5h0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=rViyB+EN9fDECsdyCRQ9zzxv9MrYiRlbWUngqqOLaL0=; b=tHpABNDh1B6hIk2kqNftFtS3ZpVhP95TZISBnDmH+LFgOSi2fyn/2zQC4gI9aQ5FKj Tppufko2nA6Jlg2ymJBqj/YML52JmaBST7CAy9a0akYqQI+U1g883fDXCHTthISKFx00 jPz55gPeG01XuHfVRIyGPkeVYEPUkATL7YbI1V9G6wNsFoKEjiSYys24VD5fjvwMDAjC +uKTcwgDWapmhhkgFUK5/a9+WZL7uSb/g6DJ5IWNoH7DV09SVh4imMnQCSTQ9RUwFJjY j/qTAwq4H7r31tl+4ummYuu47nVmUkSq7dq8zOfm1M5y4m64vsVhWiUSMo8lpD3ijDYj hMCg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v22si4651307oia.30.2020.02.23.18.58.42; Sun, 23 Feb 2020 18:58:54 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727188AbgBXC5f (ORCPT + 99 others); Sun, 23 Feb 2020 21:57:35 -0500 Received: from inva021.nxp.com ([92.121.34.21]:56216 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727158AbgBXC5e (ORCPT ); Sun, 23 Feb 2020 21:57:34 -0500 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 7EDB020CD73; Mon, 24 Feb 2020 03:57:32 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 36B8C204377; Mon, 24 Feb 2020 03:57:27 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 8E19E402B3; Mon, 24 Feb 2020 10:57:20 +0800 (SGT) From: Anson Huang To: 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 Cc: Linux-imx@nxp.com Subject: [PATCH] watchdog: imx2_wdt: Drop .remove callback Date: Mon, 24 Feb 2020 10:51:27 +0800 Message-Id: <1582512687-13312-1-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org .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); +} + 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); - - 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"); - } - return 0; + return devm_watchdog_register_device(dev, wdog); } static void imx2_wdt_shutdown(struct platform_device *pdev) @@ -417,7 +401,6 @@ static const struct of_device_id imx2_wdt_dt_ids[] = { MODULE_DEVICE_TABLE(of, imx2_wdt_dt_ids); static struct platform_driver imx2_wdt_driver = { - .remove = __exit_p(imx2_wdt_remove), .shutdown = imx2_wdt_shutdown, .driver = { .name = DRIVER_NAME, -- 2.7.4