From: Axel Lin <axel.lin@ingics.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Bengt Jonsson <bengt.g.jonsson@stericsson.com>,
Lee Jones <lee.jones@linaro.org>,
Yvan FILLION <yvan.fillion@stericsson.com>,
Liam Girdwood <lgirdwood@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] regulator: ab8500-ext: Get rid of is_enabled from struct ab8500_ext_regulator_info
Date: Sun, 07 Apr 2013 23:13:39 +0800 [thread overview]
Message-ID: <1365347619.9931.3.camel@phoenix> (raw)
In-Reply-To: <1365347548.9931.1.camel@phoenix>
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>
---
drivers/regulator/ab8500-ext.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c
index 57d43a1..5e604a2 100644
--- a/drivers/regulator/ab8500-ext.c
+++ b/drivers/regulator/ab8500-ext.c
@@ -29,7 +29,6 @@
* @desc: regulator description
* @rdev: regulator device
* @cfg: regulator configuration (extension of regulator FW configuration)
- * @is_enabled: status of regulator (on/off)
* @update_bank: bank to control on/off
* @update_reg: register to control on/off
* @update_mask: mask to enable/disable and set mode of regulator
@@ -46,7 +45,6 @@ struct ab8500_ext_regulator_info {
struct regulator_desc desc;
struct regulator_dev *rdev;
struct ab8500_ext_regulator_cfg *cfg;
- bool is_enabled;
u8 update_bank;
u8 update_reg;
u8 update_mask;
@@ -78,8 +76,6 @@ static int enable(struct ab8500_ext_regulator_info *info, u8 *regval)
return ret;
}
- info->is_enabled = true;
-
return ret;
}
@@ -125,8 +121,6 @@ static int disable(struct ab8500_ext_regulator_info *info, u8 *regval)
return ret;
}
- info->is_enabled = false;
-
return ret;
}
@@ -177,11 +171,9 @@ static int ab8500_ext_regulator_is_enabled(struct regulator_dev *rdev)
if (((regval & info->update_mask) == info->update_val_lp) ||
((regval & info->update_mask) == info->update_val_hp))
- info->is_enabled = true;
+ return 1;
else
- info->is_enabled = false;
-
- return info->is_enabled;
+ return 0;
}
static 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,
return -EINVAL;
}
- if (info->is_enabled) {
+ if (ab8500_ext_regulator_is_enabled(rdev)) {
u8 regval;
ret = enable(info, ®val);
--
1.7.10.4
next prev parent reply other threads:[~2013-04-07 15:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-07 15:12 [PATCH 1/4] regulator: ab8500: Get rid of is_enabled from struct ab8500_regulator_info Axel Lin
2013-04-07 15:13 ` Axel Lin [this message]
2013-04-08 7:54 ` [PATCH 2/4] regulator: ab8500-ext: Get rid of is_enabled from struct ab8500_ext_regulator_info Lee Jones
2013-04-07 15:15 ` [PATCH 3/4] regulator: ab8500-ext: Remove unnecessary checking for ab9540 and ab8540 Axel Lin
2013-04-07 15:17 ` [PATCH 4/4] regulator: ab8500-ext: Remove get_voltage to avoid duplicate implementation Axel Lin
2013-04-08 7:53 ` Lee Jones
2013-04-08 7:52 ` [PATCH 1/4] regulator: ab8500: Get rid of is_enabled from struct ab8500_regulator_info Lee Jones
2013-04-08 10:24 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1365347619.9931.3.camel@phoenix \
--to=axel.lin@ingics.com \
--cc=bengt.g.jonsson@stericsson.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=yvan.fillion@stericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).