aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max8952.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-03-14 20:47:48 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-01 06:59:25 -0400
commitc8237f01db63b458c34222d07f66c5417cfd866b (patch)
tree37862f1459b4ed044868b8857ee3c7d502c124aa /drivers/regulator/max8952.c
parent1f793ff258c7a48e8cc3729ac13bfd1b3850b9c9 (diff)
regulator: max8952: Simplify the logic to get vid[0|1] status
The syntax "(((vid >> 1) % 2) == 1)" is inefficient and also hard to read. Use bitwidse AND operator instead. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max8952.c')
-rw-r--r--drivers/regulator/max8952.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c
index 75d89400c123..e9c0a0ea1528 100644
--- a/drivers/regulator/max8952.c
+++ b/drivers/regulator/max8952.c
@@ -152,8 +152,8 @@ static int max8952_set_voltage(struct regulator_dev *rdev,
152 } 152 }
153 153
154 if (vid >= 0 && vid < MAX8952_NUM_DVS_MODE) { 154 if (vid >= 0 && vid < MAX8952_NUM_DVS_MODE) {
155 max8952->vid0 = (vid % 2 == 1); 155 max8952->vid0 = vid & 0x1;
156 max8952->vid1 = (((vid >> 1) % 2) == 1); 156 max8952->vid1 = (vid >> 1) & 0x1;
157 *selector = vid; 157 *selector = vid;
158 gpio_set_value(max8952->pdata->gpio_vid0, max8952->vid0); 158 gpio_set_value(max8952->pdata->gpio_vid0, max8952->vid0);
159 gpio_set_value(max8952->pdata->gpio_vid1, max8952->vid1); 159 gpio_set_value(max8952->pdata->gpio_vid1, max8952->vid1);
@@ -217,8 +217,8 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client,
217 } 217 }
218 218
219 max8952->en = !!(pdata->reg_data.constraints.boot_on); 219 max8952->en = !!(pdata->reg_data.constraints.boot_on);
220 max8952->vid0 = (pdata->default_mode % 2) == 1; 220 max8952->vid0 = pdata->default_mode & 0x1;
221 max8952->vid1 = ((pdata->default_mode >> 1) % 2) == 1; 221 max8952->vid1 = (pdata->default_mode >> 1) & 0x1;
222 222
223 if (gpio_is_valid(pdata->gpio_en)) { 223 if (gpio_is_valid(pdata->gpio_en)) {
224 if (!gpio_request(pdata->gpio_en, "MAX8952 EN")) 224 if (!gpio_request(pdata->gpio_en, "MAX8952 EN"))
@@ -241,13 +241,13 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client,
241 gpio_is_valid(pdata->gpio_vid1)) { 241 gpio_is_valid(pdata->gpio_vid1)) {
242 if (!gpio_request(pdata->gpio_vid0, "MAX8952 VID0")) 242 if (!gpio_request(pdata->gpio_vid0, "MAX8952 VID0"))
243 gpio_direction_output(pdata->gpio_vid0, 243 gpio_direction_output(pdata->gpio_vid0,
244 (pdata->default_mode) % 2); 244 (pdata->default_mode) & 0x1);
245 else 245 else
246 err = 1; 246 err = 1;
247 247
248 if (!gpio_request(pdata->gpio_vid1, "MAX8952 VID1")) 248 if (!gpio_request(pdata->gpio_vid1, "MAX8952 VID1"))
249 gpio_direction_output(pdata->gpio_vid1, 249 gpio_direction_output(pdata->gpio_vid1,
250 (pdata->default_mode >> 1) % 2); 250 (pdata->default_mode >> 1) & 0x1);
251 else { 251 else {
252 if (!err) 252 if (!err)
253 gpio_free(pdata->gpio_vid0); 253 gpio_free(pdata->gpio_vid0);