public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: Implement tps65912_list_voltage to be shared by both DCDCs and LDOs
@ 2012-03-15  9:17 Axel Lin
  2012-03-15  9:18 ` [PATCH 2/2] regulator: Use tps65912_get_voltage for " Axel Lin
  2012-03-21  8:54 ` [PATCH 1/2] regulator: Implement tps65912_list_voltage to be shared by " Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-03-15  9:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: Margarita Olaya Cabrera, Liam Girdwood, Mark Brown

Merge tps65912_list_voltage_dcdc and tps65912_list_voltage_ldo to
tps65912_list_voltage.  This change does not add too much complexity in
tps65912_list_voltage function.

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

diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c
index b36799b..46f3c61 100644
--- a/drivers/regulator/tps65912-regulator.c
+++ b/drivers/regulator/tps65912-regulator.c
@@ -372,12 +372,14 @@ static unsigned int tps65912_get_mode(struct regulator_dev *dev)
 	return mode;
 }
 
-static int tps65912_list_voltage_dcdc(struct regulator_dev *dev,
-					unsigned selector)
+static int tps65912_list_voltage(struct regulator_dev *dev, unsigned selector)
 {
 	struct tps65912_reg *pmic = rdev_get_drvdata(dev);
 	int range, voltage = 0, id = rdev_get_id(dev);
 
+	if (id >= TPS65912_REG_LDO1 && id <= TPS65912_REG_LDO10)
+		return tps65912_vsel_to_uv_ldo(selector);
+
 	if (id > TPS65912_REG_DCDC4)
 		return -EINVAL;
 
@@ -418,7 +420,7 @@ static int tps65912_get_voltage_dcdc(struct regulator_dev *dev)
 	vsel = tps65912_reg_read(mfd, reg);
 	vsel &= 0x3F;
 
-	return tps65912_list_voltage_dcdc(dev, vsel);
+	return tps65912_list_voltage(dev, vsel);
 }
 
 static int tps65912_set_voltage_sel(struct regulator_dev *dev,
@@ -451,17 +453,6 @@ static int tps65912_get_voltage_ldo(struct regulator_dev *dev)
 	return tps65912_vsel_to_uv_ldo(vsel);
 }
 
-static int tps65912_list_voltage_ldo(struct regulator_dev *dev,
-					unsigned selector)
-{
-	int ldo = rdev_get_id(dev);
-
-	if (ldo < TPS65912_REG_LDO1 || ldo > TPS65912_REG_LDO10)
-		return -EINVAL;
-
-	return tps65912_vsel_to_uv_ldo(selector);
-}
-
 /* Operations permitted on DCDCx */
 static struct regulator_ops tps65912_ops_dcdc = {
 	.is_enabled = tps65912_reg_is_enabled,
@@ -471,7 +462,7 @@ static struct regulator_ops tps65912_ops_dcdc = {
 	.get_mode = tps65912_get_mode,
 	.get_voltage = tps65912_get_voltage_dcdc,
 	.set_voltage_sel = tps65912_set_voltage_sel,
-	.list_voltage = tps65912_list_voltage_dcdc,
+	.list_voltage = tps65912_list_voltage,
 };
 
 /* Operations permitted on LDOx */
@@ -481,7 +472,7 @@ static struct regulator_ops tps65912_ops_ldo = {
 	.disable = tps65912_reg_disable,
 	.get_voltage = tps65912_get_voltage_ldo,
 	.set_voltage_sel = tps65912_set_voltage_sel,
-	.list_voltage = tps65912_list_voltage_ldo,
+	.list_voltage = tps65912_list_voltage,
 };
 
 static __devinit int tps65912_probe(struct platform_device *pdev)
-- 
1.7.5.4




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

* [PATCH 2/2] regulator: Use tps65912_get_voltage for both DCDCs and LDOs
  2012-03-15  9:17 [PATCH 1/2] regulator: Implement tps65912_list_voltage to be shared by both DCDCs and LDOs Axel Lin
@ 2012-03-15  9:18 ` Axel Lin
  2012-03-21  8:54 ` [PATCH 1/2] regulator: Implement tps65912_list_voltage to be shared by " Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2012-03-15  9:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Margarita Olaya Cabrera, Liam Girdwood, Mark Brown

Now tps65912_get_voltage_dcdc and tps65912_get_voltage_ldo has exactly the same
implementation. We can merge them to tps65912_get_voltage function.

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

diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c
index 46f3c61..05ea096 100644
--- a/drivers/regulator/tps65912-regulator.c
+++ b/drivers/regulator/tps65912-regulator.c
@@ -406,7 +406,7 @@ static int tps65912_list_voltage(struct regulator_dev *dev, unsigned selector)
 	return voltage;
 }
 
