Skip to contentSkip to conversation

regulator: da9062: Simplify da9062_buck_set_mode for BUCK_MODE_MANUAL case

PATCH In review Axel Lin 3 participants 6 messages Sep 26, 2019 – Oct 1, 2019

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 regulator: da9062: Simplify da9062_buck_set_mode for BUCK_MODE_MANUAL case

The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify the logic as the result is the same.

---
 drivers/regulator/da9062-regulator.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/regulator/da9062-regulator.c +3 -6
index 710e67081d53..739a40f256f6 100644
@@ -136,7 +136,7 @@ static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
 static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
 {
 	struct da9062_regulator *regl = rdev_get_drvdata(rdev);
-	unsigned int val, mode = 0;
+	unsigned int val;
 	int ret;
 
 	ret = regmap_field_read(regl->mode, &val);
@@ -146,7 +146,6 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
 	switch (val) {
 	default:
 	case BUCK_MODE_MANUAL:
-		mode = REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY;
 		/* Sleep flag bit decides the mode */
 		break;
 	case BUCK_MODE_SLEEP:
@@ -162,11 +161,9 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
 		return 0;
 
 	if (val)
-		mode &= REGULATOR_MODE_STANDBY;
+		return REGULATOR_MODE_STANDBY;
 	else
-		mode &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_FAST;
-
-	return mode;
+		return REGULATOR_MODE_FAST;
 }
 
 /*
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 2/2 regulator: da9063: Simplify da9063_buck_set_mode for BUCK_MODE_MANUAL case

The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify the logic as the result is the same.

---
 drivers/regulator/da9063-regulator.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/regulator/da9063-regulator.c +3 -6
index 28b1b20f45bd..2aceb3b7afc2 100644
@@ -225,7 +225,7 @@ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev)
 {
 	struct da9063_regulator *regl = rdev_get_drvdata(rdev);
 	struct regmap_field *field;
-	unsigned int val, mode = 0;
+	unsigned int val;
 	int ret;
 
 	ret = regmap_field_read(regl->mode, &val);
@@ -235,7 +235,6 @@ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev)
 	switch (val) {
 	default:
 	case BUCK_MODE_MANUAL:
-		mode = REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY;
 		/* Sleep flag bit decides the mode */
 		break;
 	case BUCK_MODE_SLEEP:
@@ -262,11 +261,9 @@ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev)
 		return 0;
 
 	if (val)
-		mode &= REGULATOR_MODE_STANDBY;
+		return REGULATOR_MODE_STANDBY;
 	else
-		mode &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_FAST;
-
-	return mode;
+		return REGULATOR_MODE_FAST;
 }
 
 /*
Signature · 1 line
2.20.1
Reviewed-by on v1 2/2
#2 lore raw

RE: [PATCH 2/2] regulator: da9063: Simplify da9063_buck_set_mode for BUCK_MODE_MANUAL case

Quoted 4 lines · Axel Lin

The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify the logic as the result is the same.

Quoted 47 lines
---
 drivers/regulator/da9063-regulator.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/regulator/da9063- renamed from drivers/regulator/da9063-regulator.c +0 -0

regulator.c
index 28b1b20f45bd..2aceb3b7afc2 100644

drivers/regulator/da9063-regulator.c +1 -1
@@ -225,7 +225,7 @@ static unsigned da9063_buck_get_mode(struct
 regulator_dev *rdev)
 {
 	struct da9063_regulator *regl = rdev_get_drvdata(rdev);
 	struct regmap_field *field;
-	unsigned int val, mode = 0;
+	unsigned int val;
 	int ret;
 
drivers/regulator/da9063-regulator.c +0 -1
 	ret = regmap_field_read(regl->mode, &val);
@@ -235,7 +235,6 @@ static unsigned da9063_buck_get_mode(struct
 regulator_dev *rdev)
 	switch (val) {
 	default:
 	case BUCK_MODE_MANUAL:
-		mode = REGULATOR_MODE_FAST |
 REGULATOR_MODE_STANDBY;
 		/* Sleep flag bit decides the mode */
drivers/regulator/da9063-regulator.c +2 -4
 		break;
 	case BUCK_MODE_SLEEP:
@@ -262,11 +261,9 @@ static unsigned da9063_buck_get_mode(struct
 regulator_dev *rdev)
 		return 0;
 
 	if (val)
-		mode &= REGULATOR_MODE_STANDBY;
+		return REGULATOR_MODE_STANDBY;
 	else
-		mode &= REGULATOR_MODE_NORMAL |
 REGULATOR_MODE_FAST;
