2012-06-08 00:26:35

by Axel Lin

[permalink] [raw]
Subject: [PATCH RFT 1/2] regulator: max1586: Convert max1586_v3_ops to regulator_list_voltage_linear

Signed-off-by: Axel Lin <[email protected]>
---
drivers/regulator/max1586.c | 32 +++++++++++---------------------
1 file changed, 11 insertions(+), 21 deletions(-)

diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index 126c7d8..a54771e 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -63,14 +63,6 @@ static int v6_voltages_uv[] = { 1, 1800000, 2500000, 3000000 };
* R24 and R25=100kOhm as described in the data sheet.
* The gain is approximately: 1 + R24/R25 + R24/185.5kOhm
*/
-static int max1586_v3_calc_voltage(struct max1586_data *max1586,
- unsigned selector)
-{
- unsigned range_uV = max1586->max_uV - max1586->min_uV;
-
- return max1586->min_uV + (selector * range_uV / MAX1586_V3_MAX_VSEL);
-}
-
static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV,
unsigned *selector)
{
@@ -86,25 +78,16 @@ static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV,

*selector = DIV_ROUND_UP((min_uV - max1586->min_uV) *
MAX1586_V3_MAX_VSEL, range_uV);
- if (max1586_v3_calc_voltage(max1586, *selector) > max_uV)
+ if (regulator_list_voltage_linear(rdev, *selector) > max_uV)
return -EINVAL;

dev_dbg(&client->dev, "changing voltage v3 to %dmv\n",
- max1586_v3_calc_voltage(max1586, *selector) / 1000);
+ regulator_list_voltage_linear(rdev, *selector) / 1000);

v3_prog = I2C_V3_SELECT | (u8) *selector;
return i2c_smbus_write_byte(client, v3_prog);
}

