From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751361AbdBUIaT (ORCPT ); Tue, 21 Feb 2017 03:30:19 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33977 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751257AbdBUIaI (ORCPT ); Tue, 21 Feb 2017 03:30:08 -0500 Date: Tue, 21 Feb 2017 00:30:03 -0800 From: Dmitry Torokhov To: Mark Brown Cc: Liam Girdwood , Guenter Roeck , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] regulator: devres: introduce managed enable and disable operations Message-ID: <20170221083003.GA21739@dtor-ws> References: <20170213023249.GA27688@dtor-ws> <20170213180129.wutjitdr72klhxwu@sirena.org.uk> <20170213185152.GC20057@dtor-ws> <20170220190258.fympxa43cdrzd44b@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170220190258.fympxa43cdrzd44b@sirena.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 20, 2017 at 11:02:58AM -0800, Mark Brown wrote: > On Mon, Feb 13, 2017 at 10:51:52AM -0800, Dmitry Torokhov wrote: > > > I think it is helps if you think about devm_regulator_enable and regular > > regulator_enable as managed and unmanaged *actions*, not resources. So > > That's how I see them but it's still not really helping my concern, in > general if you do a thing with devm_ you don't want to also be > interacting with the same resource in the same way with a non-managed > call. It really depends on how you structure your API. For input, for example, I only provide devm_input_alloc_device() and I made the rest of the functions handle both managed and unmanaged input devices and they internally sort it all out between themselves. But that is what I meant here about managed action. You are not interacting with managed regulator here, you have managed enable. There is absolutely nothing preventing you from calling devm_regulator_enable() on a regulator that was obtained with regulator_get() (i.e. non-managed). > > > managed action of enabling regulator will be undone on remove() and you > > have to manually undo unmanaged regulator_disable() on resume(). It is > > not worse than having unbalanced regulator_enable/disable between > > probe()/suspend()/resume()/remove(). > > I find it that bit harder to think about - tracking balancing of the > same thing is a lot easier than tracking balancing of two different not > quite equivalent things. Hmm... so what do we do (because I think this devm API is quite useful for cleaning up probe and remove in many drivers)? Do you want it to operate on a separate counter which we can check against underflow separately from classic regulator_enable() and regulator_disable()? Not sure if this will buy us much though and it will make bulk code uglier... Thanks. -- Dmitry