Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1630668ybi; Sat, 27 Jul 2019 14:29:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIa581TNteWrkELrizNEtUPOIvfZCM7QZgkhNw+CgjTi80SuGg1FKTzE5r1sLEiRTKlFXR X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr104808396plo.88.1564262941346; Sat, 27 Jul 2019 14:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564262941; cv=none; d=google.com; s=arc-20160816; b=c7tzg+nZSpe7ej6MhiK+pM6t5aF3fpgLzS29atEyMdgOSHQW7gV16tU0ng2q3l7jaC 86UH+87hJYSpTSVoh2tQmV1MF7ZYye8+sgVzyo1XVtZ36LyXLeli/rSHuOUNXQ0JUI5B g1KVbQRG6AN/gr73A72IZehynka40I6RXytFp5UMXykL70vLyeyWiLpHTumnVOd4sr2/ Fzz2Sk0ei9hf+cNX00Vmm/DdaIcr6/AH+6aXaylkeS9LbCCFGGaNyZyJhu4PojDvnSOH 42qaF2FqnoxMkldHOSv04U/FTFfzq7Bb4WJ9VW3JFv1j/6HKiTFerv5qxZeP6nx/hy5/ LBvw== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=3n5+QDZa+Sk8g14BLUsvjaQcgw8hg0uaEKHF7UcacA8=; b=OS7AMd8o7mgtEwj+MM44V/9hToeHuR5mH85TbldvImBXSWlkVVKBki3lRagbLgI2um O56nIuk4iKabpOsnjqlUBlku5K2+y2KtFt6O6zAdiVtNOtOuLbN69z0jzWQeujWbO6c2 VBcC764rjf+an1bxaxtx6YveTHHYjKLZHl8UESRwPTWhq3PGk9iVh6pAtNv7Y0Eouqeg tKrrXUxbM1H/ehVSayenufg4XZSNvPqSZjwt8lfsYpsGsHZnPqfr2KBwpC3VjpyctE7t J0cSs1IQunIV5QDcwRO/gwo0Wqctp1IDX42bR3xdnnfYFAY2DutunJmogfDB4VEIFGLQ DwXQ== 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 x8si23668711pgj.322.2019.07.27.14.28.46; Sat, 27 Jul 2019 14:29:01 -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; 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 S1725878AbfG0V1S (ORCPT + 99 others); Sat, 27 Jul 2019 17:27:18 -0400 Received: from saturn.retrosnub.co.uk ([46.235.226.198]:45714 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725280AbfG0V1S (ORCPT ); Sat, 27 Jul 2019 17:27:18 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) by saturn.retrosnub.co.uk (Postfix; Retrosnub mail submission) with ESMTPSA id D957B9E73DD; Sat, 27 Jul 2019 22:27:16 +0100 (BST) Date: Sat, 27 Jul 2019 22:27:15 +0100 From: Jonathan Cameron To: Chuhong Yuan Cc: Patrick Havelange , William Breathitt Gray , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] counter/ftm-quaddec: Use device-managed registration API Message-ID: <20190727222702.736d91f7@archlinux> In-Reply-To: <20190726133916.26186-1-hslester96@gmail.com> References: <20190726133916.26186-1-hslester96@gmail.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 26 Jul 2019 21:39:16 +0800 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 Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > 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);