* [PATCH] regulator: lp872x: Simplify implementation of lp872x_find_regulator_init_data()
@ 2012-07-15 8:57 Axel Lin
2012-07-16 0:02 ` Kim, Milo
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Axel Lin @ 2012-07-15 8:57 UTC (permalink / raw)
To: Mark Brown; +Cc: Milo(Woogyom) Kim, Liam Girdwood, linux-kernel
Pass regulator id rahter than the index to lp872x_find_regulator_init_data(),
then the code can be simpler.
We can also get max_regulators by lp->num_regulators.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/lp872x.c | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index 471f8e8..212c38e 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -796,30 +796,16 @@ static int lp872x_config(struct lp872x *lp)
}
static struct regulator_init_data
-*lp872x_find_regulator_init_data(int idx, struct lp872x *lp)
+*lp872x_find_regulator_init_data(int id, struct lp872x *lp)
{
- int i, base, id, max_regulators;
-
- switch (lp->chipid) {
- case LP8720:
- base = LP8720_ID_BASE;
- max_regulators = LP8720_NUM_REGULATORS;
- break;
- case LP8725:
- base = LP8725_ID_BASE;
- max_regulators = LP8725_NUM_REGULATORS;
- break;
- default:
- return NULL;
- }
+ int i;
- id = base + idx;
- for (i = 0 ; i < max_regulators ; i++)
+ for (i = 0; i < lp->num_regulators; i++) {
if (lp->pdata->regulator_data[i].id == id)
- break;
+ return lp->pdata->regulator_data[i].init_data;
+ }
- return (i == max_regulators) ? NULL :
- lp->pdata->regulator_data[i].init_data;
+ return NULL;
}
static int lp872x_regulator_register(struct lp872x *lp)
@@ -834,7 +820,7 @@ static int lp872x_regulator_register(struct lp872x *lp)
&lp8725_regulator_desc[i];
cfg.dev = lp->dev;
- cfg.init_data = lp872x_find_regulator_init_data(i, lp);
+ cfg.init_data = lp872x_find_regulator_init_data(desc->id, lp);
cfg.driver_data = lp;
cfg.regmap = lp->regmap;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] regulator: lp872x: Simplify implementation of lp872x_find_regulator_init_data()
2012-07-15 8:57 [PATCH] regulator: lp872x: Simplify implementation of lp872x_find_regulator_init_data() Axel Lin
@ 2012-07-16 0:02 ` Kim, Milo
2012-07-16 0:17 ` Kim, Milo
2012-07-16 19:59 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Kim, Milo @ 2012-07-16 0:02 UTC (permalink / raw)
To: Axel Lin; +Cc: Mark Brown, Girdwood, Liam, linux-kernel@vger.kernel.org
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 523 bytes --]
> Pass regulator id rahter than the index to
> lp872x_find_regulator_init_data(),
> then the code can be simpler.
> We can also get max_regulators by lp->num_regulators.
It looks good to me and tested successfully in the target board.
Thanks !
Acked-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Tested-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Best Regards,
Milo
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] regulator: lp872x: Simplify implementation of lp872x_find_regulator_init_data()
2012-07-15 8:57 [PATCH] regulator: lp872x: Simplify implementation of lp872x_find_regulator_init_data() Axel Lin
2012-07-16 0:02 ` Kim, Milo
@ 2012-07-16 0:17 ` Kim, Milo
2012-07-16 19:59 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Kim, Milo @ 2012-07-16 0:17 UTC (permalink / raw)
To: Axel Lin; +Cc: Mark Brown, Girdwood, Liam, linux-kernel@vger.kernel.org
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 519 bytes --]
> Pass regulator id rahter than the index to
> lp872x_find_regulator_init_data(),
> then the code can be simpler.
> We can also get max_regulators by lp->num_regulators.
It looks good to me and tested successfully in the target board.
Thanks !
Acked-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Tested-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Best Regards,
Milo
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] regulator: lp872x: Simplify implementation of lp872x_find_regulator_init_data()
2012-07-15 8:57 [PATCH] regulator: lp872x: Simplify implementation of lp872x_find_regulator_init_data() Axel Lin
2012-07-16 0:02 ` Kim, Milo
2012-07-16 0:17 ` Kim, Milo
@ 2012-07-16 19:59 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-07-16 19:59 UTC (permalink / raw)
To: Axel Lin; +Cc: Milo(Woogyom) Kim, Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 244 bytes --]
On Sun, Jul 15, 2012 at 04:57:12PM +0800, Axel Lin wrote:
> Pass regulator id rahter than the index to lp872x_find_regulator_init_data(),
> then the code can be simpler.
> We can also get max_regulators by lp->num_regulators.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-16 19:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-15 8:57 [PATCH] regulator: lp872x: Simplify implementation of lp872x_find_regulator_init_data() Axel Lin
2012-07-16 0:02 ` Kim, Milo
2012-07-16 0:17 ` Kim, Milo
2012-07-16 19:59 ` Mark Brown
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).