* [PATCH] regulator: max8952: Simplify the logic to get vid[0|1] status
@ 2012-03-15 0:47 Axel Lin
2012-03-21 8:54 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-03-15 0:47 UTC (permalink / raw)
To: linux-kernel; +Cc: Liam Girdwood, Mark Brown, MyungJoo Ham, Kyungmin Park
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>
---
drivers/regulator/max8952.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c
index 75d8940..e9c0a0e 100644
--- a/drivers/regulator/max8952.c
+++ b/drivers/regulator/max8952.c
@@ -152,8 +152,8 @@ static int max8952_set_voltage(struct regulator_dev *rdev,
}
if (vid >= 0 && vid < MAX8952_NUM_DVS_MODE) {
- max8952->vid0 = (vid % 2 == 1);
- max8952->vid1 = (((vid >> 1) % 2) == 1);
+ max8952->vid0 = vid & 0x1;
+ max8952->vid1 = (vid >> 1) & 0x1;
*selector = vid;
gpio_set_value(max8952->pdata->gpio_vid0, max8952->vid0);
gpio_set_value(max8952->pdata->gpio_vid1, max8952->vid1);
@@ -217,8 +217,8 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client,
}
max8952->en = !!(pdata->reg_data.constraints.boot_on);
- max8952->vid0 = (pdata->default_mode % 2) == 1;
- max8952->vid1 = ((pdata->default_mode >> 1) % 2) == 1;
+ max8952->vid0 = pdata->default_mode & 0x1;
+ max8952->vid1 = (pdata->default_mode >> 1) & 0x1;
if (gpio_is_valid(pdata->gpio_en)) {
if (!gpio_request(pdata->gpio_en, "MAX8952 EN"))
@@ -241,13 +241,13 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client,
gpio_is_valid(pdata->gpio_vid1)) {
if (!gpio_request(pdata->gpio_vid0, "MAX8952 VID0"))
gpio_direction_output(pdata->gpio_vid0,
- (pdata->default_mode) % 2);
+ (pdata->default_mode) & 0x1);
else
err = 1;
if (!gpio_request(pdata->gpio_vid1, "MAX8952 VID1"))
gpio_direction_output(pdata->gpio_vid1,
- (pdata->default_mode >> 1) % 2);
+ (pdata->default_mode >> 1) & 0x1);
else {
if (!err)
gpio_free(pdata->gpio_vid0);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: max8952: Simplify the logic to get vid[0|1] status
2012-03-15 0:47 [PATCH] regulator: max8952: Simplify the logic to get vid[0|1] status Axel Lin
@ 2012-03-21 8:54 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-03-21 8:54 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, MyungJoo Ham, Kyungmin Park
[-- Attachment #1: Type: text/plain, Size: 190 bytes --]
On Thu, Mar 15, 2012 at 08:47:48AM +0800, Axel Lin wrote:
> The syntax "(((vid >> 1) % 2) == 1)" is inefficient and also hard to read.
> Use bitwidse AND operator instead.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-21 8:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-15 0:47 [PATCH] regulator: max8952: Simplify the logic to get vid[0|1] status Axel Lin
2012-03-21 8:54 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox