* [PATCH 1/2] regulator: Set list_voltage callback for max8925
@ 2012-04-02 1:14 Axel Lin
2012-04-02 1:16 ` [PATCH 2/2] regulator: Add missing n_voltages setting " Axel Lin
2012-04-02 22:15 ` [PATCH 1/2] regulator: Set list_voltage callback " Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-04-02 1:14 UTC (permalink / raw)
To: linux-kernel; +Cc: Haojian Zhuang, Liam Girdwood, Mark Brown
Current code implements max8925_list_voltage but does not set the list_voltage
callback function in max8925_regulator_[ldo|sdv]_ops. Fix it.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/max8925-regulator.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c
index 2f242f4..ad8b093 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -163,6 +163,7 @@ static int max8925_set_dvm_disable(struct regulator_dev *rdev)
}
static struct regulator_ops max8925_regulator_sdv_ops = {
+ .list_voltage = max8925_list_voltage,
.set_voltage = max8925_set_voltage,
.get_voltage = max8925_get_voltage,
.enable = max8925_enable,
@@ -174,6 +175,7 @@ static struct regulator_ops max8925_regulator_sdv_ops = {
};
static struct regulator_ops max8925_regulator_ldo_ops = {
+ .list_voltage = max8925_list_voltage,
.set_voltage = max8925_set_voltage,
.get_voltage = max8925_get_voltage,
.enable = max8925_enable,
--
1.7.5.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] regulator: Add missing n_voltages setting for max8925
2012-04-02 1:14 [PATCH 1/2] regulator: Set list_voltage callback for max8925 Axel Lin
@ 2012-04-02 1:16 ` Axel Lin
2012-04-02 22:15 ` [PATCH 1/2] regulator: Set list_voltage callback " Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2012-04-02 1:16 UTC (permalink / raw)
To: linux-kernel; +Cc: Haojian Zhuang, Liam Girdwood, Mark Brown
The n_voltages are the same for all regulators: (max - min / step) + 1 == 64.
The vol_shift is always 0, and the vol_nbits is always the same as n_voltages
setting. Thus we can remove vol_shitf and vol_nbits fields from struct
max8925_regulator_info.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/max8925-regulator.c | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c
index ad8b093..a62f3b5 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -42,8 +42,6 @@ struct max8925_regulator_info {
int max_uV;
int step_uV;
int vol_reg;
- int vol_shift;
- int vol_nbits;
int enable_reg;
};
@@ -75,8 +73,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev,
}
data = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
*selector = data;
- data <<= info->vol_shift;
- mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
+ mask = rdev->desc->n_voltages - 1;
return max8925_set_bits(info->i2c, info->vol_reg, mask, data);
}
@@ -90,8 +87,8 @@ static int max8925_get_voltage(struct regulator_dev *rdev)
ret = max8925_reg_read(info->i2c, info->vol_reg);
if (ret < 0)
return ret;
- mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
- data = (ret & mask) >> info->vol_shift;
+ mask = rdev->desc->n_voltages - 1;
+ data = ret & mask;
return max8925_list_voltage(rdev, data);
}
@@ -191,13 +188,12 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
.type = REGULATOR_VOLTAGE, \
.id = MAX8925_ID_SD##_id, \
.owner = THIS_MODULE, \
+ .n_voltages = 64, \
}, \
.min_uV = min * 1000, \
.max_uV = max * 1000, \
.step_uV = step * 1000, \
.vol_reg = MAX8925_SDV##_id, \
- .vol_shift = 0, \
- .vol_nbits = 6, \
.enable_reg = MAX8925_SDCTL##_id, \
}
@@ -209,13 +205,12 @@ static struct regulator_ops max8925_regulator_ldo_ops = {
.type = REGULATOR_VOLTAGE, \
.id = MAX8925_ID_LDO##_id, \
.owner = THIS_MODULE, \
+ .n_voltages = 64, \
}, \
.min_uV = min * 1000, \
.max_uV = max * 1000, \
.step_uV = step * 1000, \
.vol_reg = MAX8925_LDOVOUT##_id, \
- .vol_shift = 0, \
- .vol_nbits = 6, \
.enable_reg = MAX8925_LDOCTL##_id, \
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] regulator: Set list_voltage callback for max8925
2012-04-02 1:14 [PATCH 1/2] regulator: Set list_voltage callback for max8925 Axel Lin
2012-04-02 1:16 ` [PATCH 2/2] regulator: Add missing n_voltages setting " Axel Lin
@ 2012-04-02 22:15 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-04-02 22:15 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Haojian Zhuang, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 226 bytes --]
On Mon, Apr 02, 2012 at 09:14:28AM +0800, Axel Lin wrote:
> Current code implements max8925_list_voltage but does not set the list_voltage
> callback function in max8925_regulator_[ldo|sdv]_ops. Fix it.
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-04-02 22:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-02 1:14 [PATCH 1/2] regulator: Set list_voltage callback for max8925 Axel Lin
2012-04-02 1:16 ` [PATCH 2/2] regulator: Add missing n_voltages setting " Axel Lin
2012-04-02 22:15 ` [PATCH 1/2] regulator: Set list_voltage callback " 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).