-static int max1586_v3_list(struct regulator_dev *rdev, unsigned selector)
-{
- struct max1586_data *max1586 = rdev_get_drvdata(rdev);
-
- if (selector > MAX1586_V3_MAX_VSEL)
- return -EINVAL;
- return max1586_v3_calc_voltage(max1586, selector);
-}
-
static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev,
unsigned int selector)
{
@@ -124,7 +107,7 @@ static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev,
*/
static struct regulator_ops max1586_v3_ops = {
.set_voltage = max1586_v3_set,
- .list_voltage = max1586_v3_list,
+ .list_voltage = regulator_list_voltage_linear,
};

static struct regulator_ops max1586_v6_ops = {
@@ -132,7 +115,7 @@ static struct regulator_ops max1586_v6_ops = {
.list_voltage = regulator_list_voltage_table,
};

-static const struct regulator_desc max1586_reg[] = {
+static struct regulator_desc max1586_reg[] = {
{
.name = "Output_V3",
.id = MAX1586_V3,
@@ -185,6 +168,13 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client,
goto err;
}

+ if (id == MAX1586_V3) {
+ max1586_reg[id].min_uV = max1586->min_uV;
+ max1586_reg[id].uV_step =
+ (max1586->max_uV - max1586->min_uV) /
+ MAX1586_V3_MAX_VSEL;
+ }
+
config.dev = &client->dev;
config.init_data = pdata->subdevs[i].platform_data;
config.driver_data = max1586;
--
1.7.9.5



2012-06-08 00:26:52

by Axel Lin

[permalink] [raw]
Subject: [PATCH RFT 2/2] regulator: max1586: Convert max1586_v3_ops to set_voltage_sel and map_voltage_linear

Signed-off-by: Axel Lin <[email protected]>
---
drivers/regulator/max1586.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index a54771e..f67af3c 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -63,28 +63,17 @@ static int v6_voltages_uv[] = { 1, 1800000, 2500000, 3000000 };
* R24 and R25=100kOhm as described in the data sheet.
* The gain is approximately: 1 + R24/R25 + R24/185.5kOhm
*/
-static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV,
- unsigned *selector)
+static int max1586_v3_set_voltage_sel(struct regulator_dev *rdev,
+ unsigned selector)
{
struct max1586_data *max1586 = rdev_get_drvdata(rdev);
struct i2c_client *client = max1586->client;
- unsigned range_uV = max1586->max_uV - max1586->min_uV;
u8 v3_prog;

- if (min_uV > max1586->max_uV || max_uV < max1586->min_uV)
- return -EINVAL;
- if (min_uV < max1586->min_uV)
- min_uV = max1586->min_uV;
-
- *selector = DIV_ROUND_UP((min_uV - max1586->min_uV) *
- MAX1586_V3_MAX_VSEL, range_uV);
- if (regulator_list_voltage_linear(rdev, *selector) > max_uV)
- return -EINVAL;
-
dev_dbg(&client->dev, "changing voltage v3 to %dmv\n",
- regulator_list_voltage_linear(rdev, *selector) / 1000);
+ regulator_list_voltage_linear(rdev, selector) / 1000);

- v3_prog = I2C_V3_SELECT | (u8) *selector;
+ v3_prog = I2C_V3_SELECT | (u8) selector;
return i2c_smbus_write_byte(client, v3_prog);
}

@@ -106,8 +95,9 @@ static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev,
* the set up value.
*/
static struct regulator_ops max1586_v3_ops = {
- .set_voltage = max1586_v3_set,
+ .set_voltage_sel = max1586_v3_set_voltage_sel,
.list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
};

static struct regulator_ops max1586_v6_ops = {
--
1.7.9.5


2012-06-10 18:11:49

by Robert Jarzmik

[permalink] [raw]
Subject: Re: [PATCH RFT 2/2] regulator: max1586: Convert max1586_v3_ops to set_voltage_sel and map_voltage_linear

Axel Lin <[email protected]> writes:

> Signed-off-by: Axel Lin <[email protected]>
Hi Axel,

The patches look OK to me, but I cannot build them.
Even on top of linux-next, I get :
drivers/regulator/max1586.c: In function 'max1586_v6_set_voltage_sel':
drivers/regulator/max1586.c:86:2: error: 'const struct regulator_desc' has no member named 'volt_table'
drivers/regulator/max1586.c: At top level:
drivers/regulator/max1586.c:105:18: error: 'regulator_list_voltage_table' undeclared here (not in a function)
drivers/regulator/max1586.c:123:3: error: unknown field 'volt_table' specified in initializer
drivers/regulator/max1586.c:123:3: warning: initialization from incompatible pointer type [enabled by default]
drivers/regulator/max1586.c:123:3: warning: (near initialization for 'max1586_reg[1].ops') [enabled by default]

I suppose you're basing your tree on top of a set of commits not available in
linux-next (maybe Mark's regulator tree ?). As I don't have that tree in mind,
it would be kind to tell me which tree you're basing your work on, so that I
could test your last patches.

Cheers.

--
Robert

2012-06-10 23:27:37

by Axel Lin

[permalink] [raw]
Subject: Re: [PATCH RFT 2/2] regulator: max1586: Convert max1586_v3_ops to set_voltage_sel and map_voltage_linear

2012/6/11 Robert Jarzmik <[email protected]>:
> Axel Lin <[email protected]> writes:
>
>> Signed-off-by: Axel Lin <[email protected]>
> Hi Axel,
>
> The patches look OK to me, but I cannot build them.
> Even on top of linux-next, I get :
> drivers/regulator/max1586.c: In function 'max1586_v6_set_voltage_sel':
> drivers/regulator/max1586.c:86:2: error: 'const struct regulator_desc' has no member named 'volt_table'
> drivers/regulator/max1586.c: At top level:
> drivers/regulator/max1586.c:105:18: error: 'regulator_list_voltage_table' undeclared here (not in a function)
> drivers/regulator/max1586.c:123:3: error: unknown field 'volt_table' specified in initializer
> drivers/regulator/max1586.c:123:3: warning: initialization from incompatible pointer type [enabled by default]
> drivers/regulator/max1586.c:123:3: warning: (near initialization for 'max1586_reg[1].ops') [enabled by default]
>
> I suppose you're basing your tree on top of a set of commits not available in
> linux-next (maybe Mark's regulator tree ?). As I don't have that tree in mind,
> it would be kind to tell me which tree you're basing your work on, so that I
> could test your last patches.

I think all the necessary patches are already in linux-next tree.
I have no problem to build it with linux-next 20120608.

Regards,
Axel

2012-06-11 18:09:51

by Robert Jarzmik

[permalink] [raw]
Subject: Re: [PATCH RFT 2/2] regulator: max1586: Convert max1586_v3_ops to set_voltage_sel and map_voltage_linear

Axel Lin <[email protected]> writes:

> 2012/6/11 Robert Jarzmik <[email protected]>:
>> Axel Lin <[email protected]> writes:
> I think all the necessary patches are already in linux-next tree.
> I have no problem to build it with linux-next 20120608.

OK, my fault, build problem.
I tested this serie with the PXA VCC-core regulation, it's fine.

Please have my :
Acked-by: Robert Jarzmik <[email protected]>

Cheers.

--
Robert

2012-06-11 18:42:38

by Robert Jarzmik

[permalink] [raw]
Subject: Re: [PATCH RFT 2/2] regulator: max1586: Convert max1586_v3_ops to set_voltage_sel and map_voltage_linear

Axel Lin <[email protected]> writes:

> 2012/6/11 Robert Jarzmik <[email protected]>:
>> Axel Lin <[email protected]> writes:
> I think all the necessary patches are already in linux-next tree.
> I have no problem to build it with linux-next 20120608.

OK, my fault, build problem.
I tested this serie with the PXA VCC-core regulation, it's fine.

Please have my :
Acked-by: Robert Jarzmik <[email protected]>

Cheers.

--
Robert