Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1241107 > unrolled thread

[PATCH RFT] regulator: tps6105x: Convert to use regmap helper functions

Started byAxel Lin <axel.lin@ingics.com>
First post2015-10-07 02:50 +0200
Last post2015-10-07 16:40 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH RFT] regulator: tps6105x: Convert to use regmap helper  functions Axel Lin <axel.lin@ingics.com> - 2015-10-07 02:50 +0200
    Re: [PATCH RFT] regulator: tps6105x: Convert to use regmap helper  functions Grigoryev Denis <grigoryev@fastwel.ru> - 2015-10-07 15:00 +0200
    Re: [PATCH RFT] regulator: tps6105x: Convert to use regmap helper  functions Mark Brown <broonie@kernel.org> - 2015-10-07 16:40 +0200

#1241107 — [PATCH RFT] regulator: tps6105x: Convert to use regmap helper functions

FromAxel Lin <axel.lin@ingics.com>
Date2015-10-07 02:50 +0200
Subject[PATCH RFT] regulator: tps6105x: Convert to use regmap helper functions
Message-ID<qgL5D-5Lb-11@gated-at.bofh.it>
Since commit 7e5071199355 ("mfd: tps6105x: Use i2c regmap to access
registers"), we can use regmap helper functions instead of open coded.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
Hi Grigoryev,
I don't have this h/w, can you help test this patch? Thanks.

This patch depends on commit 7e5071199355
"mfd: tps6105x: Use i2c regmap to access registers" which is currently
in mfd tree.

 drivers/regulator/tps6105x-regulator.c | 95 +++++-----------------------------
 1 file changed, 12 insertions(+), 83 deletions(-)

diff --git a/drivers/regulator/tps6105x-regulator.c b/drivers/regulator/tps6105x-regulator.c
index ddc4f10..584ef3d 100644
--- a/drivers/regulator/tps6105x-regulator.c
+++ b/drivers/regulator/tps6105x-regulator.c
@@ -27,90 +27,12 @@ static const unsigned int tps6105x_voltages[] = {
 	5000000, /* There is an additional 5V */
 };
 
-static int tps6105x_regulator_enable(struct regulator_dev *rdev)
-{
-	struct tps6105x *tps6105x = rdev_get_drvdata(rdev);
-	int ret;
-
-	/* Activate voltage mode */
-	ret = regmap_update_bits(tps6105x->regmap, TPS6105X_REG_0,
-		TPS6105X_REG0_MODE_MASK,
-		TPS6105X_REG0_MODE_VOLTAGE << TPS6105X_REG0_MODE_SHIFT);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
-static int tps6105x_regulator_disable(struct regulator_dev *rdev)
-{
-	struct tps6105x *tps6105x = rdev_get_drvdata(rdev);
-	int ret;
-
-	/* Set into shutdown mode */
-	ret = regmap_update_bits(tps6105x->regmap, TPS6105X_REG_0,
-		TPS6105X_REG0_MODE_MASK,
-		TPS6105X_REG0_MODE_SHUTDOWN << TPS6105X_REG0_MODE_SHIFT);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
-static int tps6105x_regulator_is_enabled(struct regulator_dev *rdev)
-{
-	struct tps6105x *tps6105x = rdev_get_drvdata(rdev);
-	unsigned int regval;
-	int ret;
-
-	ret = regmap_read(tps6105x->regmap, TPS6105X_REG_0, &regval);
-	if (ret)
-		return ret;
-	regval &= TPS6105X_REG0_MODE_MASK;
-	regval >>= TPS6105X_REG0_MODE_SHIFT;
-
-	if (regval == TPS6105X_REG0_MODE_VOLTAGE)
-		return 1;
-
-	return 0;
-}
-
-static int tps6105x_regulator_get_voltage_sel(struct regulator_dev *rdev)
-{
-	struct tps6105x *tps6105x = rdev_get_drvdata(rdev);
-	unsigned int regval;
-	int ret;
-
-	ret = regmap_read(tps6105x->regmap, TPS6105X_REG_0, &regval);
-	if (ret)
-		return ret;
-
-	regval &= TPS6105X_REG0_VOLTAGE_MASK;
-	regval >>= TPS6105X_REG0_VOLTAGE_SHIFT;
-	return (int) regval;
-}
-
-static int tps6105x_regulator_set_voltage_sel(struct regulator_dev *rdev,
-					      unsigned selector)
-{
-	struct tps6105x *tps6105x = rdev_get_drvdata(rdev);
-	int ret;
-
-	ret = regmap_update_bits(tps6105x->regmap, TPS6105X_REG_0,
-				    TPS6105X_REG0_VOLTAGE_MASK,
-				    selector << TPS6105X_REG0_VOLTAGE_SHIFT);
-	if (ret)
-		return ret;
-
-	return 0;
-}
-
 static struct regulator_ops tps6105x_regulator_ops = {
-	.enable		= tps6105x_regulator_enable,
-	.disable	= tps6105x_regulator_disable,
-	.is_enabled	= tps6105x_regulator_is_enabled,
-	.get_voltage_sel = tps6105x_regulator_get_voltage_sel,
-	.set_voltage_sel = tps6105x_regulator_set_voltage_sel,
+	.enable		= regulator_enable_regmap,
+	.disable	= regulator_disable_regmap,
+	.is_enabled	= regulator_is_enabled_regmap,
+	.get_voltage_sel = regulator_get_voltage_sel_regmap,
+	.set_voltage_sel = regulator_set_voltage_sel_regmap,
 	.list_voltage	= regulator_list_voltage_table,
 };
 
@@ -122,6 +44,12 @@ static const struct regulator_desc tps6105x_regulator_desc = {
 	.owner		= THIS_MODULE,
 	.n_voltages	= ARRAY_SIZE(tps6105x_voltages),
 	.volt_table	= tps6105x_voltages,
+	.vsel_reg	= TPS6105X_REG_0,
+	.vsel_mask	= TPS6105X_REG0_VOLTAGE_MASK,
+	.enable_reg	= TPS6105X_REG_0,
+	.enable_mask	= TPS6105X_REG0_MODE_MASK,
+	.enable_val	= TPS6105X_REG0_MODE_VOLTAGE <<
+			  TPS6105X_REG0_MODE_SHIFT,
 };
 
 /*
@@ -144,6 +72,7 @@ static int tps6105x_regulator_probe(struct platform_device *pdev)
 	config.dev = &tps6105x->client->dev;
 	config.init_data = pdata->regulator_data;
 	config.driver_data = tps6105x;
+	config.regmap = tps6105x->regmap;
 
 	/* Register regulator with framework */
 	tps6105x->regulator = devm_regulator_register(&pdev->dev,
-- 
2.1.4



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1241463

FromGrigoryev Denis <grigoryev@fastwel.ru>
Date2015-10-07 15:00 +0200
Message-ID<qgWu7-5fT-27@gated-at.bofh.it>
In reply to#1241107
SGksCgpPbiBXZWQuLCAwNy8xMC8yMDE1IDA4OjQ3ICswODAwLCBBeGVsIExpbiB3cm90ZToKPiBT
aW5jZSBjb21taXQgN2U1MDcxMTk5MzU1ICgibWZkOiB0cHM2MTA1eDogVXNlIGkyYyByZWdtYXAg
dG8gYWNjZXNzCj4gcmVnaXN0ZXJzIiksIHdlIGNhbiB1c2UgcmVnbWFwIGhlbHBlciBmdW5jdGlv
bnMgaW5zdGVhZCBvZiBvcGVuIGNvZGVkLgo+IAo+IFNpZ25lZC1vZmYtYnk6IEF4ZWwgTGluIDxh
eGVsLmxpbkBpbmdpY3MuY29tPgo+IC0tLQo+IEhpIEdyaWdvcnlldiwKPiBJIGRvbid0IGhhdmUg
dGhpcyBoL3csIGNhbiB5b3UgaGVscCB0ZXN0IHRoaXMgcGF0Y2g/IFRoYW5rcy4KPiAKCldvcmtp
bmcgZmluZSBvbiBBUk0gRnJlZXNjYWxlIElNWDZRIG1hY2hpbmUgbWZkIGdpdCB0cmVlLiBSZWd1
bGF0b3IgdGVzdGVkCmZvciBlbmFibGUvZGlzYWJsZSBhbmQgdm9sdGFnZSBjaGFuZ2UuCgpUZXN0
ZWQtYnk6IERlbmlzIEdyaWdvcnlldiA8Z3JpZ29yeWV2QGZhc3R3ZWwucnU+CgpSZWdhcmRzLApE
ZW5pcwo=
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1241563

FromMark Brown <broonie@kernel.org>
Date2015-10-07 16:40 +0200
Message-ID<qgY2S-7BV-25@gated-at.bofh.it>
In reply to#1241107

[Multipart message — attachments visible in raw view] — view raw

On Wed, Oct 07, 2015 at 08:47:17AM +0800, Axel Lin wrote:
> Since commit 7e5071199355 ("mfd: tps6105x: Use i2c regmap to access
> registers"), we can use regmap helper functions instead of open coded.

I'll merge this after the merge window.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web