Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp226213imu; Fri, 25 Jan 2019 01:01:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN7RdGv38xpzwqnUQ2xl/yjnWI7f7yQc84Rl4G2cXCcV3msMi/pDk/pXT6Y+DYC9xhU9HbRB X-Received: by 2002:a17:902:b03:: with SMTP id 3mr9981298plq.91.1548406917789; Fri, 25 Jan 2019 01:01:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548406917; cv=none; d=google.com; s=arc-20160816; b=iURCcmIOcgOPowQUMFma2XmjNw4OX/bLT2wLSIPmAMJk+++FtB8dYHUOI0LIiTqwYp RDGQubyotX6kO9qR/kSv7WggM811tdyFOIHNL/oZ6LTHF1Is9A8ORt9RWRv6Ky/yJRtp wp7+XmZh9a4v86mHndJhonqisvaS36VCMFcIXWwXYRguMz5vchjcPTh9x1nDHyXSrnxd 2+KdCPs+MjJdyRgdjXU9YHs7Qu/oVf9WcnQQUjH0uO0ADLDYc/4L2iK7aMj+ScikwDJ9 CjBT/TKAGLamM/ay0WwU69U482D1eNGVXx9rynLf+Ho5yDq9o5bajoFPeit/uCrmp0lt 8KxQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Lof1WbwTjGl75f5jNQ9eVMxww+CPak/791xsS0EsAC4=; b=joGEPWILnkmwpA9kd61sN2/1rqwf2E0Zb3ZBWg3iPM1D1a8n/46OkG/qntsGuvL5MS ctLUE1yhvm2fOFSnfXn7m1ppyepoLu7B/OTvzqrXa3jxgfhiP4rhv1eQsh6KQDuUEvqv 01cAOmYJR/umCulTf+Zn7cMZVemU0s2ZA/0Of3iJIQS9Ls4eK9S2YDVAh0jzEp+5xz8B Wx/bqlpK52HO5big2ti6kqnnNU5A+W/0/4vznJLKy1je9mSyhlu/XLyWCDgGG5H47LVA OMje6RTtW+XP0pzuB5wA4W08vtOUQWVYEn/WTHwHFA9Dcfn8fHVZif0AjBEGFEYAOAHj NxWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=enOPhhM0; 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 69si21403496pgc.164.2019.01.25.01.01.41; Fri, 25 Jan 2019 01:01:57 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=enOPhhM0; 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 S1727749AbfAYJBg (ORCPT + 99 others); Fri, 25 Jan 2019 04:01:36 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39137 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726200AbfAYJBf (ORCPT ); Fri, 25 Jan 2019 04:01:35 -0500 Received: by mail-pf1-f194.google.com with SMTP id r136so4459646pfc.6; Fri, 25 Jan 2019 01:01:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Lof1WbwTjGl75f5jNQ9eVMxww+CPak/791xsS0EsAC4=; b=enOPhhM05VgvWKUUi4rvUOTKX2cKuLR/DU0oGjWNeDQGGOuYwAgm8QNAA80FFI/IBH FqBHTkgWihM+kNqorMexR25h86ZnhAA1Buk1J5bRVSG3J0Y9oFmJkoarkZXmCFwe+5rR r1p7uAW1dMW9biSUdYMB2d+UZ5ne7/6o3bOFuQEiIE/q5YawGY9Pk7r2sYfyhcgZILzK UYx7OUZDNYpy6g8T/wP4SGKoecaBOk55gTfL/2NEA6jfJ38xiivA0M/qy/vPXSEye46V 2AS3KFi2pE8iZmNNFr8eO7e094a/SFW3wX+wog3hut3jyRL5EKEIuocH6hrlhty4m2ND PQgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Lof1WbwTjGl75f5jNQ9eVMxww+CPak/791xsS0EsAC4=; b=blvrJyzlstOZjxGLFRitQi3LYY8m0btu12U1c+7O+9Xbn8/T2CHtCndp50VpFUw4cn 9/qUbMDHkw0hAiodkJbhUqkHk3jPEznh2mE/IM3zJQLVom40EpRqv5OeLEoX5fgoUOXe 3FhA0XaSprJTqrT5d27L7Mfn/UGBgyKgN5Q0eV8jnB11MVDjg0EWZG0LPN0tK0eBaMCj 7EWMu1s1g04NeZKj9k/TPRD2Zhx7e07eftsZZjlrcigLazuhT3iU0kZnhVijfRdANntx XpPRF2l0sSBzJErj0lPBVozuyhv+BtRxwwrZlHQ6AkOT94W/l3T2f+IDiDbB59C028Rz ko0g== X-Gm-Message-State: AJcUukfqh/xQV6R99aJzBMXybgh9TYtQp38XllFP9th99kH7JOASojnE My5nEPKQlymEbSZms+F2rORHIS2Y X-Received: by 2002:a62:1d8f:: with SMTP id d137mr10011181pfd.11.1548406894406; Fri, 25 Jan 2019 01:01:34 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id t3sm24667462pgv.31.2019.01.25.01.01.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jan 2019 01:01:33 -0800 (PST) Subject: Re: [PATCH] watchdog: dw: use devm_watchdog_register_device() To: Jisheng Zhang Cc: Wim Van Sebroeck , "linux-watchdog@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20190125154604.66801c6a@xhacker.debian> <20190125161049.7884cda4@xhacker.debian> From: Guenter Roeck Message-ID: <4414c144-ebdd-2c16-7268-1e11d5a682cd@roeck-us.net> Date: Fri, 25 Jan 2019 01:01:31 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190125161049.7884cda4@xhacker.debian> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/25/19 12:17 AM, Jisheng Zhang wrote: > Hi, > > On Fri, 25 Jan 2019 00:04:25 -0800 Guenter Roeck wrote: > >> Hi, >> >> On 1/24/19 11:52 PM, Jisheng Zhang wrote: >>> Use devm_watchdog_register_device() to simplify the code. >>> >>> Signed-off-by: Jisheng Zhang >>> --- >>> drivers/watchdog/dw_wdt.c | 3 +-- >>> 1 file changed, 1 insertion(+), 2 deletions(-) >>> >>> diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c >>> index 501aebb5b81f..c053c2de5c2f 100644 >>> --- a/drivers/watchdog/dw_wdt.c >>> +++ b/drivers/watchdog/dw_wdt.c >>> @@ -303,7 +303,7 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) >>> >>> watchdog_set_restart_priority(wdd, 128); >>> >>> - ret = watchdog_register_device(wdd); >>> + ret = devm_watchdog_register_device(wdd); >>> if (ret) >>> goto out_disable_clk; >>> >>> @@ -318,7 +318,6 @@ static int dw_wdt_drv_remove(struct platform_device *pdev) >>> { >>> struct dw_wdt *dw_wdt = platform_get_drvdata(pdev); >>> >>> - watchdog_unregister_device(&dw_wdt->wdd); >>> reset_control_assert(dw_wdt->rst); >>> clk_disable_unprepare(dw_wdt->clk); >>> >>> >> Unfortunately it isn't that easy. The other two calls have to be executed after >> unregistering the watchdog, meaning you would have to add devm_add_action() >> in the probe function to call them. > > do you mean reset_control_asser() and the clk_disable_unprepare()? If yes, Yes. > does unregister the watchdog could trigger any register access? Per my > understanding, there's no register access path in the unregister. Am I > missing somthing? > If the watchdog is unregistered last, it would be still accessible via its device nodes, even though the clock has been reset, and even though the HW has been put in reset. This would be racy. Guenter