All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC/RFT] regulator: ab8500: Remove is_enabled from struct ab8500_regulator_info
@ 2013-03-26  6:50 Axel Lin
  2013-03-26  7:43 ` Bengt Jönsson
  0 siblings, 1 reply; 3+ messages in thread
From: Axel Lin @ 2013-03-26  6:50 UTC (permalink / raw)
  To: Mark Brown
  Cc: Bengt Jonsson, Lee Jones, Yvan FILLION, Mattias WALLIN,
	Liam Girdwood, linux-kernel

The is_enabled flag looks not necessary at all, it also introduces some issues
because current code updates info->is_enabled flag in error paths of
ab8500_regulator_enable() and ab8500_regulator_disable().
Thus this patch removes is_enabled from struct ab8500_regulator_info.

This patch also removes info->is_enabled checking in ab8500_regulator_set_mode(),
so it allows setting mode even the regulator is disabled.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
Hi,
This patch also removes info->is_enabled checking in ab8500_regulator_set_mode().
I'm not very clear if we should avoid setting mode when the regulator is disabled.
It looks to me if we don't want to allow setting mode when regulator is disabled,
this checking should be done in regulator-core.
Seems current code in other regulator drivers does not check if regulator is
enabled or not in set_mode callback implementation.
Axel
 drivers/regulator/ab8500.c |   36 ++++++++++--------------------------
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 12e2740..8a84b6d 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -30,7 +30,6 @@
  * @dev: device pointer
  * @desc: regulator description
  * @regulator_dev: regulator device
- * @is_enabled: status of regulator (on/off)
  * @load_lp_uA: maximum load in idle (low power) mode
  * @update_bank: bank to control on/off
  * @update_reg: register to control on/off
@@ -48,7 +47,6 @@ struct ab8500_regulator_info {
 	struct device		*dev;
 	struct regulator_desc	desc;
 	struct regulator_dev	*regulator;
-	bool is_enabled;
 	int load_lp_uA;
 	u8 update_bank;
 	u8 update_reg;
@@ -121,8 +119,6 @@ static int ab8500_regulator_enable(struct regulator_dev *rdev)
 		dev_err(rdev_get_dev(rdev),
 			"couldn't set enable bits for regulator\n");
 
-	info->is_enabled = true;
-
 	dev_vdbg(rdev_get_dev(rdev),
 		"%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
 		info->desc.name, info->update_bank, info->update_reg,
@@ -148,8 +144,6 @@ static int ab8500_regulator_disable(struct regulator_dev *rdev)
 		dev_err(rdev_get_dev(rdev),
 			"couldn't set disable bits for regulator\n");
 
-	info->is_enabled = false;
-
 	dev_vdbg(rdev_get_dev(rdev),
 		"%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
 		info->desc.name, info->update_bank, info->update_reg,
@@ -202,20 +196,15 @@ static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
 		return -EINVAL;
 	}
 
-	if (info->is_enabled) {
-		ret = abx500_mask_and_set_register_interruptible(info->dev,
-			info->update_bank, info->update_reg,
-			info->update_mask, info->update_val);
-		if (ret < 0)
-			dev_err(rdev_get_dev(rdev),
-				"couldn't set regulator mode\n");
-
-		dev_vdbg(rdev_get_dev(rdev),
-			"%s-set_mode (bank, reg, mask, value): "
-			"0x%x, 0x%x, 0x%x, 0x%x\n",
-			info->desc.name, info->update_bank, info->update_reg,
-			info->update_mask, info->update_val);
-	}
+	ret = abx500_mask_and_set_register_interruptible(info->dev,
+		info->update_bank, info->update_reg,
+		info->update_mask, info->update_val);
+	if (ret < 0)
+		dev_err(rdev_get_dev(rdev), "couldn't set regulator mode\n");
+
+	dev_vdbg(rdev_get_dev(rdev), "%s-set_mode (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
+		info->desc.name, info->update_bank, info->update_reg,
+		info->update_mask, info->update_val);
 
 	return ret;
 }
@@ -265,12 +254,7 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
 		info->desc.name, info->update_bank, info->update_reg,
 		info->update_mask, regval);
 
-	if (regval & info->update_mask)
-		info->is_enabled = true;
-	else
-		info->is_enabled = false;
-
-	return info->is_enabled;
+	return regval & info->update_mask;
 }
 
 static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
-- 
1.7.10.4




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

* Re: [PATCH RFC/RFT] regulator: ab8500: Remove is_enabled from struct ab8500_regulator_info
  2013-03-26  6:50 [PATCH RFC/RFT] regulator: ab8500: Remove is_enabled from struct ab8500_regulator_info Axel Lin
@ 2013-03-26  7:43 ` Bengt Jönsson
  2013-03-26  7:50   ` Axel Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Bengt Jönsson @ 2013-03-26  7:43 UTC (permalink / raw)
  To: Axel Lin
  Cc: Mark Brown, Lee Jones, Yvan FILLION, Mattias WALLIN,
	Liam Girdwood, linux-kernel@vger.kernel.org

On 03/26/2013 07:50 AM, Axel Lin wrote:
> The is_enabled flag looks not necessary at all, it also introduces some issues
> because current code updates info->is_enabled flag in error paths of
> ab8500_regulator_enable() and ab8500_regulator_disable().
> Thus this patch removes is_enabled from struct ab8500_regulator_info.
>
> This patch also removes info->is_enabled checking in ab8500_regulator_set_mode(),
> so it allows setting mode even the regulator is disabled.
This patch will change the behaviour of set_mode as the ab8500 
regulators share mode and enable in the same register bits:
- off = 0b00
- low power mode= 0b11
- full powermode = 0b01
- (HW control mode = 0b10)

To keep regulator_enable/disable apart from regulator_set_mode I think 
this patch should not go in.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> Hi,
> This patch also removes info->is_enabled checking in ab8500_regulator_set_mode().
> I'm not very clear if we should avoid setting mode when the regulator is disabled.
> It looks to me if we don't want to allow setting mode when regulator is disabled,
> this checking should be done in regulator-core.
Checking in regulator-core seems like a good idea to me.It would make 
the ab8500 code more clean, but I don't know how other drivers will be 
affected.
> Seems current code in other regulator drivers does not check if regulator is
> enabled or not in set_mode callback implementation.
> Axel
I know some other hardware has separate register bits for mode and 
enable which matches the framework better.

Bengt

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

* Re: [PATCH RFC/RFT] regulator: ab8500: Remove is_enabled from struct ab8500_regulator_info
  2013-03-26  7:43 ` Bengt Jönsson
