linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: ab8500: Remove unused voltage_shift field from struct expand_register
@ 2013-04-17 14:54 Axel Lin
  2013-04-17 14:55 ` [PATCH 2/2] regulator: ab8500: Get rid of voltage_shift field from struct ab8500_regulator_info Axel Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Axel Lin @ 2013-04-17 14:54 UTC (permalink / raw)
  To: Mark Brown
  Cc: Bengt Jonsson, Lee Jones, Yvan FILLION, Liam Girdwood, linux-kernel

The voltage_shift field of struct expand_register is not used now, remove it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/ab8500.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 279793e..ece31a3 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -89,7 +89,6 @@ struct ab8500_regulator_info {
 		u8 voltage_bank;
 		u8 voltage_reg;
 		u8 voltage_mask;
-		u8 voltage_shift;
 	} expand_register;
 };
 
@@ -1532,7 +1531,6 @@ static struct ab8500_regulator_info
 			.voltage_bank		= 0x04,
 			.voltage_reg		= 0x01,
 			.voltage_mask		= 0x10,
-			.voltage_shift		= 1,
 		}
 	},
 	[AB8540_LDO_AUX4] = {
-- 
1.7.10.4




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

* [PATCH 2/2] regulator: ab8500: Get rid of voltage_shift field from struct ab8500_regulator_info
  2013-04-17 14:54 [PATCH 1/2] regulator: ab8500: Remove unused voltage_shift field from struct expand_register Axel Lin
@ 2013-04-17 14:55 ` Axel Lin
  2013-04-18  6:38   ` Bengt Jönsson
  2013-04-18  6:36 ` [PATCH 1/2] regulator: ab8500: Remove unused voltage_shift field from struct expand_register Bengt Jönsson
  2013-04-18 17:27 ` Mark Brown
  2 siblings, 1 reply; 5+ messages in thread
From: Axel Lin @ 2013-04-17 14:55 UTC (permalink / raw)
  To: Mark Brown
  Cc: Bengt Jonsson, Lee Jones, Yvan FILLION, Liam Girdwood, linux-kernel

The voltage_shift can be calculated from voltage_mask.
Let's remove voltage_shift fied from struct ab8500_regulator_info, this change
can prevent missing voltage_shift setting issue.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/ab8500.c |   33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index ece31a3..f6656b8 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -61,7 +61,6 @@ struct ab8500_shared_mode {
  * @voltage_bank: bank to control regulator voltage
  * @voltage_reg: register to control regulator voltage
  * @voltage_mask: mask to control regulator voltage
- * @voltage_shift: shift to control regulator voltage
  */
 struct ab8500_regulator_info {
 	struct device		*dev;
@@ -83,7 +82,6 @@ struct ab8500_regulator_info {
 	u8 voltage_bank;
 	u8 voltage_reg;
 	u8 voltage_mask;
-	u8 voltage_shift;
 	struct {
 		u8 voltage_limit;
 		u8 voltage_bank;
@@ -480,7 +478,7 @@ static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
 
 static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
 {
-	int ret, val;
+	int ret, voltage_shift;
 	struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
 	u8 regval;
 
@@ -489,6 +487,8 @@ static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
 		return -EINVAL;
 	}
 
+	voltage_shift = ffs(info->voltage_mask) - 1;
+
 	ret = abx500_get_register_interruptible(info->dev,
 			info->voltage_bank, info->voltage_reg, &regval);
 	if (ret < 0) {
@@ -502,15 +502,14 @@ static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
 		"0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
 		info->desc.name, info->voltage_bank,
 		info->voltage_reg, info->voltage_mask,
-		info->voltage_shift, regval);
+		voltage_shift, regval);
 
-	val = regval & info->voltage_mask;
-	return val >> info->voltage_shift;
+	return (regval & info->voltage_mask) >> voltage_shift;
 }
 
 static int ab8540_aux3_regulator_get_voltage_sel(struct regulator_dev *rdev)
 {
-	int ret;
+	int ret, voltage_shift;
 	struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
 	u8 regval, regval_expand;
 
@@ -550,13 +549,15 @@ static int ab8540_aux3_regulator_get_voltage_sel(struct regulator_dev *rdev)
 		 info->desc.name, info->voltage_bank, info->voltage_reg,
 		 info->voltage_mask, regval);
 
-	return (regval & info->voltage_mask) >> info->voltage_shift;
+	voltage_shift = ffs(info->voltage_mask) - 1;
+
+	return (regval & info->voltage_mask) >> voltage_shift;
 }
 
 static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
 					    unsigned selector)
 {
-	int ret;
+	int ret, voltage_shift;
 	struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
 	u8 regval;
 
@@ -565,8 +566,10 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
 		return -EINVAL;
 	}
 
+	voltage_shift = ffs(info->voltage_mask) - 1;
+
 	/* set the registers for the request */
-	regval = (u8)selector << info->voltage_shift;
+	regval = (u8)selector << voltage_shift;
 	ret = abx500_mask_and_set_register_interruptible(info->dev,
 			info->voltage_bank, info->voltage_reg,
 			info->voltage_mask, regval);
@@ -596,7 +599,9 @@ static int ab8540_aux3_regulator_set_voltage_sel(struct regulator_dev *rdev,
 	}
 
 	if (selector < info->expand_register.voltage_limit) {
-		regval = (u8)selector << info->voltage_shift;
+		int voltage_shift = ffs(info->voltage_mask) - 1;
+
+		regval = (u8)selector << voltage_shift;
 		ret = abx500_mask_and_set_register_interruptible(info->dev,
 					info->voltage_bank, info->voltage_reg,
 					info->voltage_mask, regval);
@@ -791,7 +796,6 @@ static struct ab8500_regulator_info
 		.voltage_bank		= 0x03,
 		.voltage_reg		= 0x80,
 		.voltage_mask		= 0x38,
-		.voltage_shift		= 3,
 	},
 
 	/*
@@ -1066,7 +1070,6 @@ static struct ab8500_regulator_info
 		.voltage_bank		= 0x03,
 		.voltage_reg		= 0x80,
 		.voltage_mask		= 0x38,
-		.voltage_shift		= 3,
 	},
 
 	/*
@@ -1127,7 +1130,6 @@ static struct ab8500_regulator_info
 		.voltage_bank		= 0x01,
 		.voltage_reg		= 0x57,
 		.voltage_mask		= 0x70,
-		.voltage_shift		= 4,
 	},
 	[AB8505_LDO_ANAMIC1] = {
 		.desc = {
@@ -1327,7 +1329,6 @@ static struct ab8500_regulator_info
 		.voltage_bank		= 0x03,
 		.voltage_reg		= 0x80,
 		.voltage_mask		= 0x38,
-		.voltage_shift		= 3,
 	},
 
 	/*
@@ -1622,7 +1623,6 @@ static struct ab8500_regulator_info
 		.voltage_bank		= 0x03,
 		.voltage_reg		= 0x80,
 		.voltage_mask		= 0x38,
-		.voltage_shift		= 3,
 	},
 
 	/*
@@ -1724,7 +1724,6 @@ static struct ab8500_regulator_info
 		.voltage_bank		= 0x03,
 		.voltage_reg		= 0x83,
 		.voltage_mask		= 0xc0,
-		.voltage_shift		= 6,
 	},
 
 	/*
-- 
1.7.10.4




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

* Re: [PATCH 1/2] regulator: ab8500: Remove unused voltage_shift field from struct expand_register
  2013-04-17 14:54 [PATCH 1/2] regulator: ab8500: Remove unused voltage_shift field from struct expand_register Axel Lin
  2013-04-17 14:55 ` [PATCH 2/2] regulator: ab8500: Get rid of voltage_shift field from struct ab8500_regulator_info Axel Lin
