From patchwork Wed Apr 25 21:04:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Collins X-Patchwork-Id: 10364279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9CF06601D3 for ; Wed, 25 Apr 2018 21:05:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 898F928DF3 for ; Wed, 25 Apr 2018 21:05:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B51128DFA; Wed, 25 Apr 2018 21:05:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E88C128DF3 for ; Wed, 25 Apr 2018 21:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752712AbeDYVFE (ORCPT ); Wed, 25 Apr 2018 17:05:04 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:41982 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751558AbeDYVE6 (ORCPT ); Wed, 25 Apr 2018 17:04:58 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2B13060807; Wed, 25 Apr 2018 21:04:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524690298; bh=wtqi/SyETuqp/+ItgaOIocEB2qWfWbKfv3dfDxmXXjM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=RsjluKDsIjgqsfCNip2pr4k1VGq7333uMjmqJh65UyZMwWGskdu8lDZTQYiEX9Hq+ GPU65f7J5ocUO/Ed1f+ZI0+HJUZuWDWQYKxOkJl0hWG4Cpsq14QwTw5ao33PTfEDK1 s8wjOV6elgXgUq/tkv2NgtSLmiY4+RLUILA9yGIM= Received: from [10.46.164.143] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: collinsd@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 96646601CF; Wed, 25 Apr 2018 21:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524690297; bh=wtqi/SyETuqp/+ItgaOIocEB2qWfWbKfv3dfDxmXXjM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=fxOu27WcnDYmnkcy1W+LA+QcsdWRsHWiU1XBNrsX/4j8VUTZ+VSyOiB5gqTxjyFo2 w1kBWrSZ/03cFAmCnlhaasbDCsp4kt4BLV9eLmz/13pHT7obN1nqpocWQ0jhkDn1gi oBu7b/SObxPwUWxSjrpbMu9HW0cLCHAAXJBtBTeI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 96646601CF Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=collinsd@codeaurora.org Subject: Re: [PATCH v2 2/2] regulator: add QCOM RPMh regulator driver 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 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> From: David Collins Message-ID: Date: Wed, 25 Apr 2018 14:04:56 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20180425103136.GB24769@sirena.org.uk> Content-Language: en-US Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP >>> 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: "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 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,