Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10898680ybi; Thu, 25 Jul 2019 06:45:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6Wy6Pv3+6c7NM/3kLcRVXvHxTUjCe/B0PSkH5Il5mc2+kNCowk2MCgzKHj5YWwfhwQoFT X-Received: by 2002:a63:b1d:: with SMTP id 29mr86467342pgl.103.1564062351476; Thu, 25 Jul 2019 06:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564062351; cv=none; d=google.com; s=arc-20160816; b=q4EWwI11/4uayUgTIWygfMAR5QyFgQ4nL2vD18i2Liy9bKR7SQIf/ZDpwnwIYQMWWD 0XoRXBzkpHQsTSWG2J0+GrmgSvXuoVy1nXHL8QrLuWN5VJCtclucqIhpkIaTSR04X6aJ /p4QBMeWZXy5iDkftpa1gfmf1exRxbKNaENlDP4t19wO3Sn0U5GNlUbENU0BHo4oLWJd ca6FNVNnvNTvmfkqeQKH3ANGrFhqd7J27nZUQnkL+mtFbATcXM9wPP6iupZMUHath5Ib THVJZgC5wp2J/lVLzl6NmJy2UEgM3hL25iA9UsJD3bVMYMePOPfC7El/90YaJjQ6Q4nC 5SXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=KhuBXKW1pqwu3I/a51C/lMMrHG93yOL/odw0jXksmsM=; b=yYWp1juSWX8SJ2UiGw3UZNTy9gmsabE/oxgy57+3fyq+56Kg2mspEC1NoHeZDVe/3R fZDpiE4VRMuQ7DH4yJ0bfgdXyNvEb0QjpsiBhuvfvvSVo6U2msdowkeb9XNH+cxX0AxP 8nIeYKkAqVpHMRBuo5+PYXbbW/JLC/avXRdlzG5YFol6fYoqof6hQSkgOsVzIny+ZdjU Lzq8VORKFb2AdkySgQpw2+VoXSlo7of1mwKvrpFk5m3F47zZTf2IX9zVRSQdUQV5oxZi sQ8dD0hIlvLJCL488Faa6guVcUeO6qEjDoCuN/9UJOLowLCir5wAhmYMGVGiquCsDfMa 2psw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@essensium-com.20150623.gappssmtp.com header.s=20150623 header.b="NFaF/0+H"; 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 w184si21126649pgd.394.2019.07.25.06.45.37; Thu, 25 Jul 2019 06:45:51 -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=pass header.i=@essensium-com.20150623.gappssmtp.com header.s=20150623 header.b="NFaF/0+H"; 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 S2391885AbfGYLb4 (ORCPT + 99 others); Thu, 25 Jul 2019 07:31:56 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:37698 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391826AbfGYLbz (ORCPT ); Thu, 25 Jul 2019 07:31:55 -0400 Received: by mail-oi1-f196.google.com with SMTP id t76so37431480oih.4 for ; Thu, 25 Jul 2019 04:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=essensium-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KhuBXKW1pqwu3I/a51C/lMMrHG93yOL/odw0jXksmsM=; b=NFaF/0+HWBocaTISPRN64FldkQJsCLdLOvTsLvCXfup95wjAONzWuBKO5ZBfS6oF1J ekdw5EqRu1vDsLkUPP8yayxmbdrOGMKKvDgdSqTumrq/ZI2blPkLolJokz3tMpSz5Od7 HWqfiq+FtTHlUP+8d6HXhtaQyDxiNFxwvQFtqs/IPrI2nN9+kLAbJhhHho20DwC9vkII iPPEL36enx+NCendroTEzk3RZ2eR4hq/QsxLtDL7oviQHOAk7K1QoZ4arpkFtKrTG0OF 2qXJXB2jE18QVAJwsyM2BX8o5PSu/f32LtkYRTY6e+0sXgxGSTCjNCgu8MFCj2e64/FE njZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KhuBXKW1pqwu3I/a51C/lMMrHG93yOL/odw0jXksmsM=; b=kV1UVxCyYC7nP7q21kWOLIf4Q9t1C9TTSCHaPXo4H/1W6VQ5VvobKOaeJdS6jjSZgU MJDsIwo2g68zFfZt4Hg1mYzcWpwwZaPGXsdN/LWtTuSZRi0L5wMzgMFsJus4pOd++4RQ URRsYEgpsIhmqflzgd9OEO5L6BwK40RVt8l8QfUU3uPb/tj73LoPH1LuAeRRqk8lN8PO 8USrQdKOBxbuOhH9DQ4GoLwwYdX7okAw2m4H3IV3FIO37//F+3iameZR4a21AZ8Xns8j xfTF8KryjutrrZX3C3kXwmzf6R8/YQNGh7Jco3yHHo82dBtXrlD/Ge+0m6tBPQLzXba1 ClaQ== X-Gm-Message-State: APjAAAWyQP98MSGCjB587w6yAA8MxBks2wTG9RZrrSSZjkpA8UHp/uXR tHxx1tlG1QU7yfTQue0h2VCf3Zcil/iFJfaSoE7vvg== X-Received: by 2002:a05:6808:8d3:: with SMTP id k19mr41623577oij.164.1564054314741; Thu, 25 Jul 2019 04:31:54 -0700 (PDT) MIME-Version: 1.0 References: <20190725085458.21838-1-hslester96@gmail.com> In-Reply-To: <20190725085458.21838-1-hslester96@gmail.com> From: Patrick Havelange Date: Thu, 25 Jul 2019 13:31:43 +0200 Message-ID: Subject: Re: [PATCH] counter/ftm-quaddec: Use device-managed registration API To: Chuhong Yuan Cc: William Breathitt Gray , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Comments inline On Thu, Jul 25, 2019 at 10:55 AM Chuhong Yuan wrote: > > Make use of devm_counter_register. > Then we can remove redundant unregistration API > usage to make code simpler. > > Signed-off-by: Chuhong Yuan > --- > drivers/counter/ftm-quaddec.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/counter/ftm-quaddec.c b/drivers/counter/ftm-quaddec.c > index 68a9b7393457..bccbca8681b6 100644 > --- a/drivers/counter/ftm-quaddec.c > +++ b/drivers/counter/ftm-quaddec.c > @@ -317,7 +317,7 @@ static int ftm_quaddec_probe(struct platform_device *pdev) > > ftm_quaddec_init(ftm); > > - ret = counter_register(&ftm->counter); > + ret = devm_counter_register(&pdev->dev, &ftm->counter); > if (ret) > ftm_quaddec_disable(ftm); > > @@ -328,8 +328,6 @@ static int ftm_quaddec_remove(struct platform_device *pdev) > { > struct ftm_quaddec *ftm = platform_get_drvdata(pdev); > > - counter_unregister(&ftm->counter); > - The orders of (de)initialization should be kept symmetrical. In this case, now that counter_unregister() will be called via devm, it will be executed after ftm_quaddec_remove() This introduces a race condition where the ftm-quaddec is disabled but the counter entry itself is not. Somebody else (William?) should confirm this. > ftm_quaddec_disable(ftm); > > return 0; > -- > 2.20.1 >