Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753118AbcDSLDU (ORCPT ); Tue, 19 Apr 2016 07:03:20 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:35641 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752304AbcDSLDT (ORCPT ); Tue, 19 Apr 2016 07:03:19 -0400 Date: Tue, 19 Apr 2016 13:03:13 +0200 From: Thierry Reding To: Jon Hunter Cc: Mark Brown , Liam Girdwood , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] regulator: core: Resolve supply earlier Message-ID: <20160419110313.GA8284@ulmo.ba.sec> References: <1460038959-21592-1-git-send-email-thierry.reding@gmail.com> <20160411140300.GH3351@sirena.org.uk> <20160411141101.GB27400@ulmo.ba.sec> <20160411141621.GI3351@sirena.org.uk> <5716059B.3080503@nvidia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="SLDf9lqlvOQaIe6s" Content-Disposition: inline In-Reply-To: <5716059B.3080503@nvidia.com> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3022 Lines: 88 --SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 19, 2016 at 11:16:59AM +0100, Jon Hunter wrote: >=20 > On 11/04/16 15:16, Mark Brown wrote: > > * PGP Signed by an unknown key > >=20 > > On Mon, Apr 11, 2016 at 04:11:01PM +0200, Thierry Reding wrote: > >> On Mon, Apr 11, 2016 at 03:03:00PM +0100, Mark Brown wrote: > >=20 > >>> This shouldn't be a hard dependency: most regulators won't be in bypa= ss > >>> mode or otherwise depend on their parents enough to need this. > >=20 > >> I had initially proposed to resolve the supply only when necessary > >> during regulator_get_voltage() when checking for bypass, perhaps that > >> would after all be more appropriate here? > >=20 > > Yes, that had been what I'd expected. >=20 > So the following seems to work, but only item I am uncertain about > is if it is ok to move the mutex_lock to after the > machine_set_constraints()? >=20 > Jon >=20 > diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c > index 61d3918f329e..742d10371e2d 100644 > --- a/drivers/regulator/core.c > +++ b/drivers/regulator/core.c > @@ -3126,8 +3126,13 @@ static int _regulator_get_voltage(struct regulator= _dev *rdev) > return ret; > if (bypassed) { > /* if bypassed the regulator must have a supply */ > - if (!rdev->supply) > - return -EINVAL; > + if (!rdev->supply) { > + ret =3D regulator_resolve_supply(rdev); > + if (ret < 0) > + return ret; > + if (!rdev->supply) > + return -EINVAL; > + } > =20 > return _regulator_get_voltage(rdev->supply->rdev); > } > @@ -3939,8 +3944,6 @@ regulator_register(const struct regulator_desc *reg= ulator_desc, > rdev->dev.of_node =3D of_node_get(config->of_node); > } > =20 > - mutex_lock(®ulator_list_mutex); It seems like this is used to protect accesses to the list of enable GPIOs (regulator_ena_gpio_list), which is modified in the call to the regulator_ena_gpio_request() function below. That would be easily solved giving that its own lock, though. Thierry --SLDf9lqlvOQaIe6s Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJXFhBvAAoJEN0jrNd/PrOhmRsP/iw1xn9YzBCPchuCHRwHyZNY WecR+9uVqQjshyJiTqJohjHj6HUoCYYAst2Ed59Sf51N00jpO7n6YJc4VWA1QPor 5uwUhKzmMfCA5S1zhmD1u1H4exQ3WRQVB8bvasq54V83WF6Gw4yifIdhJxxE7GbZ p8W5ZQDb2Tas1rMH2rMLG+AX1Ymnh3l4xrvDTQzgwYLG9Yz5dL0ewBLVlDs9NDt3 M6/lH//mz02tr3zp0JEoXtjoyhPyqGUZsGHZgDYWK3FzXFfKTj1Xdc1A6+MQS18n LksvLvsx7HVL6PSmGDE4qtHL26HSDRqXPIVXq5STg/KuhBTLGrToXBTeSFyrKzSB MrvVUW/z+g4LyXhVXUUk5+PpDHs0vbj9eWG7UPJLvt5vnt/7DfDoyhDIOqy91X9o Lf4oiK1QqbgTkGYTzHst3LKv+t5ZIc+aYSHY/UTEGQxYWjjoK3fFxdIrrtLEESEQ 6GlEIomT77TOXfa5UzA7RV5uvU0xENopmZhrbEDxhS7PdJqcjQSo9X7sXElLPdWk h5Cgj+iwUAvHq4I1o1PGtJVsS1KgVD6P1j3gopfF20piuHEruFosYr+nkU2i6rXY cjnCc+mFBC0f5pEGfrFyHdGKeeqBBEdjzfiFiBWvs6jFT3cqoMeJaDRYq0E2SKEH kDODdoc2nek1Lk/bc5e3 =H1XF -----END PGP SIGNATURE----- --SLDf9lqlvOQaIe6s--