-
-	return mode;
+		return REGULATOR_MODE_FAST;
 }

/*
--
2.20.1

maintainer
#3 lore raw

Applied "regulator: da9063: Simplify da9063_buck_set_mode for BUCK_MODE_MANUAL case" to the regulator tree

In reply to Axel Lin

The patch

regulator: da9063: Simplify da9063_buck_set_mode for BUCK_MODE_MANUAL case

has been applied to the regulator tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-5.5

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 e62cb0e0002ceb1a761b4dd7bb6a2bfc77a1ae77 Mon Sep 17 00:00:00 2001
From: Axel Lin <[email protected]>
Date: Thu, 26 Sep 2019 13:51:28 +0800
Subject: [PATCH] regulator: da9063: Simplify da9063_buck_set_mode for
BUCK_MODE_MANUAL case

The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify the logic as the result is the same.

---
 drivers/regulator/da9063-regulator.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/regulator/da9063-regulator.c +3 -6
index 28b1b20f45bd..2aceb3b7afc2 100644
@@ -225,7 +225,7 @@ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev)
 {
 	struct da9063_regulator *regl = rdev_get_drvdata(rdev);
 	struct regmap_field *field;
-	unsigned int val, mode = 0;
+	unsigned int val;
 	int ret;
 
 	ret = regmap_field_read(regl->mode, &val);
@@ -235,7 +235,6 @@ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev)
 	switch (val) {
 	default:
 	case BUCK_MODE_MANUAL:
-		mode = REGULATOR_MODE_FAST | REGULATOR_MODE_STANDBY;
 		/* Sleep flag bit decides the mode */
 		break;
 	case BUCK_MODE_SLEEP:
@@ -262,11 +261,9 @@ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev)
 		return 0;
 
 	if (val)
-		mode &= REGULATOR_MODE_STANDBY;
+		return REGULATOR_MODE_STANDBY;
 	else
-		mode &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_FAST;
-
-	return mode;
+		return REGULATOR_MODE_FAST;
 }
 
 /*
Signature · 1 line
2.20.1
Reviewed-by on v1 1/2
#4 lore raw
In reply to Axel Lin
Quoted 4 lines · Axel Lin

The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify the logic as the result is the same.

This patch will need to be rebased on Marco's update titled:

"regulator: da9062: fix suspend_enable/disable preparation"

However, changes look fine so:

Quoted 47 lines
---
 drivers/regulator/da9062-regulator.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/regulator/da9062- renamed from drivers/regulator/da9062-regulator.c +0 -0

regulator.c
index 710e67081d53..739a40f256f6 100644

drivers/regulator/da9062-regulator.c +1 -1
@@ -136,7 +136,7 @@ static int da9062_buck_set_mode(struct regulator_dev
 *rdev, unsigned mode)
 static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
 {
 	struct da9062_regulator *regl = rdev_get_drvdata(rdev);
-	unsigned int val, mode = 0;
+	unsigned int val;
 	int ret;
 
drivers/regulator/da9062-regulator.c +0 -1
 	ret = regmap_field_read(regl->mode, &val);
@@ -146,7 +146,6 @@ static unsigned da9062_buck_get_mode(struct
 regulator_dev *rdev)
 	switch (val) {
 	default:
 	case BUCK_MODE_MANUAL:
-		mode = REGULATOR_MODE_FAST |
 REGULATOR_MODE_STANDBY;
 		/* Sleep flag bit decides the mode */
drivers/regulator/da9062-regulator.c +2 -4
 		break;
 	case BUCK_MODE_SLEEP:
@@ -162,11 +161,9 @@ static unsigned da9062_buck_get_mode(struct
 regulator_dev *rdev)
 		return 0;
 
 	if (val)
-		mode &= REGULATOR_MODE_STANDBY;
+		return REGULATOR_MODE_STANDBY;
 	else
-		mode &= REGULATOR_MODE_NORMAL |
 REGULATOR_MODE_FAST;
-
-	return mode;
+		return REGULATOR_MODE_FAST;
 }

/*
--
2.20.1

author
#5 lore raw

Adam Thomson <[email protected]> 於 2019年9月26日 週四 下午5:22寫道:

Quoted 11 lines · Axel Lin
Quoted 5 lines

The sleep flag bit decides the mode for BUCK_MODE_MANUAL case, simplify the logic as the result is the same.

This patch will need to be rebased on Marco's update titled:

"regulator: da9062: fix suspend_enable/disable preparation"

This patch is on top of above commit.
Should be applied cleanly.

Thanks,
Axel