* [PATCH RFT 1/2] regulator: max1586: Convert max1586_v6_ops to regulator_list_voltage_table
@ 2012-06-04 4:56 Axel Lin
2012-06-04 4:58 ` [PATCH RFT 2/2] regulator: max1586: Convert max1586_v6_ops to set_voltage_sel Axel Lin
2012-06-04 10:25 ` [PATCH RFT 1/2] regulator: max1586: Convert max1586_v6_ops to regulator_list_voltage_table Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-06-04 4:56 UTC (permalink / raw)
To: linux-kernel; +Cc: Robert Jarzmik, Liam Girdwood, Mark Brown
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/max1586.c | 35 ++++++++++++-----------------------
1 file changed, 12 insertions(+), 23 deletions(-)
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index b9444ee..f215195 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -48,6 +48,14 @@ struct max1586_data {
};
/*
+ * V6 voltage
+ * On I2C bus, sending a "x" byte to the max1586 means :
+ * set V6 to either 0V, 1.8V, 2.5V, 3V depending on (x & 0x3)
+ * As regulator framework doesn't accept voltages to be 0V, we use 1uV.
+ */
+static int v6_voltages_uv[] = { 1, 1800000, 2500000, 3000000 };
+
+/*
* V3 voltage
* On I2C bus, sending a "x" byte to the max1586 means :
* set V3 to 0.700V + (x & 0x1f) * 0.025V
@@ -97,19 +105,6 @@ static int max1586_v3_list(struct regulator_dev *rdev, unsigned selector)
return max1586_v3_calc_voltage(max1586, selector);
}
-/*
- * V6 voltage
- * On I2C bus, sending a "x" byte to the max1586 means :
- * set V6 to either 0V, 1.8V, 2.5V, 3V depending on (x & 0x3)
- * As regulator framework doesn't accept voltages to be 0V, we use 1uV.
- */
-static int max1586_v6_calc_voltage(unsigned selector)
-{
- static int voltages_uv[] = { 1, 1800000, 2500000, 3000000 };
-
- return voltages_uv[selector];
-}
-
static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV,
unsigned int *selector)
{
@@ -130,23 +125,16 @@ static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV,
else if (min_uV >= 3000000)
*selector = 3;
- if (max1586_v6_calc_voltage(*selector) > max_uV)
+ if (rdev->desc->volt_table[*selector] > max_uV)
return -EINVAL;
dev_dbg(&client->dev, "changing voltage v6 to %dmv\n",
- max1586_v6_calc_voltage(*selector) / 1000);
+ rdev->desc->volt_table[*selector] / 1000);
v6_prog = I2C_V6_SELECT | (u8) *selector;
return i2c_smbus_write_byte(client, v6_prog);
}
-static int max1586_v6_list(struct regulator_dev *rdev, unsigned selector)
-{
- if (selector > MAX1586_V6_MAX_VSEL)
- return -EINVAL;
- return max1586_v6_calc_voltage(selector);
-}
-
/*
* The Maxim 1586 controls V3 and V6 voltages, but offers no way of reading back
* the set up value.
@@ -158,7 +146,7 @@ static struct regulator_ops max1586_v3_ops = {
static struct regulator_ops max1586_v6_ops = {
.set_voltage = max1586_v6_set,
- .list_voltage = max1586_v6_list,
+ .list_voltage = regulator_list_voltage_table,
};
static const struct regulator_desc max1586_reg[] = {
@@ -176,6 +164,7 @@ static const struct regulator_desc max1586_reg[] = {
.ops = &max1586_v6_ops,
.type = REGULATOR_VOLTAGE,
.n_voltages = MAX1586_V6_MAX_VSEL + 1,
+ .volt_table = v6_voltages_uv,
.owner = THIS_MODULE,
},
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH RFT 2/2] regulator: max1586: Convert max1586_v6_ops to set_voltage_sel
2012-06-04 4:56 [PATCH RFT 1/2] regulator: max1586: Convert max1586_v6_ops to regulator_list_voltage_table Axel Lin
@ 2012-06-04 4:58 ` Axel Lin
2012-06-04 10:25 ` [PATCH RFT 1/2] regulator: max1586: Convert max1586_v6_ops to regulator_list_voltage_table Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2012-06-04 4:58 UTC (permalink / raw)
To: linux-kernel; +Cc: Robert Jarzmik, Liam Girdwood, Mark Brown
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/max1586.c | 27 +++++----------------------
1 file changed, 5 insertions(+), 22 deletions(-)
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index f215195..126c7d8 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -105,33 +105,16 @@ static int max1586_v3_list(struct regulator_dev *rdev, unsigned selector)
return max1586_v3_calc_voltage(max1586, selector);
}
-static int max1586_v6_set(struct regulator_dev *rdev, int min_uV, int max_uV,
- unsigned int *selector)
+static int max1586_v6_set_voltage_sel(struct regulator_dev *rdev,
+ unsigned int selector)
{
struct i2c_client *client = rdev_get_drvdata(rdev);
u8 v6_prog;
- if (min_uV < MAX1586_V6_MIN_UV || min_uV > MAX1586_V6_MAX_UV)
- return -EINVAL;
- if (max_uV < MAX1586_V6_MIN_UV || max_uV > MAX1586_V6_MAX_UV)
- return -EINVAL;
-
- if (min_uV < 1800000)
- *selector = 0;
- else if (min_uV < 2500000)
- *selector = 1;
- else if (min_uV < 3000000)
- *selector = 2;
- else if (min_uV >= 3000000)
- *selector = 3;
-
- if (rdev->desc->volt_table[*selector] > max_uV)
- return -EINVAL;
-
dev_dbg(&client->dev, "changing voltage v6 to %dmv\n",
- rdev->desc->volt_table[*selector] / 1000);
+ rdev->desc->volt_table[selector] / 1000);
- v6_prog = I2C_V6_SELECT | (u8) *selector;
+ v6_prog = I2C_V6_SELECT | (u8) selector;
return i2c_smbus_write_byte(client, v6_prog);
}
@@ -145,7 +128,7 @@ static struct regulator_ops max1586_v3_ops = {
};
static struct regulator_ops max1586_v6_ops = {
- .set_voltage = max1586_v6_set,
+ .set_voltage_sel = max1586_v6_set_voltage_sel,
.list_voltage = regulator_list_voltage_table,
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RFT 1/2] regulator: max1586: Convert max1586_v6_ops to regulator_list_voltage_table
2012-06-04 4:56 [PATCH RFT 1/2] regulator: max1586: Convert max1586_v6_ops to regulator_list_voltage_table Axel Lin
2012-06-04 4:58 ` [PATCH RFT 2/2] regulator: max1586: Convert max1586_v6_ops to set_voltage_sel Axel Lin
@ 2012-06-04 10:25 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-06-04 10:25 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Robert Jarzmik, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 128 bytes --]
On Mon, Jun 04, 2012 at 12:56:58PM +0800, Axel Lin wrote:
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
Applied both, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-04 10:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-04 4:56 [PATCH RFT 1/2] regulator: max1586: Convert max1586_v6_ops to regulator_list_voltage_table Axel Lin
2012-06-04 4:58 ` [PATCH RFT 2/2] regulator: max1586: Convert max1586_v6_ops to set_voltage_sel Axel Lin
2012-06-04 10:25 ` [PATCH RFT 1/2] regulator: max1586: Convert max1586_v6_ops to regulator_list_voltage_table 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).