From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754208AbdA3TWT (ORCPT ); Mon, 30 Jan 2017 14:22:19 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:51401 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754009AbdA3TWR (ORCPT ); Mon, 30 Jan 2017 14:22:17 -0500 Date: Mon, 30 Jan 2017 11:22:14 -0800 From: Guenter Roeck To: Stephen Boyd Cc: Dmitry Torokhov , Russell King - ARM Linux , Michael Turquette , Viresh Kumar , Andy Shevchenko , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] clk: add more managed APIs Message-ID: <20170130192214.GC11199@roeck-us.net> References: <20170128184047.GA24957@dtor-ws> <20170128190309.GN27312@n2100.armlinux.org.uk> <20170128192207.GA38136@dtor-ws> <64ed0890-14f6-42ff-66b1-60f7b3d7d02f@roeck-us.net> <20170128233911.GO27312@n2100.armlinux.org.uk> <20170129180743.GA10917@dtor-ws> <20170130185551.GM8801@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170130185551.GM8801@codeaurora.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 30, 2017 at 10:55:51AM -0800, Stephen Boyd wrote: > On 01/29, Dmitry Torokhov wrote: > > When converting a driver to managed resources it is desirable to be able to > > manage all resources in the same fashion. This change allows managing > > clocks in the same way we manage many other resources. > > Can you please add 'managing clock prepared and enabled state in > the same way'? > > The current wording makes it sound like we don't have > devm_clk_get() when we do. > > > > > This adds the following managed APIs: > > > > - devm_clk_prepare()/devm_clk_unprepare(); > > - devm_clk_prepare_enable()/devm_clk_disable_unprepare(). > > Wouldn't this be preceded by a devm_clk_get() call? Wouldn't it > be even shorter to have the APIs > > devm_clk_get_and_prepare()/devm_clk_unprepare_and_put() > devm_clk_get_and_prepare_enable()/devm_clk_disable_unprepare_and_put() > > instead? > In many cases I see devm_clk_get(clk1); devm_clk_get(clk2); clk_prepare_enable(clk1); clk_prepare_enable(clk2); Sometimes the calls are intertwined with setting the clock rates. devm_clk_get(clk); clk_set_rate(clk, rate); clk_prepare_enable(clk); Maybe the additional calls make sense; I can imagine they would. However, I personally would be a bit wary of changing the initialization order of multi-clock initializations, and I am not sure how a single call could address setting the rate ([devm_]clk_get_setrate_prepare_enable() seems like a bit too much). [ On a side note, why is there no clk_get_prepare_enable() and clk_get_prepare() ? Maybe it would be better to introduce those together with the matching devm_ functions in a separate patch if they are useful. ] > Is there any other subsystem that has similar functionality? > Regulators? GPIOs? Resets? I'm just curious if those subsystems > also need similar changes. > Ultimately yes, and most already do. If I recall correctly, I tried to introduce devm_ functions for regulators some time ago, but that was rejected with the comment that it would invite misuse. At the time I accepted that; today my reaction would be to counter that pretty much everything can be misused, and that the potential for misuse should not penaltize all the valid use cases. Thanks, Guenter