linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFT 1/2] regulator: anatop: Use linear_min_sel with linear mapping
@ 2012-12-09  0:05 Axel Lin
  2012-12-09  0:07 ` [PATCH RFT 2/2] regulator: anatop: Use regulator_[get|set]_voltage_sel_regmap Axel Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Axel Lin @ 2012-12-09  0:05 UTC (permalink / raw)
  To: Mark Brown
  Cc: Nancy Chen, Ying-Chun Liu (PaulLiu), Liam Girdwood, linux-kernel

By setting linear_min_sel to anatop_reg->min_bit_val, we can avoid
adjust the anatop_reg->min_bit_val offset in [set|get]_voltage_sel.

With this chance we can refactor this driver to use
regulator_[get|set]_voltage_sel_regmap.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/anatop-regulator.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index 1aa5246..645a42d 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -48,18 +48,16 @@ static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg,
 					unsigned selector)
 {
 	struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
-	u32 val, mask;
+	u32 mask;
 
 	if (!anatop_reg->control_reg)
 		return -ENOTSUPP;
 
-	val = anatop_reg->min_bit_val + selector;
-	dev_dbg(&reg->dev, "%s: calculated val %d\n", __func__, val);
 	mask = ((1 << anatop_reg->vol_bit_width) - 1) <<
 		anatop_reg->vol_bit_shift;
-	val <<= anatop_reg->vol_bit_shift;
+	selector <<= anatop_reg->vol_bit_shift;
 	regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg,
-				mask, val);
+				mask, selector);
 
 	return 0;
 }
@@ -77,7 +75,7 @@ static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg)
 		anatop_reg->vol_bit_shift;
 	val = (val & mask) >> anatop_reg->vol_bit_shift;
 
-	return val - anatop_reg->min_bit_val;
+	return val;
 }
 
 static struct regulator_ops anatop_rops = {
@@ -158,10 +156,11 @@ static int anatop_regulator_probe(struct platform_device *pdev)
 		goto anatop_probe_end;
 	}
 
-	rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage)
-		/ 25000 + 1;
+	rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1
+			    + sreg->min_bit_val;
 	rdesc->min_uV = sreg->min_voltage;
 	rdesc->uV_step = 25000;
+	rdesc->linear_min_sel = sreg->min_bit_val;
 
 	config.dev = &pdev->dev;
 	config.init_data = initdata;
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-12-10  3:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-09  0:05 [PATCH RFT 1/2] regulator: anatop: Use linear_min_sel with linear mapping Axel Lin
2012-12-09  0:07 ` [PATCH RFT 2/2] regulator: anatop: Use regulator_[get|set]_voltage_sel_regmap Axel Lin
2012-12-09  5:38   ` Ying-Chun Liu (PaulLiu)
2012-12-09  5:37 ` [PATCH RFT 1/2] regulator: anatop: Use linear_min_sel with linear mapping Ying-Chun Liu (PaulLiu)
2012-12-10  3: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).