Received: by 10.192.165.148 with SMTP id m20csp1186781imm; Wed, 25 Apr 2018 14:06:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx49PYw1uCPAZe1RAYUraUebF8syNmS2P3FrAaVsVBnCmHlh0Vr6rPBmmTt5uqFPlz7lj9KHI X-Received: by 10.99.152.26 with SMTP id q26mr22934898pgd.40.1524690406719; Wed, 25 Apr 2018 14:06:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524690406; cv=none; d=google.com; s=arc-20160816; b=Yhbec0cuSdwUMq4FhYyxwf6d2bTlzaHYAQTucRmA3w6JMdOb4hBsJCLU5b+TUfRpGR OHSZFMVhiYPu6lyYmnVL1hNicTs0DItNaXeZpI/csT/yFAO3cN977B2Br8DA+AoowJVB 0k0A3RwxiS9NG18pA+cTXNvAXWzYZtxM+HI1DO0O4WqpA100Z91S5AREutHtAIYSqO7e K5yG/WSudiOlWPOZYx382RV0w5vTeM53/ddfzBEddJ9eaqzmfDSEjDOFP9zWXpZZXwya NWD/1QUTp87voHWrK6rKMfcYNs7sFUUEy5IMVwSXYR62dqvhrMuWKTgODGJGCWgrrtD0 TgxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=OxVp+9d+oEU2tgMoWI/rjmrq8RE3pIpAyuKE9HO6eBg=; b=icNamduGw6OA+tpiMLOizg87nM+FFsDorvc/GCqH862T67ADlXfKjcVbckh47eGqA4 FAvntcTA6gh89h7JAh4dh9Yabc6xKPB6tQlnaDxMKSa69EE5LHv/MnP+nBh2aopfJqKE FCGCWyMlCdeyHE/duQbx9d+RD4OgbPhiVMLdxSm4MchpOh9C3lldinjz+pIiP5fzFspm Ob3QTE88FXnP4f5a8OwG0XL7K50gCB1Lw0ZN1g2Y+dnx7wFbV7pqcuWdWmJi9VzvOk6K LvrtU0rrrnC/LwZp9z7Gnxbv4ZJgWUeODLWCsEP2ZBz1bBw7hnfrC8LARxUx3Rwf9kdq 3X7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=RsjluKDs; dkim=pass header.i=@codeaurora.org header.s=default header.b=fxOu27Wc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8-v6si16827556plo.295.2018.04.25.14.06.32; Wed, 25 Apr 2018 14:06:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=RsjluKDs; dkim=pass header.i=@codeaurora.org header.s=default header.b=fxOu27Wc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752797AbeDYVFH (ORCPT + 99 others); Wed, 25 Apr 2018 17:05:07 -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= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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