Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756436AbcDGOWy (ORCPT ); Thu, 7 Apr 2016 10:22:54 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:35047 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756415AbcDGOWw (ORCPT ); Thu, 7 Apr 2016 10:22:52 -0400 From: Thierry Reding To: Mark Brown Cc: Jon Hunter , Liam Girdwood , linux-kernel@vger.kernel.org Subject: [PATCH 3/5] regulator: helpers: Ensure bypass register field matches ON value Date: Thu, 7 Apr 2016 16:22:37 +0200 Message-Id: <1460038959-21592-3-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1460038959-21592-1-git-send-email-thierry.reding@gmail.com> References: <1460038959-21592-1-git-send-email-thierry.reding@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1121 Lines: 32 From: Jon Hunter When checking the bypass state for a regulator, we check to see if any bits in the bypass mask are set. For most cases this is fine because there is typically only a single bit used to determine if the regulator is in bypass. However, for some regulators, such as LDO6 on AS3722, the bypass state is indicated by a value rather than a single bit. Therefore, when checking the bypass state, check that the bypass field matches the ON value. Signed-off-by: Jon Hunter Signed-off-by: Thierry Reding --- drivers/regulator/helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index b1e32e7482e9..bcf38fd5106a 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -460,7 +460,7 @@ int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) if (ret != 0) return ret; - *enable = val & rdev->desc->bypass_mask; + *enable = (val & rdev->desc->bypass_mask) == rdev->desc->bypass_val_on; return 0; } -- 2.8.0