All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Laxman Dewangan <ldewangan@nvidia.com>,
	Liam Girdwood <lrg@ti.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH RFT 3/3] regulator: rc5t583: Use regulator_get_voltage_sel_regmap()
Date: Tue, 24 Apr 2012 09:56:43 +0800	[thread overview]
Message-ID: <1335232603.6470.5.camel@phoenix> (raw)
In-Reply-To: <1335232352.6470.1.camel@phoenix>

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/rc5t583-regulator.c |   33 +++++++++------------------------
 1 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c
index f35dc527..7951260 100644
--- a/drivers/regulator/rc5t583-regulator.c
+++ b/drivers/regulator/rc5t583-regulator.c
@@ -38,8 +38,6 @@ struct rc5t583_regulator_info {
 	/* Regulator register address.*/
 	uint8_t			reg_disc_reg;
 	uint8_t			disc_bit;
-	uint8_t			vout_reg;
-	uint8_t			vout_mask;
 	uint8_t			deepsleep_reg;
 
 	/* Chip constraints on regulator behavior */
@@ -90,33 +88,20 @@ static int rc5t583_set_voltage(struct regulator_dev *rdev,
 
 	*selector = sel;
 
-	ret = rc5t583_update(reg->mfd->dev, ri->vout_reg, sel, ri->vout_mask);
+	ret = rc5t583_update(reg->mfd->dev, rdev->desc->vsel_reg, sel,
+			     rdev->desc->vsel_mask);
 	if (ret < 0)
-		dev_err(&rdev->dev,
-		    "Error in update voltage register 0x%02x\n", ri->vout_reg);
+		dev_err(&rdev->dev, "Error in update voltage register 0x%02x\n",
+			rdev->desc->vsel_reg);
 	return ret;
 }
 
-static int rc5t583_get_voltage_sel(struct regulator_dev *rdev)
-{
-	struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
-	struct rc5t583_regulator_info *ri = reg->reg_info;
-	uint8_t vsel;
-	int ret;
-	ret = rc5t583_read(reg->mfd->dev, ri->vout_reg, &vsel);
-	if (ret < 0) {
-		dev_err(&rdev->dev,
-		    "Error in reading voltage register 0x%02x\n", ri->vout_reg);
-		return ret;
-	}
-	return vsel & ri->vout_mask;
-}
-
 static int rc5t583_regulator_enable_time(struct regulator_dev *rdev)
 {
 	struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
-	int vsel = rc5t583_get_voltage_sel(rdev);
+	int vsel = regulator_get_voltage_sel_regmap(rdev);
 	int curr_uV = rc5t583_list_voltage(rdev, vsel);
+
 	return DIV_ROUND_UP(curr_uV, reg->reg_info->enable_uv_per_us);
 }
 
@@ -144,7 +129,7 @@ static struct regulator_ops rc5t583_ops = {
 	.enable			= regulator_enable_regmap,
 	.disable		= regulator_disable_regmap,
 	.enable_time		= rc5t583_regulator_enable_time,
-	.get_voltage_sel	= rc5t583_get_voltage_sel,
+	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
 	.set_voltage		= rc5t583_set_voltage,
 	.list_voltage		= rc5t583_list_voltage,
 	.set_voltage_time_sel	= rc5t583_set_voltage_time_sel,
@@ -155,8 +140,6 @@ static struct regulator_ops rc5t583_ops = {
 {								\
 	.reg_disc_reg	= RC5T583_REG_##_disc_reg,		\
 	.disc_bit	= _disc_bit,				\
-	.vout_reg	= RC5T583_REG_##_id##DAC,		\
-	.vout_mask	= _vout_mask,				\
 	.deepsleep_reg	= RC5T583_REG_##_id##DAC_DS,		\
 	.min_uV		= _min_mv * 1000,			\
 	.max_uV		= _max_mv * 1000,			\
@@ -171,6 +154,8 @@ static struct regulator_ops rc5t583_ops = {
 		.ops = &rc5t583_ops,				\
 		.type = REGULATOR_VOLTAGE,			\
 		.owner = THIS_MODULE,				\
+		.vsel_reg = RC5T583_REG_##_id##DAC,		\
+		.vsel_mask = _vout_mask,			\
 		.enable_reg = RC5T583_REG_##_en_reg,		\
 		.enable_mask = BIT(_en_bit),			\
 	},							\
-- 
1.7.5.4




  parent reply	other threads:[~2012-04-24  1:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-24  1:52 [PATCH RFT 1/3] regulator: 88pm8607: Use regulator_get_voltage_sel_regmap() Axel Lin
2012-04-24  1:54 ` [PATCH RFT 2/3] regulator: da9052: " Axel Lin
2012-05-04 12:30   ` Mark Brown
2012-04-24  1:56 ` Axel Lin [this message]
2012-05-04 12:32   ` [PATCH RFT 3/3] regulator: rc5t583: " Mark Brown
2012-05-04 12:38 ` [PATCH RFT 1/3] regulator: 88pm8607: " 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=1335232603.6470.5.camel@phoenix \
    --to=axel.lin@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.