Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3332926ybi; Mon, 29 Jul 2019 04:54:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0yWtp7ExKKm5viN/Ruke+TSKjZgeyBRlULQ31VIgmbSUVIN4jVKJ/ME9Hc/WsE0Or3Iwf X-Received: by 2002:a63:1018:: with SMTP id f24mr17766141pgl.343.1564401259478; Mon, 29 Jul 2019 04:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564401259; cv=none; d=google.com; s=arc-20160816; b=JMEdwqCfI6KodyYJSqqMM41Dn55/f7DlycP3MLXchtDHWK48bzHvf49K/oyirPzOYy iZsF/Fc87NIcqskr1z6g+kr7bETd+a7/KRlNxx4ZD2Ue6M4agvCFp5jEClGgQzZ7Jh0D b7m/W6q/DNcJv/CK9TYvXazXy/kcQav0M7OTBNP5c46mA6r1qbG+gks60AvXbshoyqNn GWwa/y+uxy3KFpiSESi99H1vKQcwXWvn0tsasXH/tnt1ZBMYD66BSpl9wSPGwtAsJfKP DzD1LUOsWRQ29nJhD4ksKE2ZTlyM/nnX2/+ISeohN/u7fEUD7kszZAyTGE7z0WNGumLb Zv3w== 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=PPGf0kPbvhe2HXNESzGCCBqYTl2vqafsajjrV11C25I=; b=gYN6uBDIfF30QvH9jgU2cHeCRIfSgn8kvqwqnhw+qVUqHgnS76PEFMBPbYcU+1ovGC av3VFSJIvADPQShiSL7r9/Dkz2W+3jP1SCkxtoiavPxSnbuAwKBgNZRkCj4TrLspydAe UAmq4FV5A1hEFx2ywh+XejqtvxjBRLlwJM/Oc5FcPJfNVXdaNlkPN9vjYETz0MH8kZEW 6dLX/RcjR6VDZQYMDhJP9MPYzkUcqYhHsZ6lWUNnjzOxoOtA0TPKlXaESlT8jOyNWxIW kcnK/0vuJm7CUWuYiFznpeiSqPM55YDUcfScbHsQEJUfaJvCLEor72Z3eHo62+lLFHjy wMSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@essensium-com.20150623.gappssmtp.com header.s=20150623 header.b=p97UEoNg; 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 t11si22659290pgu.16.2019.07.29.04.54.03; Mon, 29 Jul 2019 04:54:19 -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=p97UEoNg; 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 S2387804AbfG2LxA (ORCPT + 99 others); Mon, 29 Jul 2019 07:53:00 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:46110 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387482AbfG2Lw7 (ORCPT ); Mon, 29 Jul 2019 07:52:59 -0400 Received: by mail-ot1-f65.google.com with SMTP id z23so33874233ote.13 for ; Mon, 29 Jul 2019 04:52:59 -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=PPGf0kPbvhe2HXNESzGCCBqYTl2vqafsajjrV11C25I=; b=p97UEoNg/4v5WyEnvrg6cBEmCngBnKeqFcpQlsDLMsJijmNXQOucbWp+t+TFovLOXZ qgqyVce9UCFzNi2sjQ7Zt9gV2tetGlakx45j63Mpcia5m09PM9omEz3/9LkbQmwePBL0 VIF48g2yFADHWzzsSYLAgHOgCSTVNqoVcqaUU6txNjq6wdlFeZykRdbr6oFPL8FaU8+N dThYCT69kkPPeOrsWEGninxKcQ497ZwrJyIUU11P2AOJnQotM+PNQmu/63YJNzXRZwdv GLIEsRZvBtfJbs0do5wKLVvnCcRT1tm49qlpeRTJckOuQf8JWRg21d6AaUqUz4mY25if ZdtA== 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=PPGf0kPbvhe2HXNESzGCCBqYTl2vqafsajjrV11C25I=; b=s8ltYE/piqn903wCEAmKJIlWp026hMSIXRnR3ojuCjB2WtuiHwsPiR8j+tGuHY22Bl C53s1CdB4SdpPF/APwNjQ9ojTuOR4Po097bDDM2reFl9vvYcH6tuZr4cur0qzxJrJrao j9K9A7LtJvRCrVZe2KvOdmQryAsvjsHfhhWaG+BspjhqvZJTITY/K4m4+2p/5fdkm0G8 e0/rSvXpMzKgjaO2WvZprObcg+IDKjWwXtCazSmKeCuqdS/TpPDRHqt0Nw623dxFeBnj NkEKU4UU4P1Dv2VCDFs+ptLbtve0xgMkeGrAhXHSJVuS935hNcu7o82IPJy0S1BrjBdo Zumg== X-Gm-Message-State: APjAAAUTfjALc3xoww9yZvn646eCVvBcaAKK2jv6CSIv9QEy9n9KJfps MUJKPzCjWFNV2tcRxjc1JuMCCwCOmNTyDupGOW0IAw== X-Received: by 2002:a9d:48f:: with SMTP id 15mr49061044otm.160.1564401178640; Mon, 29 Jul 2019 04:52:58 -0700 (PDT) MIME-Version: 1.0 References: <20190726133916.26186-1-hslester96@gmail.com> In-Reply-To: <20190726133916.26186-1-hslester96@gmail.com> From: Patrick Havelange Date: Mon, 29 Jul 2019 13:52:47 +0200 Message-ID: Subject: Re: [PATCH v2] 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 On Fri, Jul 26, 2019 at 3:39 PM 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 Reviewed-by: Patrick Havelange Maybe a bit too late, sorry for that. Thanks for the patch. Patrick H. > --- > Changes in v2: > - Use devm_add_action_or_reset to keep > resource release order. > - remove() function is redundant now, > delete it. > > drivers/counter/ftm-quaddec.c | 30 ++++++++++++------------------ > 1 file changed, 12 insertions(+), 18 deletions(-) > > diff --git a/drivers/counter/ftm-quaddec.c b/drivers/counter/ftm-quaddec.c > index 68a9b7393457..4046aa9f9234 100644 > --- a/drivers/counter/ftm-quaddec.c > +++ b/drivers/counter/ftm-quaddec.c > @@ -100,16 +100,18 @@ static void ftm_quaddec_init(struct ftm_quaddec *ftm) > ftm_set_write_protection(ftm); > } > > -static void ftm_quaddec_disable(struct ftm_quaddec *ftm) > +static void ftm_quaddec_disable(void *ftm) > { > - ftm_clear_write_protection(ftm); > - ftm_write(ftm, FTM_MODE, 0); > - ftm_write(ftm, FTM_QDCTRL, 0); > + struct ftm_quaddec *ftm_qua = ftm; > + > + ftm_clear_write_protection(ftm_qua); > + ftm_write(ftm_qua, FTM_MODE, 0); > + ftm_write(ftm_qua, FTM_QDCTRL, 0); > /* > * This is enough to disable the counter. No clock has been > * selected by writing to FTM_SC in init() > */ > - ftm_set_write_protection(ftm); > + ftm_set_write_protection(ftm_qua); > } > > static int ftm_quaddec_get_prescaler(struct counter_device *counter, > @@ -317,20 +319,13 @@ static int ftm_quaddec_probe(struct platform_device *pdev) > > ftm_quaddec_init(ftm); > > - ret = counter_register(&ftm->counter); > + ret = devm_add_action_or_reset(&pdev->dev, ftm_quaddec_disable, ftm); > if (ret) > - ftm_quaddec_disable(ftm); > - > - return ret; > -} > + return ret; > > -static int ftm_quaddec_remove(struct platform_device *pdev) > -{ > - struct ftm_quaddec *ftm = platform_get_drvdata(pdev); > - > - counter_unregister(&ftm->counter); > - > - ftm_quaddec_disable(ftm); > + ret = devm_counter_register(&pdev->dev, &ftm->counter); > + if (ret) > + return ret; > > return 0; > } > @@ -346,7 +341,6 @@ static struct platform_driver ftm_quaddec_driver = { > .of_match_table = ftm_quaddec_match, > }, > .probe = ftm_quaddec_probe, > - .remove = ftm_quaddec_remove, > }; > > module_platform_driver(ftm_quaddec_driver); > -- > 2.20.1 >