Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2853364ybc; Mon, 25 Nov 2019 05:20:20 -0800 (PST) X-Google-Smtp-Source: APXvYqzrrXlgmoN7dR8G4NEegDT1oKxT1pzh50usKQUZRLwbnXyT2iqdsWjJDuj5KD6u+GXER5uj X-Received: by 2002:a17:906:37cd:: with SMTP id o13mr36425809ejc.148.1574688020539; Mon, 25 Nov 2019 05:20:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574688020; cv=none; d=google.com; s=arc-20160816; b=jOhm/Vd6xkdnC5zKekd5mtOw3JwTqNtZB+Wa/8iUl1BG8993EMwjGCGdwIMNB9eAEU A8d0BeTQWL+CWNbhdERtjlkouRdj3fvNi1fONkISkTeSAqaOKFdHYDT/QC5Fn7QfJiEA bNhohka4KqVEP9VfC769dRsuE9hSjK09jRnOhHJ6GkSS1QuP1w8uwDuy/bjAp8i5S6C3 73r2zyp6VNUba5aCvpMQkuQLurnjDsRdcQxArZoXFFKx+syFj0vC56tvpZc4bfz3VoKa NlxWBshKXdCgE2LM9wxBO4neWmc3aOnEKAOwH56Rigcncj57+lvaOyJQDHjLgKcYW+BL qdMg== 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; bh=WuCQmq/KZuq+93A9CgBWtLG6FhPzMUEo/rSD1rYsCR4=; b=tHqV4cTHKuudayk/s5gUs1CQ2ItfbhI1e/7/uT3s5zR5A5m67sfM63ibcv3RlbgoZM P4TCbQqrQlmwxx2ecEe7R909MiLUxqw8P7PbF7hcSZaK2DTcX80LkdDn/bIsmgvJgKAv fpUc+ezMkuNdxaFR+uin0cIZcEA/TJ+8/dJx6YxNOxN1iIeBvCrq09dNKB+BJgL+DDW6 kPSeJm2xlPiPiUk2cXJPhMfW9awUbXfL8sXZBzXeyILyD6sgFUa5SZRND0+w/5SrZxAR jCQLmNG5f2RcTmPr/Q+vVDyAKy+Bz1/Et/0K2HHC79NIbt0KePAJfZoi/0rFLzt2BH+v aY7Q== 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 c3si5227427edx.315.2019.11.25.05.19.55; Mon, 25 Nov 2019 05:20:20 -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; 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 S1727462AbfKYNQS (ORCPT + 99 others); Mon, 25 Nov 2019 08:16:18 -0500 Received: from ns.iliad.fr ([212.27.33.1]:55136 "EHLO ns.iliad.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725823AbfKYNQS (ORCPT ); Mon, 25 Nov 2019 08:16:18 -0500 Received: from ns.iliad.fr (localhost [127.0.0.1]) by ns.iliad.fr (Postfix) with ESMTP id 5DE9920600; Mon, 25 Nov 2019 14:16:17 +0100 (CET) Received: from [192.168.108.51] (freebox.vlq16.iliad.fr [213.36.7.13]) by ns.iliad.fr (Postfix) with ESMTP id 4651C2056B; Mon, 25 Nov 2019 14:16:17 +0100 (CET) Subject: Re: [PATCH v1] clk: Add devm_clk_{prepare,enable,prepare_enable} To: Russell King - ARM Linux admin Cc: Stephen Boyd , Michael Turquette , linux-clk , Linux ARM , LKML References: <1d7a1b3b-e9bf-1d80-609d-a9c0c932b15a@free.fr> <34e32662-c909-9eb3-e561-3274ad0bf3cc@free.fr> <20191125125231.GO25745@shell.armlinux.org.uk> From: Marc Gonzalez Message-ID: <45730e3c-efc7-4433-4980-e6aefebdcbff@free.fr> Date: Mon, 25 Nov 2019 14:16:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191125125231.GO25745@shell.armlinux.org.uk> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP ; ns.iliad.fr ; Mon Nov 25 14:16:17 2019 +0100 (CET) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/11/2019 13:52, Russell King - ARM Linux admin wrote: > On Mon, Nov 25, 2019 at 01:46:51PM +0100, Marc Gonzalez wrote: > >> On 15/07/2019 17:34, Marc Gonzalez wrote: >> >>> Provide devm variants for automatic resource release on device removal. >>> probe() error-handling is simpler, and remove is no longer required. >>> >>> Signed-off-by: Marc Gonzalez >>> --- >>> Documentation/driver-model/devres.rst | 3 +++ >>> drivers/clk/clk.c | 24 ++++++++++++++++++++++++ >>> include/linux/clk.h | 8 ++++++++ >>> 3 files changed, 35 insertions(+) >>> >>> diff --git a/Documentation/driver-model/devres.rst b/Documentation/driver-model/devres.rst >>> index 1b6ced8e4294..9357260576ef 100644 >>> --- a/Documentation/driver-model/devres.rst >>> +++ b/Documentation/driver-model/devres.rst >>> @@ -253,6 +253,9 @@ CLOCK >>> devm_clk_hw_register() >>> devm_of_clk_add_hw_provider() >>> devm_clk_hw_register_clkdev() >>> + devm_clk_prepare() >>> + devm_clk_enable() >>> + devm_clk_prepare_enable() >>> >>> DMA >>> dmaenginem_async_device_register() >>> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c >>> index c0990703ce54..5e85548357c0 100644 >>> --- a/drivers/clk/clk.c >>> +++ b/drivers/clk/clk.c >>> @@ -914,6 +914,18 @@ int clk_prepare(struct clk *clk) >>> } >>> EXPORT_SYMBOL_GPL(clk_prepare); >>> >>> +static void unprepare(void *clk) >>> +{ >>> + clk_unprepare(clk); >>> +} >>> + >>> +int devm_clk_prepare(struct device *dev, struct clk *clk) >>> +{ >>> + int rc = clk_prepare(clk); >>> + return rc ? : devm_add_action_or_reset(dev, unprepare, clk); >>> +} >>> +EXPORT_SYMBOL_GPL(devm_clk_prepare); >>> + >>> static void clk_core_disable(struct clk_core *core) >>> { >>> lockdep_assert_held(&enable_lock); >>> @@ -1136,6 +1148,18 @@ int clk_enable(struct clk *clk) >>> } >>> EXPORT_SYMBOL_GPL(clk_enable); >>> >>> +static void disable(void *clk) >>> +{ >>> + clk_disable(clk); >>> +} >>> + >>> +int devm_clk_enable(struct device *dev, struct clk *clk) >>> +{ >>> + int rc = clk_enable(clk); >>> + return rc ? : devm_add_action_or_reset(dev, disable, clk); >>> +} >>> +EXPORT_SYMBOL_GPL(devm_clk_enable); >>> + >>> static int clk_core_prepare_enable(struct clk_core *core) >>> { >>> int ret; >>> diff --git a/include/linux/clk.h b/include/linux/clk.h >>> index 3c096c7a51dc..d09b5207e3f1 100644 >>> --- a/include/linux/clk.h >>> +++ b/include/linux/clk.h >>> @@ -895,6 +895,14 @@ static inline void clk_restore_context(void) {} >>> >>> #endif >>> >>> +int devm_clk_prepare(struct device *dev, struct clk *clk); >>> +int devm_clk_enable(struct device *dev, struct clk *clk); >>> +static inline int devm_clk_prepare_enable(struct device *dev, struct clk *clk) >>> +{ >>> + int rc = devm_clk_prepare(dev, clk); >>> + return rc ? : devm_clk_enable(dev, clk); >>> +} >>> + >>> /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */ >>> static inline int clk_prepare_enable(struct clk *clk) >>> { >> >> Thoughts? Comments? > > These are part of the clk API rather than the CCF API, and belong in > drivers/clk/clk-devres.c. I'm totally confused. Are you saying that a hypothetical devm_clk_prepare() function should not be implemented in the same file as the "raw" clk_prepare() ? Regards.