Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp104278ybi; Mon, 15 Jul 2019 17:28:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRma3F1g/f1voWRxWwOoPgd3JXoPj3E0MwSrxAizhJHYhusrxkUl9iu35igqY4FRe3hKGO X-Received: by 2002:a63:c008:: with SMTP id h8mr26359779pgg.427.1563236938935; Mon, 15 Jul 2019 17:28:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563236938; cv=none; d=google.com; s=arc-20160816; b=Fs3ROw+RHUfoc87MWfxUD+xQ3tuEvJ3OQfZVLUzpDnEILvOIO7GLYClAGppvwfqgIX 500c1VwRiFEs8rRnDweZMScV64+BNhlGE7btDRYHf8bE+I4Zf/CRC04VOW6Oxn5PH5zV Px7S3gC+TZ3HSsjTFjHVwGx3ChZ8wx4QLLO3WrtL8Yrq2j2Fx6hFWvt/Jtm7XnLqQTqa C1+1yBelchMSU2S33l5633LDyUkXcDIH+jCf2CsKUV7laDSvj+KphMiWcpPa8zCCBU0I DlKOogF09F+VJWdkNg7WL6CLRk0VY/iY++Cd7THMba5EGGbSKFpjcemv4rIo7CVZ7xp6 nrkw== 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:dkim-signature; bh=wziVWxT4jhj1YL8MMH30E+O5fO28fTjFNy0DUs9/y1M=; b=eKpzBv4NEWuhnvym11XXVQ+1gNEMIdkTuXLzLH+g4j6f/POJyFJGnSkiFklsvibhNW CS/0D6P8yqzmbTOYuIC/Uk3OmzVBepb/gnmNn61YKb5E9RuBjbd3+p6zfjuyNtAXA8Fd F/xY4kZv+4BKn7Q3C0ujc7CDDwAzz+DqrBtE4CEUH+//XIS8pghORqHtzq3d0xv+lPAm 3HzsGdBkg923AdYce39v/oNQjem4NYV8lbATtSpcMoidJ3sbkvxGGxyRvHZBuBWWmATf On5ba26HBslsDvE6jnynfUMs9gnbSRjICqWDYsJki9HFNpE92fwLdG6tJnUpuk7Ee+xX WK7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pNhhCU0W; 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 q3si16981198pgp.497.2019.07.15.17.28.30; Mon, 15 Jul 2019 17:28:58 -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=fail header.i=@gmail.com header.s=20161025 header.b=pNhhCU0W; 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 S1732897AbfGPAZY (ORCPT + 99 others); Mon, 15 Jul 2019 20:25:24 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45095 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732200AbfGPAZY (ORCPT ); Mon, 15 Jul 2019 20:25:24 -0400 Received: by mail-pg1-f193.google.com with SMTP id o13so8483020pgp.12; Mon, 15 Jul 2019 17:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=wziVWxT4jhj1YL8MMH30E+O5fO28fTjFNy0DUs9/y1M=; b=pNhhCU0WdmDHPzkx3id10YV8KvhlTnul/T/fw1cvtTE+/KR/OemboYLXwHm+RntFYQ 8UPfv1y8j0/Vcnp+mXmyDsqydJMSCBwuxQJus+8rtmcmpI2b/0IRF7sSOP1OJm3rRyFh Rf+WI3tWvQRi5scHRYvY4nlqf9JGpIXPbPrvJ3YrfJ3enb4nucOnh4ST6pIA7MaZ0W70 eL1msne9/MM1yL4r6lLsngthbyihpeI9wy7j5qD4FAlk5z41STRLQofweERKkxclfhlB ZjD5kXOHZyLO3bsSgbCR1jVrn6VPs9EqWASM9K9H2Cf7g2Slau4KTDvFAxtJij47rUag DKXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=wziVWxT4jhj1YL8MMH30E+O5fO28fTjFNy0DUs9/y1M=; b=Hg+OI1EqW2+NgfdglgLIWdpcnD3aK0vACgP2j6ToP8GihJ28AcJmgoA295Mf0itkXp ZFVi1nIh/qTqrtfmr8sr3JSLnHLLw5OZzRSuY+KZMKGmLUtL+eKFd3o7gVNMnP+A0EdB 3OGZo58lJhXWeYwtS3mRtKfW5dr8HkE+QUnq1UUqjvRodVAkVcsOw4PENk4oofk2407S ZGRHzSJAUbmhs1GaecihpR8p45ekIB00ht9TNVShG9MTHgjLGM9Ytzbr4qS5jV+WKFzi m5PNOc/VSj7Onwvwt7yOPJq37HHFIoYFK4fC1M8rM7imzKOwnt6E4QC3a43A4rQoeFVP 4pqg== X-Gm-Message-State: APjAAAXaxhAJeFFJSwFQjXlybSOYlk+8nb/S7QbAdd0jYW6y0q9K99yE fmL3rr9DjgCJLJjpaDLE8tQ= X-Received: by 2002:a63:20a:: with SMTP id 10mr29639653pgc.226.1563236723240; Mon, 15 Jul 2019 17:25:23 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id a5sm17204256pjv.21.2019.07.15.17.25.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 17:25:21 -0700 (PDT) Subject: Re: [PATCH v1] clk: Add devm_clk_{prepare,enable,prepare_enable} To: Marc Gonzalez , Stephen Boyd , Michael Turquette Cc: linux-clk , LKML , =?UTF-8?Q?Jonathan_Neusch=c3=a4fer?= , Bjorn Andersson , Dmitry Torokhov References: <1d7a1b3b-e9bf-1d80-609d-a9c0c932b15a@free.fr> From: Guenter Roeck Message-ID: Date: Mon, 15 Jul 2019 17:25:19 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <1d7a1b3b-e9bf-1d80-609d-a9c0c932b15a@free.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/15/19 8:34 AM, 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 Again ? https://lore.kernel.org/patchwork/patch/755667/ This must be at least the third time this is tried. I don't think anything changed since the previous submissions. I long since gave up and use devm_add_action_or_reset() in affected drivers instead. Guenter > --- > 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) > { >