All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFT 1/3] regulator: isl6271a: Use regulator_list_voltage_linear()
@ 2012-05-16  2:09 Axel Lin
  2012-05-16  2:10 ` [PATCH RFT 2/3] regulator: isl6271a: Convert to get_voltage_sel Axel Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Axel Lin @ 2012-05-16  2:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marek Vasut, Liam Girdwood, Mark Brown

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

diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c
index 5caaf1f..78cdc90 100644
--- a/drivers/regulator/isl6271a-regulator.c
+++ b/drivers/regulator/isl6271a-regulator.c
@@ -83,15 +83,10 @@ static int isl6271a_set_voltage(struct regulator_dev *dev,
 	return err;
 }
 
-static int isl6271a_list_voltage(struct regulator_dev *dev, unsigned selector)
-{
-	return ISL6271A_VOLTAGE_MIN + (ISL6271A_VOLTAGE_STEP * selector);
-}
-
 static struct regulator_ops isl_core_ops = {
 	.get_voltage	= isl6271a_get_voltage,
 	.set_voltage	= isl6271a_set_voltage,
-	.list_voltage	= isl6271a_list_voltage,
+	.list_voltage	= regulator_list_voltage_linear,
 };
 
 static int isl6271a_get_fixed_voltage(struct regulator_dev *dev)
@@ -119,6 +114,8 @@ static const struct regulator_desc isl_rd[] = {
 		.ops		= &isl_core_ops,
 		.type		= REGULATOR_VOLTAGE,
 		.owner		= THIS_MODULE,
+		.min_uV		= ISL6271A_VOLTAGE_MIN,
+		.uV_step	= ISL6271A_VOLTAGE_STEP,
 	}, {
 		.name		= "LDO1",
 		.id		= 1,
-- 
1.7.5.4




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

* [PATCH RFT 2/3] regulator: isl6271a: Convert to get_voltage_sel
  2012-05-16  2:09 [PATCH RFT 1/3] regulator: isl6271a: Use regulator_list_voltage_linear() Axel Lin
@ 2012-05-16  2:10 ` Axel Lin
  2012-05-16  2:11 ` [PATCH RFT 3/3] regulator: isl6271a: Convert to set_voltage_sel and regulator_map_voltage_linear Axel Lin
  2012-05-16  8:47 ` [PATCH RFT 1/3] regulator: isl6271a: Use regulator_list_voltage_linear() Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Axel Lin @ 2012-05-16  2:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marek Vasut, Liam Girdwood, Mark Brown

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/isl6271a-regulator.c |   17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c
index 78cdc90..00cb288 100644
--- a/drivers/regulator/isl6271a-regulator.c
+++ b/drivers/regulator/isl6271a-regulator.c
@@ -35,26 +35,19 @@ struct isl_pmic {
 	struct mutex		mtx;
 };
 
-static int isl6271a_get_voltage(struct regulator_dev *dev)
+static int isl6271a_get_voltage_sel(struct regulator_dev *dev)
 {
 	struct isl_pmic *pmic = rdev_get_drvdata(dev);
-	int idx, data;
+	int idx;
 
 	mutex_lock(&pmic->mtx);
 
 	idx = i2c_smbus_read_byte(pmic->client);
-	if (idx < 0) {
+	if (idx < 0)
 		dev_err(&pmic->client->dev, "Error getting voltage\n");
-		data = idx;
-		goto out;
-	}
-
-	/* Convert the data from chip to microvolts */
-	data = ISL6271A_VOLTAGE_MIN + (ISL6271A_VOLTAGE_STEP * (idx & 0xf));
 
-out:
 	mutex_unlock(&pmic->mtx);
-	return data;
+	return idx;
 }
 
 static int isl6271a_set_voltage(struct regulator_dev *dev,
@@ -84,7 +77,7 @@ static int isl6271a_set_voltage(struct regulator_dev *dev,
 }
 
 static struct regulator_ops isl_core_ops = {
-	.get_voltage	= isl6271a_get_voltage,
+	.get_voltage_sel = isl6271a_get_voltage_sel,
 	.set_voltage	= isl6271a_set_voltage,
 	.list_voltage	= regulator_list_voltage_linear,
 };
-- 
1.7.5.4




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

* [PATCH RFT 3/3] regulator: isl6271a: Convert to set_voltage_sel and regulator_map_voltage_linear
  2012-05-16  2:09 [PATCH RFT 1/3] regulator: isl6271a: Use regulator_list_voltage_linear() Axel Lin
  2012-05-16  2:10 ` [PATCH RFT 2/3] regulator: isl6271a: Convert to get_voltage_sel Axel Lin
@ 2012-05-16  2:11 ` Axel Lin
  2012-05-16  2:29   ` Marek Vasut
  2012-05-16  8:47 ` [PATCH RFT 1/3] regulator: isl6271a: Use regulator_list_voltage_linear() Mark Brown
  2 siblings, 1 reply; 5+ messages in thread
From: Axel Lin @ 2012-05-16  2:11 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marek Vasut, Liam Girdwood, Mark Brown

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/isl6271a-regulator.c |   21 ++++++---------------
 1 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c
index 00cb288..56d273f 100644
--- a/drivers/regulator/isl6271a-regulator.c
+++ b/drivers/regulator/isl6271a-regulator.c
@@ -50,25 +50,15 @@ static int isl6271a_get_voltage_sel(struct regulator_dev *dev)
 	return idx;
 }
 
