* [PATCH 1/2] regulator: lp3971: Convert to get_voltage_sel
@ 2012-12-10 11:46 Axel Lin
2012-12-10 11:50 ` [PATCH 2/2] regulator: lp3972: " Axel Lin
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Axel Lin @ 2012-12-10 11:46 UTC (permalink / raw)
To: Mark Brown; +Cc: Marek Szyprowski, Liam Girdwood, linux-kernel
regulator_list_voltage_table() returns -EINVAL if selector >= n_voltages.
Thus we don't need to check if reg is greater than BUCK_TARGET_VOL_MAX_IDX in
lp3971_dcdc_get_voltage_sel.
BUCK_TARGET_VOL_MIN_IDX and BUCK_TARGET_VOL_MAX_IDX are not used, remove them.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/lp3971.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c
index 5f68ff1..9cb2c0f 100644
--- a/drivers/regulator/lp3971.c
+++ b/drivers/regulator/lp3971.c
@@ -73,8 +73,6 @@ static const unsigned int buck_voltage_map[] = {
};
#define BUCK_TARGET_VOL_MASK 0x3f
-#define BUCK_TARGET_VOL_MIN_IDX 0x01
-#define BUCK_TARGET_VOL_MAX_IDX 0x19
#define LP3971_BUCK_RAMP_REG(x) (buck_base_addr[x]+2)
@@ -140,7 +138,7 @@ static int lp3971_ldo_disable(struct regulator_dev *dev)
return lp3971_set_bits(lp3971, LP3971_LDO_ENABLE_REG, mask, 0);
}
-static int lp3971_ldo_get_voltage(struct regulator_dev *dev)
+static int lp3971_ldo_get_voltage_sel(struct regulator_dev *dev)
{
struct lp3971 *lp3971 = rdev_get_drvdata(dev);
int ldo = rdev_get_id(dev) - LP3971_LDO1;
@@ -149,7 +147,7 @@ static int lp3971_ldo_get_voltage(struct regulator_dev *dev)
reg = lp3971_reg_read(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo));
val = (reg >> LDO_VOL_CONTR_SHIFT(ldo)) & LDO_VOL_CONTR_MASK;
- return dev->desc->volt_table[val];
+ return val;
}
static int lp3971_ldo_set_voltage_sel(struct regulator_dev *dev,
@@ -168,7 +166,7 @@ static struct regulator_ops lp3971_ldo_ops = {
.is_enabled = lp3971_ldo_is_enabled,
.enable = lp3971_ldo_enable,
.disable = lp3971_ldo_disable,
- .get_voltage = lp3971_ldo_get_voltage,
+ .get_voltage_sel = lp3971_ldo_get_voltage_sel,
.set_voltage_sel = lp3971_ldo_set_voltage_sel,
};
@@ -201,24 +199,16 @@ static int lp3971_dcdc_disable(struct regulator_dev *dev)
return lp3971_set_bits(lp3971, LP3971_BUCK_VOL_ENABLE_REG, mask, 0);
}
-static int lp3971_dcdc_get_voltage(struct regulator_dev *dev)
+static int lp3971_dcdc_get_voltage_sel(struct regulator_dev *dev)
{
struct lp3971 *lp3971 = rdev_get_drvdata(dev);
int buck = rdev_get_id(dev) - LP3971_DCDC1;
u16 reg;
- int val;
reg = lp3971_reg_read(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck));
reg &= BUCK_TARGET_VOL_MASK;
- if (reg <= BUCK_TARGET_VOL_MAX_IDX)
- val = buck_voltage_map[reg];
- else {
- val = 0;
- dev_warn(&dev->dev, "chip reported incorrect voltage value.\n");
- }
-
- return val;
+ return reg;
}
static int lp3971_dcdc_set_voltage_sel(struct regulator_dev *dev,
@@ -249,7 +239,7 @@ static struct regulator_ops lp3971_dcdc_ops = {
.is_enabled = lp3971_dcdc_is_enabled,
.enable = lp3971_dcdc_enable,
.disable = lp3971_dcdc_disable,
- .get_voltage = lp3971_dcdc_get_voltage,
+ .get_voltage_sel = lp3971_dcdc_get_voltage_sel,
.set_voltage_sel = lp3971_dcdc_set_voltage_sel,
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] regulator: lp3972: Convert to get_voltage_sel
2012-12-10 11:46 [PATCH 1/2] regulator: lp3971: Convert to get_voltage_sel Axel Lin
@ 2012-12-10 11:50 ` Axel Lin
2012-12-24 16:28 ` Mark Brown
2012-12-11 7:16 ` [PATCH 1/2] regulator: lp3971: " Marek Szyprowski
2012-12-24 16:27 ` Mark Brown
2 siblings, 1 reply; 5+ messages in thread
From: Axel Lin @ 2012-12-10 11:50 UTC (permalink / raw)
To: Mark Brown; +Cc: Liam Girdwood, linux-kernel
regulator_list_voltage_table() returns -EINVAL if selector >= n_voltages.
Thus we don't need to check if reg is greater than LP3972_BUCK_VOL_MAX_IDX in
lp3972_dcdc_get_voltage_sel.
LP3972_BUCK_VOL_MIN_IDX and LP3972_BUCK_VOL_MAX_IDX are not used, remove them.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/lp3972.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c
index 69c42c3..0baabcf 100644
--- a/drivers/regulator/lp3972.c
+++ b/drivers/regulator/lp3972.c
@@ -165,8 +165,6 @@ static const int buck_base_addr[] = {
#define LP3972_BUCK_VOL_ENABLE_REG(x) (buck_vol_enable_addr[x])
#define LP3972_BUCK_VOL1_REG(x) (buck_base_addr[x])
#define LP3972_BUCK_VOL_MASK 0x1f
-#define LP3972_BUCK_VOL_MIN_IDX(x) ((x) ? 0x01 : 0x00)
-#define LP3972_BUCK_VOL_MAX_IDX(x) ((x) ? 0x19 : 0x1f)
static int lp3972_i2c_read(struct i2c_client *i2c, char reg, int count,
u16 *dest)
@@ -257,7 +255,7 @@ static int lp3972_ldo_disable(struct regulator_dev *dev)
mask, 0);
}
-static int lp3972_ldo_get_voltage(struct regulator_dev *dev)
+static int lp3972_ldo_get_voltage_sel(struct regulator_dev *dev)
{
struct lp3972 *lp3972 = rdev_get_drvdata(dev);
int ldo = rdev_get_id(dev) - LP3972_LDO1;
@@ -267,7 +265,7 @@ static int lp3972_ldo_get_voltage(struct regulator_dev *dev)
reg = lp3972_reg_read(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo));
val = (reg >> LP3972_LDO_VOL_CONTR_SHIFT(ldo)) & mask;
- return dev->desc->volt_table[val];
+ return val;
}
static int lp3972_ldo_set_voltage_sel(struct regulator_dev *dev,
@@ -314,7 +312,7 @@ static struct regulator_ops lp3972_ldo_ops = {
.is_enabled = lp3972_ldo_is_enabled,
.enable = lp3972_ldo_enable,
.disable = lp3972_ldo_disable,
- .get_voltage = lp3972_ldo_get_voltage,
+ .get_voltage_sel = lp3972_ldo_get_voltage_sel,
.set_voltage_sel = lp3972_ldo_set_voltage_sel,
};
@@ -353,24 +351,16 @@ static int lp3972_dcdc_disable(struct regulator_dev *dev)
return val;
}
-static int lp3972_dcdc_get_voltage(struct regulator_dev *dev)
+static int lp3972_dcdc_get_voltage_sel(struct regulator_dev *dev)
{
struct lp3972 *lp3972 = rdev_get_drvdata(dev);
int buck = rdev_get_id(dev) - LP3972_DCDC1;
u16 reg;
- int val;
reg = lp3972_reg_read(lp3972, LP3972_BUCK_VOL1_REG(buck));
reg &= LP3972_BUCK_VOL_MASK;
- if (reg <= LP3972_BUCK_VOL_MAX_IDX(buck))
- val = dev->desc->volt_table[reg];
- else {
- val = 0;
- dev_warn(&dev->dev, "chip reported incorrect voltage value."
- " reg = %d\n", reg);
- }
- return val;
+ return reg;
}
static int lp3972_dcdc_set_voltage_sel(struct regulator_dev *dev,
@@ -402,7 +392,7 @@ static struct regulator_ops lp3972_dcdc_ops = {
.is_enabled = lp3972_dcdc_is_enabled,
.enable = lp3972_dcdc_enable,
.disable = lp3972_dcdc_disable,
- .get_voltage = lp3972_dcdc_get_voltage,
+ .get_voltage_sel = lp3972_dcdc_get_voltage_sel,
.set_voltage_sel = lp3972_dcdc_set_voltage_sel,
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] regulator: lp3971: Convert to get_voltage_sel
2012-12-10 11:46 [PATCH 1/2] regulator: lp3971: Convert to get_voltage_sel Axel Lin
2012-12-10 11:50 ` [PATCH 2/2] regulator: lp3972: " Axel Lin
@ 2012-12-11 7:16 ` Marek Szyprowski
2012-12-24 16:27 ` Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Marek Szyprowski @ 2012-12-11 7:16 UTC (permalink / raw)
To: Axel Lin; +Cc: Mark Brown, Liam Girdwood, linux-kernel
Hello,
On 12/10/2012 12:46 PM, Axel Lin wrote:
> regulator_list_voltage_table() returns -EINVAL if selector >= n_voltages.
> Thus we don't need to check if reg is greater than BUCK_TARGET_VOL_MAX_IDX in
> lp3971_dcdc_get_voltage_sel.
>
> BUCK_TARGET_VOL_MIN_IDX and BUCK_TARGET_VOL_MAX_IDX are not used, remove them.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> drivers/regulator/lp3971.c | 22 ++++++----------------
> 1 file changed, 6 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c
> index 5f68ff1..9cb2c0f 100644
> --- a/drivers/regulator/lp3971.c
> +++ b/drivers/regulator/lp3971.c
> @@ -73,8 +73,6 @@ static const unsigned int buck_voltage_map[] = {
> };
>
> #define BUCK_TARGET_VOL_MASK 0x3f
> -#define BUCK_TARGET_VOL_MIN_IDX 0x01
> -#define BUCK_TARGET_VOL_MAX_IDX 0x19
>
> #define LP3971_BUCK_RAMP_REG(x) (buck_base_addr[x]+2)
>
> @@ -140,7 +138,7 @@ static int lp3971_ldo_disable(struct regulator_dev *dev)
> return lp3971_set_bits(lp3971, LP3971_LDO_ENABLE_REG, mask, 0);
> }
>
> -static int lp3971_ldo_get_voltage(struct regulator_dev *dev)
> +static int lp3971_ldo_get_voltage_sel(struct regulator_dev *dev)
> {
> struct lp3971 *lp3971 = rdev_get_drvdata(dev);
> int ldo = rdev_get_id(dev) - LP3971_LDO1;
> @@ -149,7 +147,7 @@ static int lp3971_ldo_get_voltage(struct regulator_dev *dev)
> reg = lp3971_reg_read(lp3971, LP3971_LDO_VOL_CONTR_REG(ldo));
> val = (reg >> LDO_VOL_CONTR_SHIFT(ldo)) & LDO_VOL_CONTR_MASK;
>
> - return dev->desc->volt_table[val];
> + return val;
> }
>
> static int lp3971_ldo_set_voltage_sel(struct regulator_dev *dev,
> @@ -168,7 +166,7 @@ static struct regulator_ops lp3971_ldo_ops = {
> .is_enabled = lp3971_ldo_is_enabled,
> .enable = lp3971_ldo_enable,
> .disable = lp3971_ldo_disable,
> - .get_voltage = lp3971_ldo_get_voltage,
> + .get_voltage_sel = lp3971_ldo_get_voltage_sel,
> .set_voltage_sel = lp3971_ldo_set_voltage_sel,
> };
>
> @@ -201,24 +199,16 @@ static int lp3971_dcdc_disable(struct regulator_dev *dev)
> return lp3971_set_bits(lp3971, LP3971_BUCK_VOL_ENABLE_REG, mask, 0);
> }
>
> -static int lp3971_dcdc_get_voltage(struct regulator_dev *dev)
> +static int lp3971_dcdc_get_voltage_sel(struct regulator_dev *dev)
> {
> struct lp3971 *lp3971 = rdev_get_drvdata(dev);
> int buck = rdev_get_id(dev) - LP3971_DCDC1;
> u16 reg;
> - int val;
>
> reg = lp3971_reg_read(lp3971, LP3971_BUCK_TARGET_VOL1_REG(buck));
> reg &= BUCK_TARGET_VOL_MASK;
>
> - if (reg <= BUCK_TARGET_VOL_MAX_IDX)
> - val = buck_voltage_map[reg];
> - else {
> - val = 0;
> - dev_warn(&dev->dev, "chip reported incorrect voltage value.\n");
> - }
> -
> - return val;
> + return reg;
> }
>
> static int lp3971_dcdc_set_voltage_sel(struct regulator_dev *dev,
> @@ -249,7 +239,7 @@ static struct regulator_ops lp3971_dcdc_ops = {
> .is_enabled = lp3971_dcdc_is_enabled,
> .enable = lp3971_dcdc_enable,
> .disable = lp3971_dcdc_disable,
> - .get_voltage = lp3971_dcdc_get_voltage,
> + .get_voltage_sel = lp3971_dcdc_get_voltage_sel,
> .set_voltage_sel = lp3971_dcdc_set_voltage_sel,
> };
>
>
Best regards
--
Marek Szyprowski
Samsung Poland R&D Center
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] regulator: lp3971: Convert to get_voltage_sel
2012-12-10 11:46 [PATCH 1/2] regulator: lp3971: Convert to get_voltage_sel Axel Lin
2012-12-10 11:50 ` [PATCH 2/2] regulator: lp3972: " Axel Lin
2012-12-11 7:16 ` [PATCH 1/2] regulator: lp3971: " Marek Szyprowski
@ 2012-12-24 16:27 ` Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2012-12-24 16:27 UTC (permalink / raw)
To: Axel Lin; +Cc: Marek Szyprowski, Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 263 bytes --]
On Mon, Dec 10, 2012 at 07:46:52PM +0800, Axel Lin wrote:
> regulator_list_voltage_table() returns -EINVAL if selector >= n_voltages.
> Thus we don't need to check if reg is greater than BUCK_TARGET_VOL_MAX_IDX in
> lp3971_dcdc_get_voltage_sel.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] regulator: lp3972: Convert to get_voltage_sel
2012-12-10 11:50 ` [PATCH 2/2] regulator: lp3972: " Axel Lin
@ 2012-12-24 16:28 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2012-12-24 16:28 UTC (permalink / raw)
To: Axel Lin; +Cc: Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 263 bytes --]
On Mon, Dec 10, 2012 at 07:50:12PM +0800, Axel Lin wrote:
> regulator_list_voltage_table() returns -EINVAL if selector >= n_voltages.
> Thus we don't need to check if reg is greater than LP3972_BUCK_VOL_MAX_IDX in
> lp3972_dcdc_get_voltage_sel.
Applied, 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-12-24 16:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-10 11:46 [PATCH 1/2] regulator: lp3971: Convert to get_voltage_sel Axel Lin
2012-12-10 11:50 ` [PATCH 2/2] regulator: lp3972: " Axel Lin
2012-12-24 16:28 ` Mark Brown
2012-12-11 7:16 ` [PATCH 1/2] regulator: lp3971: " Marek Szyprowski
2012-12-24 16:27 ` 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.