-static int tps65912_get_voltage_dcdc(struct regulator_dev *dev)
+static int tps65912_get_voltage(struct regulator_dev *dev)
 {
 	struct tps65912_reg *pmic = rdev_get_drvdata(dev);
 	struct tps65912 *mfd = pmic->mfd;
@@ -438,21 +438,6 @@ static int tps65912_set_voltage_sel(struct regulator_dev *dev,
 	return tps65912_reg_write(mfd, reg, selector | value);
 }
 
-static int tps65912_get_voltage_ldo(struct regulator_dev *dev)
-{
-	struct tps65912_reg *pmic = rdev_get_drvdata(dev);
-	struct tps65912 *mfd = pmic->mfd;
-	int id = rdev_get_id(dev);
-	int vsel = 0;
-	u8 reg;
-
-	reg = tps65912_get_sel_register(pmic, id);
-	vsel = tps65912_reg_read(mfd, reg);
-	vsel &= 0x3F;
-
-	return tps65912_vsel_to_uv_ldo(vsel);
-}
-
 /* Operations permitted on DCDCx */
 static struct regulator_ops tps65912_ops_dcdc = {
 	.is_enabled = tps65912_reg_is_enabled,
@@ -460,7 +445,7 @@ static struct regulator_ops tps65912_ops_dcdc = {
 	.disable = tps65912_reg_disable,
 	.set_mode = tps65912_set_mode,
 	.get_mode = tps65912_get_mode,
-	.get_voltage = tps65912_get_voltage_dcdc,
+	.get_voltage = tps65912_get_voltage,
 	.set_voltage_sel = tps65912_set_voltage_sel,
 	.list_voltage = tps65912_list_voltage,
 };
@@ -470,7 +455,7 @@ static struct regulator_ops tps65912_ops_ldo = {
 	.is_enabled = tps65912_reg_is_enabled,
 	.enable = tps65912_reg_enable,
 	.disable = tps65912_reg_disable,
-	.get_voltage = tps65912_get_voltage_ldo,
+	.get_voltage = tps65912_get_voltage,
 	.set_voltage_sel = tps65912_set_voltage_sel,
 	.list_voltage = tps65912_list_voltage,
 };
-- 
1.7.5.4




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

* Re: [PATCH 1/2] regulator: Implement tps65912_list_voltage to be shared by both DCDCs and LDOs
  2012-03-15  9:17 [PATCH 1/2] regulator: Implement tps65912_list_voltage to be shared by both DCDCs and LDOs Axel Lin
  2012-03-15  9:18 ` [PATCH 2/2] regulator: Use tps65912_get_voltage for " Axel Lin
@ 2012-03-21  8:54 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-03-21  8:54 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Margarita Olaya Cabrera, Liam Girdwood

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

On Thu, Mar 15, 2012 at 05:17:36PM +0800, Axel Lin wrote:
> Merge tps65912_list_voltage_dcdc and tps65912_list_voltage_ldo to
> tps65912_list_voltage.  This change does not add too much complexity in
> tps65912_list_voltage function.

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-21  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-15  9:17 [PATCH 1/2] regulator: Implement tps65912_list_voltage to be shared by both DCDCs and LDOs Axel Lin
2012-03-15  9:18 ` [PATCH 2/2] regulator: Use tps65912_get_voltage for " Axel Lin
2012-03-21  8:54 ` [PATCH 1/2] regulator: Implement tps65912_list_voltage to be shared by " Mark Brown

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