@ 2013-03-26  7:50   ` Axel Lin
  0 siblings, 0 replies; 3+ messages in thread
From: Axel Lin @ 2013-03-26  7:50 UTC (permalink / raw)
  To: Bengt Jönsson
  Cc: Mark Brown, Lee Jones, Yvan FILLION, Mattias WALLIN,
	Liam Girdwood, linux-kernel@vger.kernel.org

2013/3/26 Bengt Jönsson <bengt.g.jonsson@stericsson.com>:
> On 03/26/2013 07:50 AM, Axel Lin wrote:
>>
>> The is_enabled flag looks not necessary at all, it also introduces some
>> issues
>> because current code updates info->is_enabled flag in error paths of
>> ab8500_regulator_enable() and ab8500_regulator_disable().
>> Thus this patch removes is_enabled from struct ab8500_regulator_info.
>>
>> This patch also removes info->is_enabled checking in
>> ab8500_regulator_set_mode(),
>> so it allows setting mode even the regulator is disabled.
>
> This patch will change the behaviour of set_mode as the ab8500 regulators
> share mode and enable in the same register bits:
> - off = 0b00
> - low power mode= 0b11
> - full powermode = 0b01
> - (HW control mode = 0b10)
>
> To keep regulator_enable/disable apart from regulator_set_mode I think this
> patch should not go in.

Thanks for the review.
I'll send a patch to avoid update is_enabled flag in error paths.

Axel

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

end of thread, other threads:[~2013-03-26  7:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-26  6:50 [PATCH RFC/RFT] regulator: ab8500: Remove is_enabled from struct ab8500_regulator_info Axel Lin
2013-03-26  7:43 ` Bengt Jönsson
2013-03-26  7:50   ` Axel Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.