From patchwork Fri Jan 26 13:08:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 125964 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp324289ljd; Fri, 26 Jan 2018 05:10:04 -0800 (PST) X-Google-Smtp-Source: AH8x226ZkWj3keJXFqnVE9i4ZZv4KL/nA3L857nL1b6R4rO7kNebz7WzvVuUxOvXb57+l/p1Jm1z X-Received: by 10.99.56.85 with SMTP id h21mr15366686pgn.402.1516972204296; Fri, 26 Jan 2018 05:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516972204; cv=none; d=google.com; s=arc-20160816; b=K7V3Wnypd/dQywoPwPREj6vji22wUa37ljDz4RdTt0LAAqNcvP6RCDM1GpWCi2hQjc cLj/xAmAUCzdT0wIwPHfuYEo2FE+Z9F+9d1hInNoImT1MMcYXtHocoTmCc/BeMnBtUYn CqbRTgLM9Ts81+dk37/54yGQO+C49AQoyG+9BHg1ACLLR00hdklbKHQ0U9atptZqFCI/ iUNI93kIiesflALWABK7lsrVf/b0PXeDdbGfrtmLLbeSh5PSGYBmymM1HFAFgM5yCKaf 0S1szdwjnTS9OMXUKmxfYlrpZCbVszDFQywzWCk1nhzsuATvAxmNv/Hy9pp/48ExVjrt H8fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=EcLpvBMIMakiKa8EPdDMFEkOKTKDf++0HWt3W/KiWU4=; b=KUBaOBSfIL4sW41u6iZ65B0H6QTR2YnbBaf40kDRas8BDKHMH0R8SYTvka4YHukS8D qhSpXaGIzDw67Jjmjvoml1ZMgoT5eUGcYVXm/j6hs5rIWdR8EqQlfUMFvWoBHCsGclRo KAhuuUqPcQUXsswx8+W7DNDSLzQ0YBQdhYGGopyQxPKRYJi6qd/WUGFRvxex+dqi7h25 tqRu0FXAc5w/XC8BZ+5B690r1oafUcIyHpQio57FVrPBFUpqLglPHxvWRwN+SzcZZ6WA 2ymDnx2u3AWzFgCiO9/syy7tfcXsR5/zhu30KFdx8EiMsXcgfmGqGFGxipYxVJN8f7WD fimw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B7nA6Beh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a89si6383161pfj.107.2018.01.26.05.10.04; Fri, 26 Jan 2018 05:10:04 -0800 (PST) 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=@linaro.org header.s=google header.b=B7nA6Beh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752200AbeAZNKB (ORCPT + 28 others); Fri, 26 Jan 2018 08:10:01 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:45743 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751664AbeAZNJQ (ORCPT ); Fri, 26 Jan 2018 08:09:16 -0500 Received: by mail-pf0-f195.google.com with SMTP id a88so216451pfe.12 for ; Fri, 26 Jan 2018 05:09:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EcLpvBMIMakiKa8EPdDMFEkOKTKDf++0HWt3W/KiWU4=; b=B7nA6BehZHF7TFm4eFiVU1nACabbE662RlrHGgXWRSYpDKayvZZumx2IYl3FwEDcEX wxiyeLMWLJmBVudqZQw7z3ypwto1mpo64qtfz/TGjqgSX5qqhsRpV4ILm9vsSBeKG3Qn 8TjiBtRFjXx8q6FWY5qO0DteLrU63hXHJHmSg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EcLpvBMIMakiKa8EPdDMFEkOKTKDf++0HWt3W/KiWU4=; b=gANSMiXIK2XVS4mVO/ZyPg5YnzPzfhdeoQblfXnHWcfRLeVGQFrEbA0sVK8EiqXbOK 51EuMGoTstPIV4tDNw5mWkiqxm5/sXvaERe6b7k5hkx8oIiydT2uHwuAZP2d5TWI6TpA +675ev/8N55s1I3RqZ2veKUkmZQ1gWxTPfg7LO6+zQyNOv8isZy+SZn81x3U/yN38zP8 nrRk38yiSO5a55Oe2jkXMDPgUNFDoP6FocTj1IccZhgN+edyUEZpOfpoRezbgqwn6eJ0 1nmUvBnlkl/XUtnoeaBkxa82eam06MpvoN3sRFndPvScMTTxL9eb5u3MpFWvDuW+ximz dVlw== X-Gm-Message-State: AKwxytdOSWEfZUOej97wOHCEv5ywA4SOsrPsIlJHKf/WRa0JRZeQaRof QtYN+pecFM6HCwPCjUtQmNvfVQ== X-Received: by 10.101.64.139 with SMTP id t11mr15207712pgp.162.1516972155955; Fri, 26 Jan 2018 05:09:15 -0800 (PST) Received: from ubt.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id b6sm18663238pfe.85.2018.01.26.05.09.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jan 2018 05:09:15 -0800 (PST) From: Chunyan Zhang To: Mark Brown , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chunyan Zhang Subject: [PATCH V5 3/5] drivers: regulator: leave one item to record whether regulator is enabled Date: Fri, 26 Jan 2018 21:08:45 +0800 Message-Id: <1516972127-972-4-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516972127-972-1-git-send-email-zhang.chunyan@linaro.org> References: <1516972127-972-1-git-send-email-zhang.chunyan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The items "disabled" and "enabled" are a little redundant, since only one of them would be set to record if the regulator device should keep on or be switched to off in suspend states. So in this patch, the "disabled" was removed, only leave the "enabled": - enabled == 1 for regulator-on-in-suspend - enabled == 0 for regulator-off-in-suspend - enabled == -1 means do nothing when entering suspend mode. Signed-off-by: Chunyan Zhang --- drivers/regulator/core.c | 14 ++++++-------- drivers/regulator/of_regulator.c | 6 ++++-- include/linux/regulator/machine.h | 19 +++++++++++++++---- 3 files changed, 25 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 97bc9f7..5ea80e9 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -742,21 +742,19 @@ static int suspend_set_state(struct regulator_dev *rdev, * only warn if the driver implements set_suspend_voltage or * set_suspend_mode callback. */ - if (!rstate->enabled && !rstate->disabled) { + if (rstate->enabled != ENABLE_IN_SUSPEND && + rstate->enabled != DISABLE_IN_SUSPEND) { if (rdev->desc->ops->set_suspend_voltage || rdev->desc->ops->set_suspend_mode) rdev_warn(rdev, "No configuration\n"); return 0; } - if (rstate->enabled && rstate->disabled) { - rdev_err(rdev, "invalid configuration\n"); - return -EINVAL; - } - - if (rstate->enabled && rdev->desc->ops->set_suspend_enable) + if (rstate->enabled == ENABLE_IN_SUSPEND && + rdev->desc->ops->set_suspend_enable) ret = rdev->desc->ops->set_suspend_enable(rdev); - else if (rstate->disabled && rdev->desc->ops->set_suspend_disable) + else if (rstate->enabled == DISABLE_IN_SUSPEND && + rdev->desc->ops->set_suspend_disable) ret = rdev->desc->ops->set_suspend_disable(rdev); else /* OK if set_suspend_enable or set_suspend_disable is NULL */ ret = 0; diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 14637a0..41dad42 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -177,10 +177,12 @@ static void of_get_regulation_constraints(struct device_node *np, if (of_property_read_bool(suspend_np, "regulator-on-in-suspend")) - suspend_state->enabled = true; + suspend_state->enabled = ENABLE_IN_SUSPEND; else if (of_property_read_bool(suspend_np, "regulator-off-in-suspend")) - suspend_state->disabled = true; + suspend_state->enabled = DISABLE_IN_SUSPEND; + else + suspend_state->enabled = DO_NOTHING_IN_SUSPEND; if (!of_property_read_u32(suspend_np, "regulator-suspend-microvolt", &pval)) diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index 9cd4fef..ce89c55 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h @@ -42,6 +42,16 @@ struct regulator; #define REGULATOR_CHANGE_DRMS 0x10 #define REGULATOR_CHANGE_BYPASS 0x20 +/* + * operations in suspend mode + * DO_NOTHING_IN_SUSPEND - the default value + * DISABLE_IN_SUSPEND - turn off regulator in suspend states + * ENABLE_IN_SUSPEND - keep regulator on in suspend states + */ +#define DO_NOTHING_IN_SUSPEND (-1) +#define DISABLE_IN_SUSPEND 0 +#define ENABLE_IN_SUSPEND 1 + /* Regulator active discharge flags */ enum regulator_active_discharge { REGULATOR_ACTIVE_DISCHARGE_DEFAULT, @@ -58,14 +68,15 @@ enum regulator_active_discharge { * * @uV: Operating voltage during suspend. * @mode: Operating mode during suspend. - * @enabled: Enabled during suspend. - * @disabled: Disabled during suspend. + * @enabled: operations during suspend. + * - DO_NOTHING_IN_SUSPEND + * - DISABLE_IN_SUSPEND + * - ENABLE_IN_SUSPEND */ struct regulator_state { int uV; /* suspend voltage */ unsigned int mode; /* suspend regulator operating mode */ - int enabled; /* is regulator enabled in this suspend state */ - int disabled; /* is the regulator disabled in this suspend state */ + int enabled; }; /**