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: 10364283 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 1CABA601D3 for ; Wed, 25 Apr 2018 21:05:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2A3D28DFA for ; Wed, 25 Apr 2018 21:05:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3F5F28E05; Wed, 25 Apr 2018 21:05:26 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6EE2D28DFA for ; Wed, 25 Apr 2018 21:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zV0KFk0D9CN+1kRtHIdhd8GQjs5rsNnRomfb+ZU/qzc=; b=ci2BA1BrihaeeO DX8DSpWblRKGiiXJZoeaRittuWqWpceN60/pTvno9OR8XlId9ZyG8cyoHJG+Rv4RDKSMVva/f811s OIU/0uYW33rw+/A7fFfxma6RAl2jJBfLYi+YphtUHT4U4NT4BOh7OsDwWVaiUk1X4uu79mX9VA+fE OrEvitGRt9+L9Wc4ybDb6ehKaIaUt6PcS8teUZdbtXhVVUJaf+AKPGz5imw71yKZ5v9nPDlKM+q8k nkMnetniY7bwR4JIXsnGYmhsXJVU3JGUfIjHTPBOlBV/EsPJ+FfwkzavJeT0TWM7szbGd1fTmUxnP 3wEuGbWHP/+1GoLgzrGw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBRbF-0002Ew-JF; Wed, 25 Apr 2018 21:05:13 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBRbB-0001W6-Kq for linux-arm-kernel@lists.infradead.org; Wed, 25 Apr 2018 21:05:11 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D662460D81; 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180425_140509_741090_A2A10321 X-CRM114-Status: GOOD ( 19.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, LKML , Stephen Boyd , linux-arm-msm@vger.kernel.org, Doug Anderson , Liam Girdwood , Rob Herring , Rajendra Nayak , Matthias Kaehlcke , Linux ARM Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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,