* [PATCH] regulator: s5m8767: Remove max_vol parameter from s5m8767_convert_voltage_to_sel
@ 2012-12-29 1:38 Axel Lin
2013-01-08 11:12 ` Mark Brown
2013-01-17 7:12 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-12-29 1:38 UTC (permalink / raw)
To: Mark Brown
Cc: Sangbeom Kim, Inderpal Singh, Amit Daniel Kachhap, Liam Girdwood,
linux-kernel
It looks pointless to pass max_vol to s5m8767_convert_voltage_to_sel().
Compare selected voltage to desc->max is enough to ensure selected voltage
is in supported range.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/s5m8767.c | 33 ++++++++++-----------------------
1 file changed, 10 insertions(+), 23 deletions(-)
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index eeadf58..aa0ccef 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -297,16 +297,15 @@ static int s5m8767_get_vsel_reg(int reg_id, struct s5m8767_info *s5m8767)
return reg;
}
-static int s5m8767_convert_voltage_to_sel(
- const struct sec_voltage_desc *desc,
- int min_vol, int max_vol)
+static int s5m8767_convert_voltage_to_sel(const struct sec_voltage_desc *desc,
+ int min_vol)
{
int selector = 0;
if (desc == NULL)
return -EINVAL;
- if (max_vol < desc->min || min_vol > desc->max)
+ if (min_vol > desc->max)
return -EINVAL;
if (min_vol < desc->min)
@@ -314,7 +313,7 @@ static int s5m8767_convert_voltage_to_sel(
selector = DIV_ROUND_UP(min_vol - desc->min, desc->step);
- if (desc->min + desc->step * selector > max_vol)
+ if (desc->min + desc->step * selector > desc->max)
return -EINVAL;
return selector;
@@ -544,23 +543,17 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
s5m8767->opmode = pdata->opmode;
buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
- pdata->buck2_init,
- pdata->buck2_init +
- buck_voltage_val2.step);
+ pdata->buck2_init);
sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS2, buck_init);
buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
- pdata->buck3_init,
- pdata->buck3_init +
- buck_voltage_val2.step);
+ pdata->buck3_init);
sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS2, buck_init);
buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
- pdata->buck4_init,
- pdata->buck4_init +
- buck_voltage_val2.step);
+ pdata->buck4_init);
sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS2, buck_init);
@@ -569,27 +562,21 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
s5m8767->buck2_vol[i] =
s5m8767_convert_voltage_to_sel(
&buck_voltage_val2,
- pdata->buck2_voltage[i],
- pdata->buck2_voltage[i] +
- buck_voltage_val2.step);
+ pdata->buck2_voltage[i]);
}
if (s5m8767->buck3_gpiodvs) {
s5m8767->buck3_vol[i] =
s5m8767_convert_voltage_to_sel(
&buck_voltage_val2,
- pdata->buck3_voltage[i],
- pdata->buck3_voltage[i] +
- buck_voltage_val2.step);
+ pdata->buck3_voltage[i]);
}
if (s5m8767->buck4_gpiodvs) {
s5m8767->buck4_vol[i] =
s5m8767_convert_voltage_to_sel(
&buck_voltage_val2,
- pdata->buck4_voltage[i],
- pdata->buck4_voltage[i] +
- buck_voltage_val2.step);
+ pdata->buck4_voltage[i]);
}
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: s5m8767: Remove max_vol parameter from s5m8767_convert_voltage_to_sel
2012-12-29 1:38 [PATCH] regulator: s5m8767: Remove max_vol parameter from s5m8767_convert_voltage_to_sel Axel Lin
@ 2013-01-08 11:12 ` Mark Brown
2013-01-17 7:12 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2013-01-08 11:12 UTC (permalink / raw)
To: Axel Lin
Cc: Sangbeom Kim, Inderpal Singh, Amit Daniel Kachhap, Liam Girdwood,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 295 bytes --]
On Sat, Dec 29, 2012 at 09:38:50AM +0800, Axel Lin wrote:
> It looks pointless to pass max_vol to s5m8767_convert_voltage_to_sel().
> Compare selected voltage to desc->max is enough to ensure selected voltage
> is in supported range.
This doesn't apply against -rc2, can you please regenerate?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: s5m8767: Remove max_vol parameter from s5m8767_convert_voltage_to_sel
2012-12-29 1:38 [PATCH] regulator: s5m8767: Remove max_vol parameter from s5m8767_convert_voltage_to_sel Axel Lin
2013-01-08 11:12 ` Mark Brown
@ 2013-01-17 7:12 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2013-01-17 7:12 UTC (permalink / raw)
To: Axel Lin
Cc: Sangbeom Kim, Inderpal Singh, Amit Daniel Kachhap, Liam Girdwood,
linux-kernel
On Sat, Dec 29, 2012 at 09:38:50AM +0800, Axel Lin wrote:
> It looks pointless to pass max_vol to s5m8767_convert_voltage_to_sel().
> Compare selected voltage to desc->max is enough to ensure selected voltage
> is in supported range.
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-01-17 7:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-29 1:38 [PATCH] regulator: s5m8767: Remove max_vol parameter from s5m8767_convert_voltage_to_sel Axel Lin
2013-01-08 11:12 ` Mark Brown
2013-01-17 7:12 ` 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).