Received: by 10.223.176.46 with SMTP id f43csp4080076wra; Tue, 23 Jan 2018 04:02:52 -0800 (PST) X-Google-Smtp-Source: AH8x225vpL2NKYu6jCCa6q0HgkGXZR6PAzJ/ZppTZsPrYDXjZOo6R+6Z4B7V4ZveuPsxvHHBUvyE X-Received: by 10.101.97.12 with SMTP id z12mr8360493pgu.92.1516708971965; Tue, 23 Jan 2018 04:02:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516708971; cv=none; d=google.com; s=arc-20160816; b=cyCA8yLiYzlsCBvDCKa/tMQYkuNqAWuanFKXCT2SUFTlc3Dm2CxdTd9j40wamqm+Al KIjp89f5x+HFxPq4tbLGNeGaPLvwT64xwSFKX+tFahCbP8xoZmwmRWI9XtK5eWFmqEXM +0P+Fihew32lRJ4YSUS+2gmimhHsMeKSxCVRjgMbSF566tL7+ZIfLa2veN90Y+j5/tJD Zy5bIjwJhgiXRYsr9NSf4RLcnBnKDzdPtpVxVOkHp0EQ9+ojMDNYepgXm5Ajmm5obIWx xmSylM82qMxE0KVSEC/hpCC6GTneuMla7fMROflGJg5pLdIrre4Sglpq9li43IcmuQDL VbrQ== 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=FKO4AxaTrKbnGuQ8iA4pe8harToDfi8wb0PAzTAZMu3HZPRZ64eN4S4FAKZpDO+YDG a3JocrLeIIUNvCCR/j1vIMn6bMYw4VJAxvEG4sfzgtPyJGypeEMp6LOg2af6R3iJ+i5r EaJainXdNgGCljUIdj7k4ikkhp+0SU6VNfHySeG1ozoAzTR74v7MPMAcu1xs0kEdxCBR E5Z9vlb6CKIC8+6r89uksyfYuGlE126DEh6XXTSxm48ioMzBWuVu6QnB63+4LFK00jXC JWeJbWHQ9lGy1XisZr0VrepNuB2rbRX+vynO4+o1mc4WeDlO2AHo8rwt6RlgZtEHG56b lfhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M8JrD0S4; 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 n8si14909756pgc.322.2018.01.23.04.02.36; Tue, 23 Jan 2018 04:02:51 -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=M8JrD0S4; 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 S1751351AbeAWMA4 (ORCPT + 99 others); Tue, 23 Jan 2018 07:00:56 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:46875 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751169AbeAWMAx (ORCPT ); Tue, 23 Jan 2018 07:00:53 -0500 Received: by mail-pf0-f195.google.com with SMTP id y5so136737pff.13 for ; Tue, 23 Jan 2018 04:00:52 -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=M8JrD0S4Zl8PUP15QmxBF7RxRDwpWw4E5k1GSTlM8ykECeXxHcZ60U5sFg0HojiyTO qYAlyEoA7hd+ddIg5m073uYKq6XN51icVbclM1OTZ5iiQdU8J8LTrtfnBgTrpsPTFnvC 7HD9CmKnExqe/MGh2dS/XPl9cuW7vuztPHsQU= 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=S8WovtVflhy7Bv4A/FoZ5/73PxjgD68Jd6naRoOtAWFVXR3salYkgXBTmJwnU57qlb tEjkF0UE/BAevqBFpUeiN8zYvJtPvOtNwfA1DEu6laXpHz5ov0PTzRizXwy2WIXpApBy lBdTdP1GbzzNXvg2OEqw+uk0EzQxaYwHDiCpaQfU/U9OGDOSSN34huGhh0CloDoK1zKX gE+kQRzm7iG9QOiXZaKBY0qraWVQBvfdoK+ZjCmXbIRUuYzEOe7n5xOOY4jYfH/l4Emu gWaa+z7/ASDoFJelIXPKDtGoSXtcWiKiVSfKnY1c9doiv8ijyLCbu9Q4/mhwRcO5Lj9t UhuA== X-Gm-Message-State: AKwxyte0TkpeB5FnZRRGjpPKKiUKfqivccsRFcbcPDVgIL51Y4a2uYOs Auw5b23z22G2wwCaf2fLDzNRtw== X-Received: by 10.101.101.144 with SMTP id u16mr8552042pgv.73.1516708852473; Tue, 23 Jan 2018 04:00:52 -0800 (PST) Received: from ubt.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id p75sm5853049pfi.148.2018.01.23.04.00.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jan 2018 04:00:51 -0800 (PST) From: Chunyan Zhang To: Mark Brown , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chunyan Zhang Subject: [PATCH V4 3/5] drivers: regulator: leave one item to record whether regulator is enabled Date: Tue, 23 Jan 2018 19:59:41 +0800 Message-Id: <1516708783-6288-3-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516708783-6288-1-git-send-email-zhang.chunyan@linaro.org> References: <1516708783-6288-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