* [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear
@ 2013-01-18 3:58 Axel Lin
2013-01-18 3:59 ` [PATCH 2/2] regulator: wm8994: Merge wm8994_ldo1_ops and wm8994_ldo2_ops Axel Lin
2013-01-18 6:13 ` [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2013-01-18 3:58 UTC (permalink / raw)
To: Mark Brown; +Cc: Liam Girdwood, patches, linux-kernel
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/wm8994-regulator.c | 57 ++++++++++++++++------------------
1 file changed, 26 insertions(+), 31 deletions(-)
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c
index 6ff8723..fef2692 100644
--- a/drivers/regulator/wm8994-regulator.c
+++ b/drivers/regulator/wm8994-regulator.c
@@ -27,7 +27,6 @@
struct wm8994_ldo {
struct regulator_dev *regulator;
- struct wm8994 *wm8994;
};
#define WM8994_LDO1_MAX_SELECTOR 0x7
@@ -40,39 +39,14 @@ static struct regulator_ops wm8994_ldo1_ops = {
.set_voltage_sel = regulator_set_voltage_sel_regmap,
};
-static int wm8994_ldo2_list_voltage(struct regulator_dev *rdev,
- unsigned int selector)
-{
- struct wm8994_ldo *ldo = rdev_get_drvdata(rdev);
-
- if (selector > WM8994_LDO2_MAX_SELECTOR)
- return -EINVAL;
-
- switch (ldo->wm8994->type) {
- case WM8994:
- return (selector * 100000) + 900000;
- case WM8958:
- return (selector * 100000) + 1000000;
- case WM1811:
- switch (selector) {
- case 0:
- return -EINVAL;
- default:
- return (selector * 100000) + 950000;
- }
- break;
- default:
- return -EINVAL;
- }
-}
-
static struct regulator_ops wm8994_ldo2_ops = {
- .list_voltage = wm8994_ldo2_list_voltage,
+ .list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
};
-static const struct regulator_desc wm8994_ldo_desc[] = {
+static struct regulator_desc wm8994_ldo_desc[] = {
{
.name = "LDO1",
.id = 1,
@@ -116,8 +90,6 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
return -ENOMEM;
}
- ldo->wm8994 = wm8994;
-
config.dev = wm8994->dev;
config.driver_data = ldo;
config.regmap = wm8994->regmap;
@@ -126,6 +98,29 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
config.ena_gpio = pdata->ldo[id].enable;
}
+ /* LDO2, id starts from 0 */
+ if (id == 1) {
+ switch (wm8994->type) {
+ case WM8994:
+ wm8994_ldo_desc[id].min_uV = 900000;
+ wm8994_ldo_desc[id].uV_step = 100000;
+ break;
+ case WM8958:
+ wm8994_ldo_desc[id].min_uV = 1000000;
+ wm8994_ldo_desc[id].uV_step = 100000;
+ break;
+ case WM1811:
+ wm8994_ldo_desc[id].min_uV = 1050000;
+ wm8994_ldo_desc[id].uV_step = 100000;
+ wm8994_ldo_desc[id].linear_min_sel = 1;
+ break;
+ default:
+ dev_err(&pdev->dev, "Unknown wm8994 device type %d\n",
+ wm8994->type);
+ return -EINVAL;
+ }
+ }
+
ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config);
if (IS_ERR(ldo->regulator)) {
ret = PTR_ERR(ldo->regulator);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] regulator: wm8994: Merge wm8994_ldo1_ops and wm8994_ldo2_ops
2013-01-18 3:58 [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear Axel Lin
@ 2013-01-18 3:59 ` Axel Lin
2013-01-18 6:13 ` [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2013-01-18 3:59 UTC (permalink / raw)
To: Mark Brown; +Cc: Liam Girdwood, patches, linux-kernel
wm8994_ldo1_ops and wm8994_ldo2_ops are the same after converting
wm8994_ldo2_ops to use regulator_list_voltage_linear, merge them.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/wm8994-regulator.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c
index fef2692..98edfe0 100644
--- a/drivers/regulator/wm8994-regulator.c
+++ b/drivers/regulator/wm8994-regulator.c
@@ -32,14 +32,7 @@ struct wm8994_ldo {
#define WM8994_LDO1_MAX_SELECTOR 0x7
#define WM8994_LDO2_MAX_SELECTOR 0x3
-static struct regulator_ops wm8994_ldo1_ops = {
- .list_voltage = regulator_list_voltage_linear,
- .map_voltage = regulator_map_voltage_linear,
- .get_voltage_sel = regulator_get_voltage_sel_regmap,
- .set_voltage_sel = regulator_set_voltage_sel_regmap,
-};
-
-static struct regulator_ops wm8994_ldo2_ops = {
+static struct regulator_ops wm8994_ldo_ops = {
.list_voltage = regulator_list_voltage_linear,
.map_voltage = regulator_map_voltage_linear,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
@@ -54,7 +47,7 @@ static struct regulator_desc wm8994_ldo_desc[] = {
.n_voltages = WM8994_LDO1_MAX_SELECTOR + 1,
.vsel_reg = WM8994_LDO_1,
.vsel_mask = WM8994_LDO1_VSEL_MASK,
- .ops = &wm8994_ldo1_ops,
+ .ops = &wm8994_ldo_ops,
.min_uV = 2400000,
.uV_step = 100000,
.enable_time = 3000,
@@ -67,7 +60,7 @@ static struct regulator_desc wm8994_ldo_desc[] = {
.n_voltages = WM8994_LDO2_MAX_SELECTOR + 1,
.vsel_reg = WM8994_LDO_2,
.vsel_mask = WM8994_LDO2_VSEL_MASK,
- .ops = &wm8994_ldo2_ops,
+ .ops = &wm8994_ldo_ops,
.enable_time = 3000,
.owner = THIS_MODULE,
},
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear
2013-01-18 3:58 [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear Axel Lin
2013-01-18 3:59 ` [PATCH 2/2] regulator: wm8994: Merge wm8994_ldo1_ops and wm8994_ldo2_ops Axel Lin
@ 2013-01-18 6:13 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2013-01-18 6:13 UTC (permalink / raw)
To: Axel Lin; +Cc: Liam Girdwood, patches, linux-kernel
On Fri, Jan 18, 2013 at 11:58:33AM +0800, Axel Lin wrote:
> + /* LDO2, id starts from 0 */
> + if (id == 1) {
> + switch (wm8994->type) {
> + case WM8994:
> + wm8994_ldo_desc[id].min_uV = 900000;
> + wm8994_ldo_desc[id].uV_step = 100000;
> + break;
This isn't going to work in the (admittedly unlikely) case where we have
two different devices using this driver in the system. We shouldn't be
modifying static data like this.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-01-18 6:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-18 3:58 [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear Axel Lin
2013-01-18 3:59 ` [PATCH 2/2] regulator: wm8994: Merge wm8994_ldo1_ops and wm8994_ldo2_ops Axel Lin
2013-01-18 6:13 ` [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear 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).