From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Collins Subject: Re: [PATCH v2 2/2] regulator: add QCOM RPMh regulator driver Date: Wed, 25 Apr 2018 14:04:56 -0700 Message-ID: References: <4b45f41996ea3344340e44fab2dc9e487572e209.1523673467.git.collinsd@codeaurora.org> <4e3353fe-ebb5-46bb-aa58-49ad04c4d9db@codeaurora.org> <132ab845-52d6-6192-4d8c-5a9c95410688@codeaurora.org> <20180424174507.GI22073@sirena.org.uk> <20a8f736-2687-f14f-eaa1-2b2c06eed629@codeaurora.org> <20180425103136.GB24769@sirena.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20180425103136.GB24769@sirena.org.uk> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Mark Brown Cc: Doug Anderson , Liam Girdwood , Rob Herring , Mark Rutland , linux-arm-msm@vger.kernel.org, Linux ARM , devicetree@vger.kernel.org, LKML , Rajendra Nayak , Stephen Boyd , Matthias Kaehlcke List-Id: devicetree@vger.kernel.org >>> I think that's probably only OK if we have a specific error code for the >>> regulator being limited in this way otherwise our error handling for I/O >>> problems involves us trying to reconfigure supplies which seems like it >>> would be risky. >> Would you be ok with -EAGAIN being used for this purpose? > Using -EAGAIN for "I can't ever read the configuration from this > regulator" doesn't seem right - it's not like any number of retries > will ever manage to read the value back. In this case, the _regulator_get_voltage() call can succeed, but only after a voltage is explicitly requested from the framework side. The intention here would then be to call _regulator_do_set_voltage() with the constraint min_uV to max_uV range. After that, subsequent _regulator_get_voltage() calls will be successful. Here is the general idea: diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 65f9b7c..e61983d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -910,6 +910,19 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, rdev->constraints->min_uV && rdev->constraints->max_uV) { int target_min, target_max; int current_uV = _regulator_get_voltage(rdev); + if (current_uV == -EAGAIN) { + /* + * Regulator voltage cannot be read until after + * configuration; try setting constraint range. + */ + rdev_info(rdev, "Setting %d-%duV\n", + rdev->constraints->min_uV, + rdev->constraints->max_uV); + _regulator_do_set_voltage(rdev, + rdev->constraints->min_uV, + rdev->constraints->max_uV); + current_uV = _regulator_get_voltage(rdev); + } if (current_uV < 0) { rdev_err(rdev, "failed to get the current voltage(%d)\n", Do you still have reservations about using -EAGAIN for this purpose? If so, which error code would you suggest using? Thanks, David -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project