Received: by 10.223.176.46 with SMTP id f43csp823399wra; Fri, 26 Jan 2018 07:28:42 -0800 (PST) X-Google-Smtp-Source: AH8x225ZCVohPLnYF7QnX4g3VZgMtwlbZThrDSbGYArq1gCZ8sCYYDVB1gRHWy+eox9+tzuVT8PI X-Received: by 10.99.177.76 with SMTP id g12mr16349248pgp.269.1516980522205; Fri, 26 Jan 2018 07:28:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516980522; cv=none; d=google.com; s=arc-20160816; b=SyYvM6M0UYyqsa80bc8FUP9V4t8vrK8tQd4TH3CW3XvvfFA/kRrwlLGXmaWt4HFCj6 co4wL5IxW3HbDiKu8jGBwyoWbGBItBDarRZzCaLS9EhNJz4gHsFFgZ3kS0kLqXJL/cvi 1QjvwTPorn7NhuDpa+PssvPI3xUo3dkGl6MH4OjLaj7q8+zWl9bCuDl2bIcal87HTFk3 b+69/pj3jfU+K46qzfJqJx5j6COkSx3wZx7z0ajtTPbAoW06H6JTksjn4z63W1OCNsNY 9U+woMvLqzLAQmkjr8kd3pfvWdAduFKMfcehNJ3Wdxi7ntnkp/+wfrWObXzr9CtTblmn 0FNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=DGg6eOr9l5ZK31H1znmV3nWHb3t8ntfRsCJEoJ2as5I=; b=pE6ZjyqHIlesC9Eo6wxzw7oPTY9mprU6oQHB/72XHSKXpMCGroeSbLwP31MN4I0a6a ausIhzn+ArD1kYF7fsi8G8/p23/Vpdm+BfOjydCagTig7oDmKWsHc/5XQwBeBLvCMjs+ L6qFf4FrUSNGMRQzDNdbzPymBKRDcRpkKTJoXNzAxsaWkRizU+rus4fiLQBsulPFez5B X1J+++Sts6Q0MhTmpZWzkE0fn5uEOjvmlHr6ymTjj151b5XPpR77k86drNv/6j77nNWR 1GezPJMmHqrma49Om4CrKWc8sCYES4vEqqwq0QqPOy5J8fzFHhdAzzje7MiPmCDw0pkW 7bbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=db+92xOE; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t16si3122859pgo.398.2018.01.26.07.28.26; Fri, 26 Jan 2018 07:28:42 -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=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=db+92xOE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753393AbeAZP0l (ORCPT + 99 others); Fri, 26 Jan 2018 10:26:41 -0500 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:38530 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753086AbeAZP0H (ORCPT ); Fri, 26 Jan 2018 10:26:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=DGg6eOr9l5ZK31H1znmV3nWHb3t8ntfRsCJEoJ2as5I=; b=db+92xOE/fck Z1pD/TEfjJYPN8FBoF5TsHmzEB9v727rHgolI6+3kIWzV1UER/F3JjX27KLJ4BtRYOxdQD7gxGP+B 73M0ZgckR0KE0GV3OVCvvBPTwX8SQMlELdGcdPR57s3tGmBGCzM2IYULYDOgmrmN43kToFUEgWra3 EIQn4=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ef5tF-0007E2-93; Fri, 26 Jan 2018 15:26:05 +0000 Received: from broonie by debutante with local (Exim 4.90) (envelope-from ) id 1ef5tE-0006dc-Qf; Fri, 26 Jan 2018 15:26:04 +0000 From: Mark Brown To: Chunyan Zhang Cc: Mark Brown , Mark Brown , Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Ulf Hansson , Arnd Bergmann , Chunyan Zhang , linux-kernel@vger.kernel.org Subject: Applied "regulator: leave one item to record whether regulator is enabled" to the regulator tree In-Reply-To: <1515752305-15907-4-git-send-email-zhang.chunyan@linaro.org> Message-Id: Date: Fri, 26 Jan 2018 15:26:04 +0000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch regulator: leave one item to record whether regulator is enabled has been applied to the regulator tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 72069f9957a11896e79e95c8b55ec815e97c2187 Mon Sep 17 00:00:00 2001 From: Chunyan Zhang Date: Fri, 26 Jan 2018 21:08:45 +0800 Subject: [PATCH] regulator: leave one item to record whether regulator is enabled 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 Signed-off-by: Mark Brown --- 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 97bc9f7adf2f..5ea80e94eb69 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 14637a01ba2d..41dad42b18f0 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 9cd4fef37203..ce89c5548c89 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.15.1