aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-04-07 11:13:39 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-08 06:23:45 -0400
commit9ab51a0eb46a1cd894b1bc784e7775f7c29918c0 (patch)
tree84d1736c99fd816e8abb0056253d3cd96bb8f9ff
parent438e695b87e03953fc4ba1aff59feab33c9c79a7 (diff)
regulator: ab8500-ext: Get rid of is_enabled from struct ab8500_ext_regulator_info
The intention of this patch is to simplify the code. Maintain the is_enabled flag is not trivial, it not only needs to set/clear the flag in disable()/enable() but also needs to set the flag in is_enable() to get initial status. The only benefit of keeping is_enabled flag is just save a register read when set_mode(). Remove is_enabled flag makes the code simpler. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--drivers/regulator/ab8500-ext.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c
index 57d43a10e6b0..5e604a2ad7cd 100644
--- a/drivers/regulator/ab8500-ext.c
+++ b/drivers/regulator/ab8500-ext.c
@@ -29,7 +29,6 @@
29 * @desc: regulator description 29 * @desc: regulator description
30 * @rdev: regulator device 30 * @rdev: regulator device
31 * @cfg: regulator configuration (extension of regulator FW configuration) 31 * @cfg: regulator configuration (extension of regulator FW configuration)
32 * @is_enabled: status of regulator (on/off)
33 * @update_bank: bank to control on/off 32 * @update_bank: bank to control on/off
34 * @update_reg: register to control on/off 33 * @update_reg: register to control on/off
35 * @update_mask: mask to enable/disable and set mode of regulator 34 * @update_mask: mask to enable/disable and set mode of regulator
@@ -46,7 +45,6 @@ struct ab8500_ext_regulator_info {
46 struct regulator_desc desc; 45 struct regulator_desc desc;
47 struct regulator_dev *rdev; 46 struct regulator_dev *rdev;
48 struct ab8500_ext_regulator_cfg *cfg; 47 struct ab8500_ext_regulator_cfg *cfg;
49 bool is_enabled;
50 u8 update_bank; 48 u8 update_bank;
51 u8 update_reg; 49 u8 update_reg;
52 u8 update_mask; 50 u8 update_mask;
@@ -78,8 +76,6 @@ static int enable(struct ab8500_ext_regulator_info *info, u8 *regval)
78 return ret; 76 return ret;
79 } 77 }
80 78
81 info->is_enabled = true;
82
83 return ret; 79 return ret;
84} 80}
85 81
@@ -125,8 +121,6 @@ static int disable(struct ab8500_ext_regulator_info *info, u8 *regval)
125 return ret; 121 return ret;
126 } 122 }
127 123
128 info->is_enabled = false;
129
130 return ret; 124 return ret;
131} 125}
132 126
@@ -177,11 +171,9 @@ static int ab8500_ext_regulator_is_enabled(struct regulator_dev *rdev)
177 171
178 if (((regval & info->update_mask) == info->update_val_lp) || 172 if (((regval & info->update_mask) == info->update_val_lp) ||
179 ((regval & info->update_mask) == info->update_val_hp)) 173 ((regval & info->update_mask) == info->update_val_hp))
180 info->is_enabled = true; 174 return 1;
181 else 175 else
182 info->is_enabled = false; 176 return 0;
183
184 return info->is_enabled;
185} 177}
186 178
187static int ab8500_ext_regulator_set_mode(struct regulator_dev *rdev, 179static int ab8500_ext_regulator_set_mode(struct regulator_dev *rdev,
@@ -207,7 +199,7 @@ static int ab8500_ext_regulator_set_mode(struct regulator_dev *rdev,
207 return -EINVAL; 199 return -EINVAL;
208 } 200 }
209 201
210 if (info->is_enabled) { 202 if (ab8500_ext_regulator_is_enabled(rdev)) {
211 u8 regval; 203 u8 regval;
212 204
213 ret = enable(info, &regval); 205 ret = enable(info, &regval);