From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932722AbeARP0F (ORCPT ); Thu, 18 Jan 2018 10:26:05 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:46577 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932618AbeARPZ7 (ORCPT ); Thu, 18 Jan 2018 10:25:59 -0500 X-Google-Smtp-Source: ACJfBouJBuDVLMfZQf2bbGk0Tonu2VHmWtNrprxC6vUE0b7R481e354xeitGSd5XLom0kNWsg9M3lw== Subject: Re: [PATCH 2/2] clk: meson: use devm_of_clk_add_hw_provider To: Jerome Brunet Cc: Kevin Hilman , Carlo Caione , Michael Turquette , Stephen Boyd , linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180118120831.8349-1-jbrunet@baylibre.com> <20180118120831.8349-3-jbrunet@baylibre.com> From: Neil Armstrong Organization: Baylibre Message-ID: Date: Thu, 18 Jan 2018 16:25:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180118120831.8349-3-jbrunet@baylibre.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/01/2018 13:08, Jerome Brunet wrote: > There is no remove callbacks in meson's clock controllers and > of_clk_del_provider is never called if of_clk_add_hw_provider has been > executed, introducing a potential memory leak. > Fixing this by the using the devm variant. > > In reality, the leak would never happen since these controllers are > never unloaded once in use ... still, this is worth cleaning. > > Signed-off-by: Jerome Brunet > --- > drivers/clk/meson/axg.c | 4 ++-- > drivers/clk/meson/gxbb.c | 5 +++-- > drivers/clk/meson/meson8b.c | 4 ++-- > 3 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/clk/meson/axg.c b/drivers/clk/meson/axg.c > index 87aba8e871a0..02f4401d7bc3 100644 > --- a/drivers/clk/meson/axg.c > +++ b/drivers/clk/meson/axg.c > @@ -923,8 +923,8 @@ static int axg_clkc_probe(struct platform_device *pdev) > } > } > > - return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, > - clkc_data->hw_onecell_data); > + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, > + clkc_data->hw_onecell_data); > } > > static struct platform_driver axg_driver = { > diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c > index ba1023983d79..472a3cfbfbc5 100644 > --- a/drivers/clk/meson/gxbb.c > +++ b/drivers/clk/meson/gxbb.c > @@ -2028,8 +2028,9 @@ static int gxbb_clkc_probe(struct platform_device *pdev) > goto iounmap; > } > > - return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, > - clkc_data->hw_onecell_data); > + > + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, > + clkc_data->hw_onecell_data); > > iounmap: > iounmap(clk_base); > diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c > index 3ffea80c1308..abac079ff77f 100644 > --- a/drivers/clk/meson/meson8b.c > +++ b/drivers/clk/meson/meson8b.c > @@ -878,8 +878,8 @@ static int meson8b_clkc_probe(struct platform_device *pdev) > return ret; > } > > - return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, > - &meson8b_hw_onecell_data); > + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, > + &meson8b_hw_onecell_data); > } > > static const struct of_device_id meson8b_clkc_match_table[] = { > Well devm is allocating a devm structure to unregister the clocks when removed, which will never happen so this allocation is useless. Anyway it's cleaner if we do some other stuff after this call in the future. Acked-by: Neil Armstrong