Received: by 10.223.176.46 with SMTP id f43csp672979wra; Fri, 26 Jan 2018 05:10:57 -0800 (PST) X-Google-Smtp-Source: AH8x225eNefCJJ9IzW3PO7JawYo7AaNkpSPEfucQ+AEOzaKN5tnXQF0VF2vTOF3zE7QhKR9aqVUt X-Received: by 2002:a17:902:6bc3:: with SMTP id m3-v6mr14209141plt.442.1516972256740; Fri, 26 Jan 2018 05:10:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516972256; cv=none; d=google.com; s=arc-20160816; b=Ak2L88w7y7DTIC5gOMMnAPH6AC3N8jUmALv6+f9lm1iRte5MMfyZPQIhnLIAxeaAPk w1Z3Poibl7hTCQ9wUjZBGkBsdAcXcTiZVvD23rgRaLei4FwgB/wOVhJeS2U9eYDWrts3 uz4vQ1D6vMNLbw8w9vJsOYYgUWWlHwnj+3kACDXJgPuNlIciMeWkSyW0Zc+/rnjwD8NW sKXYEVhvNyanWygU5QGC3xv9Y0GJgd1hi042cKILAPAsZRlAc0rN2o768P3URE1cgwhQ 7/IchSCqqJ15sjwWVARIYXmdqinQaBh2jk54shCVbjJd3lA6wStIDbKqUbNAnz1lSywe iiPw== 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 b9si3013610pgf.430.2018.01.26.05.10.42; Fri, 26 Jan 2018 05:10:56 -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 S1752183AbeAZNKA (ORCPT + 99 others); Fri, 26 Jan 2018 08:10:00 -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(-) 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; }; /** -- 2.7.4