@ 2013-04-18  6:36 ` Bengt Jönsson
  2013-04-18 17:27 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Bengt Jönsson @ 2013-04-18  6:36 UTC (permalink / raw)
  To: Axel Lin; +Cc: Mark Brown, Lee Jones, Yvan FILLION, Liam Girdwood, linux-kernel

On 04/17/2013 04:54 PM, Axel Lin wrote:
> The voltage_shift field of struct expand_register is not used now, remove it.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Looks good.

Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>


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

* Re: [PATCH 2/2] regulator: ab8500: Get rid of voltage_shift field from struct ab8500_regulator_info
  2013-04-17 14:55 ` [PATCH 2/2] regulator: ab8500: Get rid of voltage_shift field from struct ab8500_regulator_info Axel Lin
@ 2013-04-18  6:38   ` Bengt Jönsson
  0 siblings, 0 replies; 5+ messages in thread
From: Bengt Jönsson @ 2013-04-18  6:38 UTC (permalink / raw)
  To: Axel Lin; +Cc: Mark Brown, Lee Jones, Yvan FILLION, Liam Girdwood, linux-kernel

On 04/17/2013 04:55 PM, Axel Lin wrote:
> The voltage_shift can be calculated from voltage_mask.
> Let's remove voltage_shift fied from struct ab8500_regulator_info, this change
> can prevent missing voltage_shift setting issue.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Nice improvement.Thanks.

Acked-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>


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

* Re: [PATCH 1/2] regulator: ab8500: Remove unused voltage_shift field from struct expand_register
  2013-04-17 14:54 [PATCH 1/2] regulator: ab8500: Remove unused voltage_shift field from struct expand_register Axel Lin
  2013-04-17 14:55 ` [PATCH 2/2] regulator: ab8500: Get rid of voltage_shift field from struct ab8500_regulator_info Axel Lin
  2013-04-18  6:36 ` [PATCH 1/2] regulator: ab8500: Remove unused voltage_shift field from struct expand_register Bengt Jönsson
@ 2013-04-18 17:27 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2013-04-18 17:27 UTC (permalink / raw)
  To: Axel Lin
  Cc: Bengt Jonsson, Lee Jones, Yvan FILLION, Liam Girdwood, linux-kernel

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

On Wed, Apr 17, 2013 at 10:54:00PM +0800, Axel Lin wrote:
> The voltage_shift field of struct expand_register is not used now, remove it.

Applied both, thanks.

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

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

end of thread, other threads:[~2013-04-18 17:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-17 14:54 [PATCH 1/2] regulator: ab8500: Remove unused voltage_shift field from struct expand_register Axel Lin
2013-04-17 14:55 ` [PATCH 2/2] regulator: ab8500: Get rid of voltage_shift field from struct ab8500_regulator_info Axel Lin
2013-04-18  6:38   ` Bengt Jönsson
2013-04-18  6:36 ` [PATCH 1/2] regulator: ab8500: Remove unused voltage_shift field from struct expand_register Bengt Jönsson
2013-04-18 17:27 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).