public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: Use tps65912_set_voltage_sel for both DCDCx and LDOx
@ 2012-03-14  2:18 Axel Lin
  2012-03-14  2:20 ` [PATCH 2/2] regulator: Simplify implementation of tps65912_get_voltage_dcdc Axel Lin
  2012-03-14 12:39 ` [PATCH 1/2] regulator: Use tps65912_set_voltage_sel for both DCDCx and LDOx Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-03-14  2:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Margarita Olaya Cabrera, Liam Girdwood, Mark Brown

commit 42b5ef "regulator: tps65912: Use simple equations to get register address"
uses tps65912_get_sel_register to replace tps65912_get_dcdc_sel_register
and tps65912_get_ldo_sel_register.

Now tps65912_set_voltage_dcdc_sel and tps65912_set_voltage_ldo_sel has exactly
the same implementation. Merge them to tps65912_set_voltage_sel function.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/tps65912-regulator.c |   19 +++----------------
 1 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c
index ede688b..988d0ec 100644
--- a/drivers/regulator/tps65912-regulator.c
+++ b/drivers/regulator/tps65912-regulator.c
@@ -442,7 +442,7 @@ static int tps65912_get_voltage_dcdc(struct regulator_dev *dev)
 	return tps65912_list_voltage_dcdc(dev, vsel);
 }
 
-static int tps65912_set_voltage_dcdc_sel(struct regulator_dev *dev,
+static int tps65912_set_voltage_sel(struct regulator_dev *dev,
 					 unsigned selector)
 {
 	struct tps65912_reg *pmic = rdev_get_drvdata(dev);
@@ -472,19 +472,6 @@ static int tps65912_get_voltage_ldo(struct regulator_dev *dev)
 	return tps65912_vsel_to_uv_ldo(vsel);
 }
 
-static int tps65912_set_voltage_ldo_sel(struct regulator_dev *dev,
-					unsigned selector)
-{
-	struct tps65912_reg *pmic = rdev_get_drvdata(dev);
-	struct tps65912 *mfd = pmic->mfd;
-	int id = rdev_get_id(dev), reg, value;
-
-	reg = tps65912_get_sel_register(pmic, id);
-	value = tps65912_reg_read(mfd, reg);
-	value &= 0xC0;
-	return tps65912_reg_write(mfd, reg, selector | value);
-}
-
 static int tps65912_list_voltage_ldo(struct regulator_dev *dev,
 					unsigned selector)
 {
@@ -504,7 +491,7 @@ static struct regulator_ops tps65912_ops_dcdc = {
 	.set_mode = tps65912_set_mode,
 	.get_mode = tps65912_get_mode,
 	.get_voltage = tps65912_get_voltage_dcdc,
-	.set_voltage_sel = tps65912_set_voltage_dcdc_sel,
+	.set_voltage_sel = tps65912_set_voltage_sel,
 	.list_voltage = tps65912_list_voltage_dcdc,
 };
 
@@ -514,7 +501,7 @@ static struct regulator_ops tps65912_ops_ldo = {
 	.enable = tps65912_reg_enable,
 	.disable = tps65912_reg_disable,
 	.get_voltage = tps65912_get_voltage_ldo,
-	.set_voltage_sel = tps65912_set_voltage_ldo_sel,
+	.set_voltage_sel = tps65912_set_voltage_sel,
 	.list_voltage = tps65912_list_voltage_ldo,
 };
 
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] regulator: Simplify implementation of tps65912_get_voltage_dcdc
  2012-03-14  2:18 [PATCH 1/2] regulator: Use tps65912_set_voltage_sel for both DCDCx and LDOx Axel Lin
@ 2012-03-14  2:20 ` Axel Lin
  2012-03-14 12:39 ` [PATCH 1/2] regulator: Use tps65912_set_voltage_sel for both DCDCx and LDOx Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2012-03-14  2:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: Margarita Olaya Cabrera, Liam Girdwood, Mark Brown

Call tps65912_get_sel_register instead of duplicating the same code.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/tps65912-regulator.c |   31 +++++--------------------------
 1 files changed, 5 insertions(+), 26 deletions(-)

diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c
index 988d0ec..b36799b 100644
--- a/drivers/regulator/tps65912-regulator.c
+++ b/drivers/regulator/tps65912-regulator.c
@@ -409,34 +409,13 @@ static int tps65912_get_voltage_dcdc(struct regulator_dev *dev)
 	struct tps65912_reg *pmic = rdev_get_drvdata(dev);
 	struct tps65912 *mfd = pmic->mfd;
 	int id = rdev_get_id(dev);
-	int opvsel = 0, avsel = 0, sr, vsel;
+	int reg, vsel;
 
-	switch (id) {
-	case TPS65912_REG_DCDC1:
-		opvsel = tps65912_reg_read(mfd, TPS65912_DCDC1_OP);
-		avsel = tps65912_reg_read(mfd, TPS65912_DCDC1_AVS);
-		break;
-	case TPS65912_REG_DCDC2:
-		opvsel = tps65912_reg_read(mfd, TPS65912_DCDC2_OP);
-		avsel = tps65912_reg_read(mfd, TPS65912_DCDC2_AVS);
-		break;
-	case TPS65912_REG_DCDC3:
-		opvsel = tps65912_reg_read(mfd, TPS65912_DCDC3_OP);
-		avsel = tps65912_reg_read(mfd, TPS65912_DCDC3_AVS);
-		break;
-	case TPS65912_REG_DCDC4:
-		opvsel = tps65912_reg_read(mfd, TPS65912_DCDC4_OP);
-		avsel = tps65912_reg_read(mfd, TPS65912_DCDC4_AVS);
-		break;
-	default:
-		return -EINVAL;
-	}
+	reg = tps65912_get_sel_register(pmic, id);
+	if (reg < 0)
+		return reg;
 
-	sr = (opvsel & OP_SELREG_MASK) >> OP_SELREG_SHIFT;
-	if (sr)
-		vsel = avsel;
-	else
-		vsel = opvsel;
+	vsel = tps65912_reg_read(mfd, reg);
 	vsel &= 0x3F;
 
 	return tps65912_list_voltage_dcdc(dev, vsel);
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] regulator: Use tps65912_set_voltage_sel for both DCDCx and LDOx
  2012-03-14  2:18 [PATCH 1/2] regulator: Use tps65912_set_voltage_sel for both DCDCx and LDOx Axel Lin
  2012-03-14  2:20 ` [PATCH 2/2] regulator: Simplify implementation of tps65912_get_voltage_dcdc Axel Lin
@ 2012-03-14 12:39 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-03-14 12:39 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Margarita Olaya Cabrera, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 277 bytes --]

On Wed, Mar 14, 2012 at 10:18:45AM +0800, Axel Lin wrote:
> commit 42b5ef "regulator: tps65912: Use simple equations to get register address"
> uses tps65912_get_sel_register to replace tps65912_get_dcdc_sel_register
> and tps65912_get_ldo_sel_register.

Applied both, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-14 12:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-14  2:18 [PATCH 1/2] regulator: Use tps65912_set_voltage_sel for both DCDCx and LDOx Axel Lin
2012-03-14  2:20 ` [PATCH 2/2] regulator: Simplify implementation of tps65912_get_voltage_dcdc Axel Lin
2012-03-14 12:39 ` [PATCH 1/2] regulator: Use tps65912_set_voltage_sel for both DCDCx and LDOx Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox