From patchwork Thu Dec 21 06:25:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 122509 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp485390qgn; Wed, 20 Dec 2017 22:25:54 -0800 (PST) X-Google-Smtp-Source: ACJfBovSZc8FCKCyQXGm0T2hp93wUgl6g35TjHHjY7H5sJRC1KNqhyYhomItSjBI8FL9CbPzh2sn X-Received: by 10.101.100.199 with SMTP id t7mr8848844pgv.316.1513837554787; Wed, 20 Dec 2017 22:25:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513837554; cv=none; d=google.com; s=arc-20160816; b=Dtqbf7iXHqjqgoL0ps4gy2hnSeAyQxLyyYASl/gXeaCtkUOuZWU8x6am4wsP8dvOrk EYIWbInfynPE7d+gKzrmQTMzxIDaRYjPxNEdqjf/EXbTBHmhgbvMyOR/7PHlUPAV6Am/ c/5W/K9EuAp3TokakswWmgCjpmHBljpdzznAxX3+lSKbfLVwBtKvhMYaGEJqPaevz0ds PHZxMWhIdxZVWHmYYQsuxkbfqRCIGEuqhuJvDzajzkYCaKUtO3V4GAbv5WC6f2enLQc8 GXxo9cRKdVf5yuAt3kYgpq0nPrZndpQBu/hG7bLKcSMh7JJF8rB9o5jghyVxTfEG7SMV EbOw== 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=jkvcWkCfs/3yJIIexrdCvn3amSwEvdN47NDvBiInvw4=; b=vjFTJK1dBbLHv6xAqLTRyC+L6UXEgR0SXnkHeyV2fQP/EkkdN1I0QzJuln4uhjz2Xt tY1wSWJVpfBPQ2ko7LyGEzEdLDNdWxDIxdTXT5FRdMFNQFdOflVt8yBhmwS+ipIPSqVH xU04VEe+FKfx73SNW1W4TlN11RBfRg25O91E+X4o1/pkEo/kluXRPABVAHeROEszKpmf Gqsa3j1EvxbY69aGMehcfi1Ji153QXGGnQgGBBH/ST5OTDnbm55y3/ePU6C1Zc/U89OR jeb3gJk8MBpchyeIqz1GLzWcgFQF3XNE6wb9UqBnkTZWDK+eUZM3666CiSvgHypeTAdi fjzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=E+Wo7OsH; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (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 n3si1638719pgf.122.2017.12.20.22.25.54; Wed, 20 Dec 2017 22:25:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=E+Wo7OsH; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932086AbdLUGZq (ORCPT + 6 others); Thu, 21 Dec 2017 01:25:46 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:42522 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751838AbdLUGZj (ORCPT ); Thu, 21 Dec 2017 01:25:39 -0500 Received: by mail-pg0-f67.google.com with SMTP id q67so3676890pga.9 for ; Wed, 20 Dec 2017 22:25:39 -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=9azF0a/CRva7kzQyUrrdYveI6VR5wsw/N+Df49tk6LE=; b=E+Wo7OsHXkqF3GZo2d2MX6ssnUyTUjv3g5/Z9bC+MnmY6kbDXku8/muHKzrcr2ayTy 11SqJQTzdGYBMoXPtXPlcRWjDf7JW2ubxniMhYpCD3RPGQthONTsW0vWTP1xoJdXmrcH IuHEBkDRX8MwFPjbfZK728KBri2j1umI3qEgM= 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=9azF0a/CRva7kzQyUrrdYveI6VR5wsw/N+Df49tk6LE=; b=AYfyS4jcpq1jBvRajRM6n4/a+xc3WQDz/4qkHBwN10kpNzYiLuouiFxn7xxUhdqXdN ES48F2CnHE0B05XM35sD5xWc2++hY7o1ktREvXGmtOsjoc39GOpeGHDy0B6xUHbWH6km PPkfjTL+M0qLq8F2nRL0/+3+wmi+3l17EPCsYxchVp0GauSOpNfPVKyFjzmQ1QiGoA7U W/7n48E1XnIXWGgSqgfudX8EF/WWAOlzw7uqyRneyJLL7cLJfmxC4Iq+bq51rTyFC0zw 1uU2Kgnb03a+p8UDXD2YB9UxPmtS0T70fpYHexn23gX3r1QBDqXfyIu5FNpOW7aCxN3U TYeQ== X-Gm-Message-State: AKGB3mJd9StFwRiaDKfQA4gn81Ak5rEch4kN0vOoAOhCct4BSHzkweK5 c7B4Ve303mjrmXhpiLtCcXi48w== X-Received: by 10.99.157.206 with SMTP id i197mr8522605pgd.409.1513837538899; Wed, 20 Dec 2017 22:25:38 -0800 (PST) Received: from ubt.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id o88sm36970683pfj.175.2017.12.20.22.25.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Dec 2017 22:25:38 -0800 (PST) From: Chunyan Zhang To: Mark Brown , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chunyan Zhang Subject: [PATCH 3/5] drivers: regulator: leave one item to record whether regulator is enabled Date: Thu, 21 Dec 2017 14:25:04 +0800 Message-Id: <1513837506-26543-4-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513837506-26543-1-git-send-email-zhang.chunyan@linaro.org> References: <1513837506-26543-1-git-send-email-zhang.chunyan@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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 | 12 +++++++++--- 3 files changed, 19 insertions(+), 13 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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..e50519f 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h @@ -42,6 +42,11 @@ struct regulator; #define REGULATOR_CHANGE_DRMS 0x10 #define REGULATOR_CHANGE_BYPASS 0x20 +/* operations in suspend mode */ +#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 +63,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 */ }; /**