-static int isl6271a_set_voltage(struct regulator_dev *dev,
-				int minuV, int maxuV,
-				unsigned *selector)
+static int isl6271a_set_voltage_sel(struct regulator_dev *dev,
+				    unsigned selector)
 {
 	struct isl_pmic *pmic = rdev_get_drvdata(dev);
-	int err, data;
-
-	if (minuV < ISL6271A_VOLTAGE_MIN || minuV > ISL6271A_VOLTAGE_MAX)
-		return -EINVAL;
-	if (maxuV < ISL6271A_VOLTAGE_MIN || maxuV > ISL6271A_VOLTAGE_MAX)
-		return -EINVAL;
-
-	data = DIV_ROUND_UP(minuV - ISL6271A_VOLTAGE_MIN,
-			    ISL6271A_VOLTAGE_STEP);
-	*selector = data;
+	int err;
 
 	mutex_lock(&pmic->mtx);
 
-	err = i2c_smbus_write_byte(pmic->client, data);
+	err = i2c_smbus_write_byte(pmic->client, selector);
 	if (err < 0)
 		dev_err(&pmic->client->dev, "Error setting voltage\n");
 
@@ -78,8 +68,9 @@ static int isl6271a_set_voltage(struct regulator_dev *dev,
 
 static struct regulator_ops isl_core_ops = {
 	.get_voltage_sel = isl6271a_get_voltage_sel,
-	.set_voltage	= isl6271a_set_voltage,
+	.set_voltage_sel = isl6271a_set_voltage_sel,
 	.list_voltage	= regulator_list_voltage_linear,
+	.map_voltage	= regulator_map_voltage_linear,
 };
 
 static int isl6271a_get_fixed_voltage(struct regulator_dev *dev)
-- 
1.7.5.4




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

* Re: [PATCH RFT 3/3] regulator: isl6271a: Convert to set_voltage_sel and regulator_map_voltage_linear
  2012-05-16  2:11 ` [PATCH RFT 3/3] regulator: isl6271a: Convert to set_voltage_sel and regulator_map_voltage_linear Axel Lin
@ 2012-05-16  2:29   ` Marek Vasut
  0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2012-05-16  2:29 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, Mark Brown

Dear Axel Lin,

> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>  drivers/regulator/isl6271a-regulator.c |   21 ++++++---------------
>  1 files changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/regulator/isl6271a-regulator.c
> b/drivers/regulator/isl6271a-regulator.c index 00cb288..56d273f 100644
> --- a/drivers/regulator/isl6271a-regulator.c
> +++ b/drivers/regulator/isl6271a-regulator.c
> @@ -50,25 +50,15 @@ static int isl6271a_get_voltage_sel(struct
> regulator_dev *dev) return idx;
>  }
> 
> -static int isl6271a_set_voltage(struct regulator_dev *dev,
> -				int minuV, int maxuV,
> -				unsigned *selector)
> +static int isl6271a_set_voltage_sel(struct regulator_dev *dev,
> +				    unsigned selector)
>  {
>  	struct isl_pmic *pmic = rdev_get_drvdata(dev);
> -	int err, data;
> -
> -	if (minuV < ISL6271A_VOLTAGE_MIN || minuV > ISL6271A_VOLTAGE_MAX)
> -		return -EINVAL;
> -	if (maxuV < ISL6271A_VOLTAGE_MIN || maxuV > ISL6271A_VOLTAGE_MAX)
> -		return -EINVAL;
> -
> -	data = DIV_ROUND_UP(minuV - ISL6271A_VOLTAGE_MIN,
> -			    ISL6271A_VOLTAGE_STEP);
> -	*selector = data;
> +	int err;
> 
>  	mutex_lock(&pmic->mtx);
> 
> -	err = i2c_smbus_write_byte(pmic->client, data);
> +	err = i2c_smbus_write_byte(pmic->client, selector);
>  	if (err < 0)
>  		dev_err(&pmic->client->dev, "Error setting voltage\n");
> 
> @@ -78,8 +68,9 @@ static int isl6271a_set_voltage(struct regulator_dev
> *dev,
> 
>  static struct regulator_ops isl_core_ops = {
>  	.get_voltage_sel = isl6271a_get_voltage_sel,
> -	.set_voltage	= isl6271a_set_voltage,
> +	.set_voltage_sel = isl6271a_set_voltage_sel,
>  	.list_voltage	= regulator_list_voltage_linear,
> +	.map_voltage	= regulator_map_voltage_linear,
>  };
> 
>  static int isl6271a_get_fixed_voltage(struct regulator_dev *dev)

Hm well, I hope this won't break the driver. I can't test it any soon.

Best regards,
Marek Vasut

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

* Re: [PATCH RFT 1/3] regulator: isl6271a: Use regulator_list_voltage_linear()
  2012-05-16  2:09 [PATCH RFT 1/3] regulator: isl6271a: Use regulator_list_voltage_linear() Axel Lin
  2012-05-16  2:10 ` [PATCH RFT 2/3] regulator: isl6271a: Convert to get_voltage_sel Axel Lin
  2012-05-16  2:11 ` [PATCH RFT 3/3] regulator: isl6271a: Convert to set_voltage_sel and regulator_map_voltage_linear Axel Lin
@ 2012-05-16  8:47 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2012-05-16  8:47 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Marek Vasut, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 127 bytes --]

On Wed, May 16, 2012 at 10:09:27AM +0800, Axel Lin wrote:
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied all, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2012-05-16  8:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-16  2:09 [PATCH RFT 1/3] regulator: isl6271a: Use regulator_list_voltage_linear() Axel Lin
2012-05-16  2:10 ` [PATCH RFT 2/3] regulator: isl6271a: Convert to get_voltage_sel Axel Lin
2012-05-16  2:11 ` [PATCH RFT 3/3] regulator: isl6271a: Convert to set_voltage_sel and regulator_map_voltage_linear Axel Lin
2012-05-16  2:29   ` Marek Vasut
2012-05-16  8:47 ` [PATCH RFT 1/3] regulator: isl6271a: Use regulator_list_voltage_linear() Mark Brown

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.