Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932983AbeAIGIt (ORCPT + 1 other); Tue, 9 Jan 2018 01:08:49 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:43036 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932928AbeAIGIr (ORCPT ); Tue, 9 Jan 2018 01:08:47 -0500 X-Google-Smtp-Source: ACJfBov9Fr+JintAGnRAGyZMYn2yHMJv9UtIbkkBh6XK8Fv8qcaJc8Koc9YdNAmtWuyd+BglFtQzyMWzNtczC6pgxv8= MIME-Version: 1.0 In-Reply-To: <20180108123533.GE11698@sirena.org.uk> References: <1515050568-23876-1-git-send-email-zhang.chunyan@linaro.org> <1515050568-23876-2-git-send-email-zhang.chunyan@linaro.org> <20180105185328.zmt33idv2cqled62@rob-hp-laptop> <20180105191837.GI9076@sirena.org.uk> <20180108123533.GE11698@sirena.org.uk> From: Chunyan Zhang Date: Tue, 9 Jan 2018 14:08:45 +0800 Message-ID: Subject: Re: [PATCH V2 1/5] bindings: regulator: added support for suspend states To: Mark Brown Cc: Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson , Chunyan Zhang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 8 January 2018 at 20:35, Mark Brown wrote: > On Mon, Jan 08, 2018 at 02:36:36PM +0800, Chunyan Zhang wrote: >> On 6 January 2018 at 03:18, Mark Brown wrote: > >> > No, it means that the software has permission to use those changes to >> > those registers - we only want to be changing things if the user has >> > permission to change them since some systems will have specific >> > constraints, we don't know if it's safe without being explicitly told. >> > You're right that we could infer this from a range being provided >> > though, let's do that. > >> Ok, so we don't need this property IIUC, and instead we just need to check >> if the regulator-suspend-min-microvolt and regulator-suspend-max-microvolt >> are set to the same value, right? > > Yes. Then, do we need a flag as well to give permission to change 'suspend_state->enabled'? Or we just do keeping the regulator device enabled if any consumer of it has set voltage for suspend mode with non-zero value, and do switching it off if all consumers of it have set voltage for suspend with zero. +static int _regulator_set_suspend_voltage(struct regulator *regulator, + int min_uV, int max_uV, + suspend_state_t state) +{ + int ret; + struct regulator_dev *rdev = regulator->rdev; + + /* + * We assume users want to switch off the regulator device for + * suspend state when setting min_uV and max_uV all with zero. + */ + if (min_uV == 0 && max_uV == 0) { + regulator->voltage[state].min_uV = 0; + regulator->voltage[state].max_uV = 0; + return regulator_suspend_disable(rdev, state); + } + + ret = regulator_suspend_enable(rdev, state); + if (ret < 0) + return ret; + + return regulator_set_voltage_unlocked(regulator, min_uV, max_uV, state); +}